Difference between revisions of "Vertically Centered Boxes"

From Wiki
Jump to navigation Jump to search
(simplify the macros)
(The examples with \bTABLE ... \eTABLE are not broken any more)
Line 48: Line 48:
  
 
If you need a proper table (the one above only had one column), use <code>\bTABLE ... \eTABLE</code> or similar instead of <code>1\\2\\3</code>. See [[Tables Overview]] for more possibilities.
 
If you need a proper table (the one above only had one column), use <code>\bTABLE ... \eTABLE</code> or similar instead of <code>1\\2\\3</code>. See [[Tables Overview]] for more possibilities.
 
 
A broken example (for the second box):
 
 
<context>
 
\setupTABLE[frame=on]
 
\setupTABLE[c][1,2][align=lohi]
 
\bTABLE
 
\bTR\bTD
 
  a midaligned parbox:
 
\eTD\bTD[offset=0pt,width=1em]
 
  1 2 3
 
\eTD\eTR
 
\eTABLE
 
</context>
 

Revision as of 10:50, 29 July 2005

In LaTeX

\documentclass{article}
\begin{document}
a box with a table:
\fbox{\begin{tabular}[c]{l}1\\2\\3\end{tabular}}\par
a midaligned parbox: \parbox[c]{1em}{1 2 3}
\end{document}

In ConTeXt:

a box with a table:
\framed
   [location=middle, % vertically centered
    align=flushleft, % align=no (default) is a normal hbox
                     % align=flushleft/middle/flushright/normal is used for multiple lines
    offset=5pt]      % to make the frame wider (as in LaTeX)
   {1\\2\\3}

a midaligned parbox:
\framed
   [location=middle, % vertically centered
    align=normal,    % justified alignment
    frame=off,       % no frame
    width=1em]       % make box 1em wide; note that line breaking is not the same as in LaTeX (?)
   {1 2 3}

If you need a proper table (the one above only had one column), use \bTABLE ... \eTABLE or similar instead of 1\\2\\3. See Tables Overview for more possibilities.