question
Jim Diamond
jim at jdvb.ca
Sun Apr 30 21:03:48 CEST 2023
On Sat, Apr 29, 2023 at 14:41 (-0700), Walter Burkhard via texhax wrote:
> Hello,
> I am trying to draw in TeX a 4cm x 5.3cm outline rectangle. However,
> I am missing something and the outline is not accomplished. I have
> attached two files, one the "source" test.tex and the other the "output"
> test.pdf.
> What am I missing here.
> Many thanks in advance.
Hi Walt,
you are constructing a vbox, and in your vbox you have multiple hboxes.
But sometimes (see The TeXbook!) in such cases you will get space between
the entries in a vbox.
If you add
\offinterlineskip
as the first thing inside your \vtop, I think it should work for you.
(It works for me, anyway.)
You might consider using something like the following (admittedly it is a
bit obsessively commented), in case you find it easier to use in some
cases. Or even if you find the definition somehow illuminating.
% Define this function once
\def\frameit#1{% modified version where the lines on left & bottom have 0 size
\hbox{% So we can back up horizontally after hrules drawn
\vbox{% Cuz we're stacking things vertically
\hrule % First, the top edge
\hbox{% Then an hbox which has...
\vrule % the left edge
\hbox{#1}% the contents
\vrule % and the right edge
}%
\hrule % Now the bottom edge
\setbox0=\vbox{\hrule}% And back up over that edge so that boxes
\vskip-\ht0 \vskip-\dp0% stacked vertically fit together
}%
\setbox1=\hbox{\vrule}%
\hskip-\wd1% Finally backspace over the right edge so
}% that boxes next to each other merge
}
% And get that box you are looking for:
\frameit{\hbox to 4cm{\hss\vrule height 5.3 cm width 0pt}}
% Or a box with no border around something else:
\frameit{This is some text in a box.}
Jim
P.S. If you use some brain-dead OS and/or mail program that likes to turn
multiple-space sequences into non-breakable spaces, the above may crash and
burn unless you sanitize it. It was fine when it left here.
More information about the texhax
mailing list.