[texhax] \boxit
Daniel H. Luecking
luecking at uark.edu
Thu Jun 28 23:28:14 CEST 2018
Rodolfo Medina wrote:
>In the following example, to be processed simply with `text file', the left box
>is bottomed down, whereas I want it `toped' up at the same level as the right
>box. How could I change the definition of \boxit so to do that...?
[example omitted]
This is what I use (adjust the kerns to get desired
spacing):
\long\def\frameit#1{% Frames box or text, preserves baseline.
\leavevmode
\hbox{% % encloses framed box
\vrule % Left side
\vtop{ % \vtop has same baseline as its
\vbox{ % first box (namely the \vbox here).
\hrule % Top side
\kern 3pt % Top gap
\hbox{% % Innermost \hbox, encloses text or box
\kern 3pt % Left gap
\ignorespaces #1% % maybe "#1\unskip%"?
\kern 3pt % Right gap
}% % END hbox: \vbox has same baseline
}% % END \vbox
\kern 3pt % Bottom gap
\hrule % Bottom side
}% % END \vtop
\vrule % Right side
}% % END \hbox
}%
\bigskip
\frameit{hallo}%
\frameit{\vtop{\hsize2cm\parindent0pt to be or not to be, that is the question}}
The definition itself is designed to produce a box that has the
same baseline as its contents. Then I have to feed it a \vtop
so as to make the baseline align with the top line of the text.
The trick is not to put a \kern at the very top of a \vtop, nor at
the very bottom of a \vbox, as then TeX puts the baseline right at
the top or bottom instead of at the baseline of the text.
Cheers,
Dan
Daniel H. Luecking, Graduate Coordinator
Dept. of Mathematical Sciences
University of Arkansas
Fayetteville, AR, USA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20180628/30768d28/attachment-0001.html>
More information about the texhax
mailing list