I've been using LaTeX for years and never saw this before: if an item (in enumerate) starts with an \hbox, then the \hbox is placed before the label!


\def\Blank#1{\relax{\hbox to 1in{\hrulefill\textsl{#1}\hrulefill}}}



Here's a list:
\Blank{test}, plus stuff after.

\Blank{test}, plus stuff after.

\Blank{test}, plus stuff after.

\item{ }
\Blank{test}, plus stuff after.

\item{ }\relax
\hbox to 1in{\hrulefill\textsl{test}\hrulefill}, plus stuff after.

\item{ X }
\Blank{test}, plus stuff after.

% etc.



The result is unexpected, except for the last item. shows text coming before labels

Blanks, \relax, nothing stops the \hbox being moved back except actual text.

What am I doing wrong?


As explained in

Differentiating between \hbox and \mbox

\hbox is a TeX primitve not a LaTeX command and does not react well with most LaTeX constructs, notably it is not centered by a center environment and has various perhaps unexpected behaviours at the start of a paragraph.

The specific interaction with lists is not mentioned there though so answering here rather than suggesting that is a duplicate.

LaTeX implements list item labels by typesetting the label into a box register and then inserting the label at the start of the following paragraph. \hbox does not start a paragraph, this primitive box construct inserts the hbox directly into the surrounding vertical list, so the saved item label is not inserted until some following text does start the paragraph. So the lable comes after the box.

So you could fix this by using \leavevmode\hbox instead of simply \hbox (that is the main part of the definition of \mbox) or as you are using the \hbox to syntax you could use the standard latex equivalent namely


which will automatically apply \leavevmode as well as constructing the 1cm wide box.

  • didn't see befor posting . Sorry ;-) – touhami Aug 6 '19 at 17:54
  • @touhami no harm done:-) – David Carlisle Aug 6 '19 at 17:55

What happen is that the label is placed with \everypar command.

\everypar content is inserted at the beging of every paragraph, when TeX enter to horizental mode (after indentation).

The \hbox primitive doesn't start a new paragraph i.e. it's add to the vertical list, so the label will wait for additional stuff that start a new paragraph (comma , in the OP).

See this question




\myitem foo bar.

\myitem you see.

\myitem \mbox{OK. here} every thing is good.

\myitem \hbox {No!} but not here.



\everypar{\textbf{Foo} }

\mbox{yes} again

\hbox{what's} now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.