What is the difference between \hbox and \mbox?
What are these commands intended to do?
I cannot see what they do from my code alone without a word explanation...
What is the difference between \hbox and \mbox?
What are these commands intended to do?
I cannot see what they do from my code alone without a word explanation...
As mentioned in a comment, \mbox leaves vertical mode before employing an \hbox. But the question also seemed to encompass "what is a box"?
So, this answer tries to answer both issues. The first three examples compare boxed text to unboxed text. The last example addresses when leaving vertical mode makes a difference.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\parindent0pt
\begin{document}
Mbox Meaning: \meaning\mbox
\hrulefill
\textbf{BOXES ARE UNBREAKABLE}
This is a texting piece of text. This is a texting piece of text.
This is a texting piece of text.
\mbox{This is a texting piece of text. This is a texting piece of text.
This is a texting piece of text.}
\hrulefill
\textbf{BOXES ARE UNHYPHENATABLE}
This is a texting piece of text. This is texting piece of text.
This is an hyphenatable piece of text.
This is a texting piece of text. This is texting piece of text.
This is an \mbox{hyphenatable} piece of text.
\hrulefill
\textbf{BOXES ARE UNSTRETCHABLE}
This is a texting piece of text. This is the texting piece of text.
This is a texting piece of text.
This is a texting \mbox{piece of text. This is the texting piece of text.}
This is a texting piece of text.
\hrulefill
\textbf{WHEN LEAVING VERTICAL MODE MAKES A DIFFERENCE}
\parskip 1ex
blah
\mbox{Regular line space with mbox}
\hbox{Irregular line space with hbox}
blah
\end{document}
\hbox) was set in vertical mode, so all the close-out-the-one-paragraph-and-begin-the-next-paragraph instructions were never executed.
– Steven B. Segletes
Feb 16 '19 at 17:51
\mboxleaves vertical mode before invoking an\hbox(see\meaning\mbox). I'm sure someone can point out when that makes a difference. – Steven B. Segletes Feb 15 '19 at 16:51