I want to enclose a text in a box. My problem is that when the code below is placed at the beginning of a line it causes a line-break/carriage-return (the box stays on a line by itself, the rest of paragraph starts at the next line). But it is OK when I use it in the middle or the end of a line. What is causing this behavior?
\def\boxit#1#2{\hbox{\vrule
\vtop{%
\vbox{\hrule\kern#1%
\hbox{\kern#1#2\kern#1}}%
\kern#1 \hrule}%
\vrule}}
\def\emptybox#1#2#3{\hbox spread #3{\hfil
\vtop spread #2{
\vbox spread #1{\vfil}
\vfil}}}
\hbox
doesn't start horizontal mode; add\leavevmode
as the first token in the replacement text.