What's going on with an item that starts with an hbox?
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
\makebox[1cm]{...}
which will automatically apply \leavevmode
as well as constructing the 1cm wide box.
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
ECM
\documentclass{article}
\def\myitem{\setbox0=\hbox{\textbullet\quad}\everypar{\unhbox0\everypar{}}}
\begin{document}
\myitem foo bar.
\myitem you see.
\myitem \mbox{OK. here} every thing is good.
\myitem \hbox {No!} but not here.
\end{document}
ECM
\documentclass{article}
\begin{document}
\begingroup
\everypar{\textbf{Foo} }
yes
\mbox{yes} again
\hbox{what's} now
\endgroup
\end{document}