# Boxes and glue: hand-setting letter header

I tried to set a letter header by hand, using two vboxes inside an hbox. I expected the right side of the second to align with the right margin, but that is not what happened. What am I missing?

\hbox to \hsize {\parindent=0pt\obeylines
\vbox{Mr. Recipient
\hfil
\vbox{Sender

In the shade of the house, in the sunshine of the riverbank near the
boats, in the shade of the Sal-wood forest, in the shade of the fig tree
is where Siddhartha grew up, the handsome son of the Brahman, the young
falcon, together with his friend Govinda, son of a Brahman.  The sun
tanned his light shoulders by the banks of the river when bathing,
performing the sacred ablutions, the sacred offerings.  In the mango
grove, shade poured into his black eyes, when playing as a boy, when
his mother sang, when the sacred offerings were made, when his father,
the scholar, taught him, when the wise men talked.  For a long time,
Siddhartha had been partaking in the discussions of the wise men,
practising debate with Govinda, practising with Govinda the art of
reflection, the service of meditation.  He already knew how to speak the
Om silently, the word of words, to speak it silently into himself while
inhaling, to speak it silently out of himself while exhaling, with all
the concentration of his soul, the forehead surrounded by the glow of
the clear-thinking spirit.  He already knew to feel Atman in the depths
of his being, indestructible, one with the universe.

\bye


The result of this is that the /left/ margin of the second box is aligned with the right margin of the text.

• You are making paragraphs in the \vbox so it ends up \hsize wide. – egreg Aug 13 '17 at 9:54

Here's another approach, along the lines of what you were trying to do:

\hbox to \hsize {%
\hfil%

In the shade of the house, in the sunshine of the riverbank near the
boats, in the shade of the Sal-wood forest, in the shade of the fig tree
is where Siddhartha grew up, the handsome son of the Brahman, the young
falcon, together with his friend Govinda, son of a Brahman.  The sun
tanned his light shoulders by the banks of the river when bathing,
performing the sacred ablutions, the sacred offerings.  In the mango
grove, shade poured into his black eyes, when playing as a boy, when
his mother sang, when the sacred offerings were made, when his father,
the scholar, taught him, when the wise men talked.  For a long time,
Siddhartha had been partaking in the discussions of the wise men,
practising debate with Govinda, practising with Govinda the art of
reflection, the service of meditation.  He already knew how to speak the
Om silently, the word of words, to speak it silently into himself while
inhaling, to speak it silently out of himself while exhaling, with all
the concentration of his soul, the forehead surrounded by the glow of
the clear-thinking spirit.  He already knew to feel Atman in the depths
of his being, indestructible, one with the universe.

\bye


(Note the %s to avoid unwanted spaces.)

Why did your approach:

\hbox to \hsize {\parindent=0pt\obeylines
\vbox{Mr. Recipient
\hfil
\vbox{Sender


not work? The short answer is that when TeX sees the capital M inside the \vbox, it goes into (restricted) horizontal mode, and starts creating a paragraph at the current width (the \hsize you are in). The best book IMO on these boxes-and-glue aspects of TeX is A Beginner's Book of TeX by Raymond Seroul and Silvio Levy. See the following from page 82 (Chapter 8: Boxes), which explains exactly this natural mistake:

• Moving acceptance to this, since it is the more direct answer. – Toothrot Aug 15 '17 at 7:44

You're making paragraphs in your \vbox, so the width ends up to be \hsize.

You can use \halign, instead.

\def\header#1#2{%
\hbox to \hsize{%
}%
}
\vbox{
\let\\\cr
\ialign{##\unskip\hfil\cr#1\crcr}
}%
}

Mr. Recipient \\
}{
Sender \\
}

In the shade of the house, in the sunshine of the riverbank near the
boats, in the shade of the Sal-wood forest, in the shade of the fig tree
is where Siddhartha grew up, the handsome son of the Brahman, the young
falcon, together with his friend Govinda, son of a Brahman.  The sun
tanned his light shoulders by the banks of the river when bathing,
performing the sacred ablutions, the sacred offerings.  In the mango
grove, shade poured into his black eyes, when playing as a boy, when
his mother sang, when the sacred offerings were made, when his father,
the scholar, taught him, when the wise men talked.  For a long time,
Siddhartha had been partaking in the discussions of the wise men,
practising debate with Govinda, practising with Govinda the art of
reflection, the service of meditation.  He already knew how to speak the
Om silently, the word of words, to speak it silently into himself while
inhaling, to speak it silently out of himself while exhaling, with all
the concentration of his soul, the forehead surrounded by the glow of
the clear-thinking spirit.  He already knew to feel Atman in the depths
of his being, indestructible, one with the universe.

\bye