ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: centering framed boxes
@ 2005-05-15 12:02 Idris Samawi Hamid
  0 siblings, 0 replies; 5+ messages in thread
From: Idris Samawi Hamid @ 2005-05-15 12:02 UTC (permalink / raw)


I forgot about $\vcenter$ (I hardly ever need math mode, so...)

The following works for the framed boxes, and the text is well positioned 
also, but is there a better/more efficient way to center the text between 
frames?

Best
Idris
=============================================
\setupoutput[pdftex]%

\setuppagenumbering[state=stop]
\starttext\showstruts

\setupfloats[location=middle]
\placefigure
[here][tab:enclosure]{4 Stages.}
{
 \midaligned{
 \framed
 [width=12\baselineskip,height=12\baselineskip,strut=yes]
 {\midaligned{\raise.25ex\hbox{Stage 1}}
   $\vcenter%
   {\framed[width=9\baselineskip,height=9\baselineskip,strut=yes]
     {\midaligned{\raise.25ex\hbox{Stage 2}}
       $\vcenter%
       {\framed[width=6\baselineskip,height=6\baselineskip,strut=yes]
         {\midaligned{\raise.25ex\hbox{Stage 3}}
           $\vcenter%
           {\framed[width=3\baselineskip,height=3\baselineskip,strut=yes]
            {\midaligned{\raise.25ex\hbox{Stage 4}}}
           }$
         \midaligned{\null}}%
       }$
     \midaligned{\null}}%
   }$
 \midaligned{\null}}
 }
}

\stoptext
============================================

===============original message=============
Dear gang,

I need a way to overlay four framed boxes so that each inner box is exactly in
the center of its respective outer box. So far I have the following, but
careful inspection will show that the boxes are not precisely centered with
respect to each other. I could go on by trial and error but I'm sure there is
a direct way to do this.

The text should also be precisely centered between frames.

Thank you in advance!
Idris

============================
Professor Idris Samawi Hamid
Department of Philosophy
Colorado State University
Fort Collins, CO 80523

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: centering framed boxes
@ 2005-05-17 13:39 Idris Samawi Hamid
  0 siblings, 0 replies; 5+ messages in thread
From: Idris Samawi Hamid @ 2005-05-17 13:39 UTC (permalink / raw)


>===== Original Message From Hans Hagen <pragma@wxs.nl> =====
>\starttext
>
>\definelayer[test][width=12\bodyfontsize,height=12\bodyfontsize]
>
>\setlayerframed[test][preset=middle][width=12\bodyfontsize,height=12\bodyfont
size]{one}
>\setlayerframed[test][preset=middle][width= 9\bodyfontsize,height=
>9\bodyfontsize]{two}
>\setlayerframed[test][preset=middle][width= 6\bodyfontsize,height=
>6\bodyfontsize]{three}
>\setlayerframed[test][preset=middle][width= 3\bodyfontsize,height=
>3\bodyfontsize]{four}
>
>\tightlayer[test]
>
>\stoptext

Hi Hans,

I tried your code (so beautiful and simple!): it properly stacks the frames 
but places the text for each level, not midway between frames as desired, but 
in the middle frame (on top of one another).

