6

Why when I write a hbox at the beginning of a paragraph, TeX puts the next word in the next line, but when the paragraph starts with a 'normal' letter TeX puts all together in a line? i.e. :

\hbox{Hello} World

generates

Hello

World

...but

A\hbox{Hello} World

produces

AHello World

1 Answers1

7

In the first case, TeX is in vertical mode when you insert the \hbox. The material inside the box is (of course) typeset in horizontal mode, but the box itself is inserted in vertical mode and does not start a paragraph. That happens when TeX gets to the w of world, so you see a separate paragraph there.

In the second case, TeX is already in horizontal mode when the box is inserted, so it just 'fits in' to the paragraph.

You need to ensure you are not in vertical mode, which is what \leavevmode is for

\hbox{Hello} World

(In LaTeX, you'll see all of the 'higher level' box constructs deliberately escape from horizontal mode by containing a built-in \leavevmode. You still need one with the 'raw' \hbox, however.)

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036