[Tex/LaTex] Problem with \setbox


I wrote the following box, which contains my name displayed vertically:


I'd like to dysplay it twice in a line, so I wrote:

\line{\hss \box0 \hss \box0 \hss}

But there is a problem: \box0 appears only once! I see only one copy of my name!

Instead, if I write

\line{\hss \vbox{\hbox{M}\hbox{a}\hbox{t}\hbox{t}\hbox{e}\hbox{o}} \hss \vbox{\hbox{M}\hbox{a}\hbox{t}\hbox{t}\hbox{e}\hbox{o}}\hss}

I get the desired output.

What's wrong with the use of \setbox0 or \box0?

(All is done under plain TeX.)

Best Answer

\box also clears the box register. Use \copy instead.

\line{\hss \copy0 \hss \copy0 \hss}

I would use \hfill instead of \hss. Then TeX will throw an overfull \hbox warning, if the place is not sufficient.

A centered version can be achieved via \halign:

\setbox0\vbox{\halign{\hfil#\hfil\cr M\cr a\cr t\cr t\cr e\cr o\cr}}
\line{\hfill \copy0 \hfill \copy0 \hfill}


Smaller space between letters

The following example uses different methods to reduce the space between the letters. The first boxes 0, 2, 4 (even numbered boxes smaller than ten are scratch boxes for local assignments) keep the distance between the baselines constant. Box 0 is the unmodified version. Box 2 shrinks the \baselineskip according to egreg's comment. The extreme is in box 4, where the maximum letter height is measured with the result that the two "t"s are in touch.

The boxes 6 and 8 keep the distance between the letters constant. Because of \baselineskip=0pt, TeX switches to set \lineskip instead. It's default value is 1pt. Box 8 finally does not leave any space between the letters.

\def\test{\halign{\hfil##\hfil\cr M\cr a\cr t\cr t\cr e\cr o\cr}}


\line{\hfill\copy0 \hfill\copy2 \hfill\copy4 \hfill\copy6 \hfill\copy8 \hfill}


Related Question