Anyway, the following file illustrates the exact effect I'm trying to acheive 
(note the final overlay of some text across all four levels). I certainly 
would prefer to do this the ConTeXt way (e.g. is there a better way to stretch 
the word `testing'?)!

Thanks as always for your guidance and help.

Best
Idris
============================================
\setupoutput[pdftex]%

\setuppagenumbering[state=stop]
\starttext\showstruts

\startbuffer[Test]
\setupfloats[location=middle]
\placefigure
[here][fig:Test]{4 levels.}
{\startbuffer[test]\vbox{
 \midaligned{\it
 \framed
 [width=12\baselineskip,height=12\baselineskip,strut=yes]
 {\midaligned{\raise.25ex\hbox{level 1}}
   $\vcenter%
   {\framed[width=9\baselineskip,height=9\baselineskip,strut=yes]
     {\midaligned{\raise.25ex\hbox{level 2}}
       $\vcenter%
       {\framed[width=6\baselineskip,height=6\baselineskip,strut=yes]
         {\midaligned{\raise.25ex\hbox{level 3}}
           $\vcenter%
           {\framed[width=3\baselineskip,height=3\baselineskip,strut=yes]
            {\midaligned{\raise3.6ex\hbox{level 4}}}
           }$
         \midaligned{\null}}%
       }$
     \midaligned{\null}}%
   }$
 \midaligned{\null}}
 }
}
\stopbuffer

\startbuffer[testing]\vbox{\midaligned{\kern-6\baselineskip\itb
                           \lower1.4ex\hbox{t\,e\,s\,t\,i\,n\,g}}}
\stopbuffer
\hbox{$\vcenter{\getbuffer[test]}\llap{$\vcenter{\getbuffer[testing]}$}$}
}
\stopbuffer

\getbuffer[Test]

\stoptext
===============================================

============================
Professor Idris Samawi Hamid
Department of Philosophy
Colorado State University
Fort Collins, CO 80523

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: centering framed boxes
  2005-05-15  2:39 Idris Samawi Hamid
  2005-05-17  7:23 ` Hans Hagen
@ 2005-05-17  7:30 ` Hans Hagen
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2005-05-17  7:30 UTC (permalink / raw)


Idris Samawi Hamid wrote:
> Dear gang,
> 
> I need a way to overlay four framed boxes so that each inner box is exactly in 
> the center of its respective outer box. So far I have the following, but 
> careful inspection will show that the boxes are not precisely centered with 
> respect to each other. I could go on by trial and error but I'm sure there is 
> a direct way to do this.
> 
> The text should also be precisely centered between frames.
> 
> Thank you in advance!
> Idris
> =========================================================
> \setupoutput[pdftex]%
> 
> \setuppagenumbering[state=stop]
> \starttext
> 
> \setupfloats[location=middle]
> \placefigure
> [here][tab:enclosure]{4 Stages.}
> {
>  \midaligned{
>  \framed
>  [width=12\baselineskip,height=12\baselineskip,strut=yes]
>  {\midaligned{Stage 1}
>    \midaligned%
>    {\framed[width=9\baselineskip,height=9\baselineskip,strut=yes]
>      {\midaligned{Stage 2}
>        \midaligned%
>        {\framed[width=6\baselineskip,height=6\baselineskip,strut=yes]
>          {\midaligned{Stage 3}
>            \midaligned%
>            {\framed[width=3\baselineskip,height=3\baselineskip,strut=yes]
>             {\midaligned{Stage 4}}
>            }
>          \midaligned{\null}}%
>        }
>      \midaligned{\null}}%
>    }
>  \midaligned{\null}}
>  }
> }
> 
> \stoptext
\starttext

\definelayer[test][width=12\bodyfontsize,height=12\bodyfontsize]

\setlayerframed[test][preset=middle][width=12\bodyfontsize,height=12\bodyfontsize]{one}
\setlayerframed[test][preset=middle][width= 9\bodyfontsize,height= 
9\bodyfontsize]{two}
\setlayerframed[test][preset=middle][width= 6\bodyfontsize,height= 
6\bodyfontsize]{three}
\setlayerframed[test][preset=middle][width= 3\bodyfontsize,height= 
3\bodyfontsize]{four}

\tightlayer[test]

\stoptext


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: centering framed boxes
  2005-05-15  2:39 Idris Samawi Hamid
@ 2005-05-17  7:23 ` Hans Hagen
  2005-05-17  7:30 ` Hans Hagen
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2005-05-17  7:23 UTC (permalink / raw)


Idris Samawi Hamid wrote:
> Dear gang,
> 
> I need a way to overlay four framed boxes so that each inner box is exactly in 
> the center of its respective outer box. So far I have the following, but 
> careful inspection will show that the boxes are not precisely centered with 
> respect to each other. I could go on by trial and error but I'm sure there is 
> a direct way to do this.
> 
> The text should also be precisely centered between frames.
> 
> Thank you in advance!
> Idris
> =========================================================
> \setupoutput[pdftex]%
> 
> \setuppagenumbering[state=stop]
> \starttext
> 
> \setupfloats[location=middle]
> \placefigure
> [here][tab:enclosure]{4 Stages.}
> {
>  \midaligned{
>  \framed
>  [width=12\baselineskip,height=12\baselineskip,strut=yes]
>  {\midaligned{Stage 1}
>    \midaligned%
>    {\framed[width=9\baselineskip,height=9\baselineskip,strut=yes]
>      {\midaligned{Stage 2}
>        \midaligned%
>        {\framed[width=6\baselineskip,height=6\baselineskip,strut=yes]
>          {\midaligned{Stage 3}
>            \midaligned%
>            {\framed[width=3\baselineskip,height=3\baselineskip,strut=yes]
>             {\midaligned{Stage 4}}
>            }
>          \midaligned{\null}}%
>        }
>      \midaligned{\null}}%
>    }
>  \midaligned{\null}}
>  }
> }
> 
> \stoptext

yuo're messing around with struts -)

keep it simple:

\showstruts

  \framed
  [width=12\baselineskip,height=12\baselineskip,strut=no]
  {\framed[width=9\baselineskip,height=9\baselineskip,strut=no]
     {\framed[width=6\baselineskip,height=6\baselineskip,strut=no]
        {\framed[width=3\baselineskip,height=3\baselineskip,strut=no]
           {\begstrut text\endstrut}
        }
    }}

-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* centering framed boxes
@ 2005-05-15  2:39 Idris Samawi Hamid
  2005-05-17  7:23 ` Hans Hagen
  2005-05-17  7:30 ` Hans Hagen
  0 siblings, 2 replies; 5+ messages in thread
From: Idris Samawi Hamid @ 2005-05-15  2:39 UTC (permalink / raw)


Dear gang,

I need a way to overlay four framed boxes so that each inner box is exactly in 
the center of its respective outer box. So far I have the following, but 
careful inspection will show that the boxes are not precisely centered with 
respect to each other. I could go on by trial and error but I'm sure there is 
a direct way to do this.

The text should also be precisely centered between frames.

Thank you in advance!
Idris
=========================================================
\setupoutput[pdftex]%

\setuppagenumbering[state=stop]
\starttext

\setupfloats[location=middle]
\placefigure
[here][tab:enclosure]{4 Stages.}
{
 \midaligned{
 \framed
 [width=12\baselineskip,height=12\baselineskip,strut=yes]
 {\midaligned{Stage 1}
   \midaligned%
   {\framed[width=9\baselineskip,height=9\baselineskip,strut=yes]
     {\midaligned{Stage 2}
       \midaligned%
       {\framed[width=6\baselineskip,height=6\baselineskip,strut=yes]
         {\midaligned{Stage 3}
           \midaligned%
           {\framed[width=3\baselineskip,height=3\baselineskip,strut=yes]
            {\midaligned{Stage 4}}
           }
         \midaligned{\null}}%
       }
     \midaligned{\null}}%
   }
 \midaligned{\null}}
 }
}

\stoptext
=========================================================

============================
Professor Idris Samawi Hamid
Department of Philosophy
Colorado State University
Fort Collins, CO 80523

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-05-17 13:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-15 12:02 centering framed boxes Idris Samawi Hamid
  -- strict thread matches above, loose matches on Subject: below --
2005-05-17 13:39 Idris Samawi Hamid
2005-05-15  2:39 Idris Samawi Hamid
2005-05-17  7:23 ` Hans Hagen
2005-05-17  7:30 ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).