Vertically Centered Boxes

From Wiki
Revision as of 10:50, 29 July 2005 by Mojca Miklavec (talk | contribs) (The examples with \bTABLE ... \eTABLE are not broken any more)
Jump to navigation Jump to search

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.