# \hbox \mbox difference … what they do? [duplicate]

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...

## marked as duplicate by egreg boxes StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Feb 15 at 16:48

• Possible duplicate: What are the different kinds of boxes in (La)TeX? – Werner Feb 15 at 16:46
• An \mbox leaves 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 at 16:51
• What they do is set text in a horizontal box. A box cannot be broken in the middle. So they can be used to prevent breaking up a text across lines. Also, glue (compressible/expandable space used to meet margin requirements) will not be active inside a box – Steven B. Segletes Feb 15 at 16:59
• I was actually asking right about this, now upvoted comment. No one is able to expalin to me what is the difference between \mbox and \hbox. Can you, please?? Or at least give me a link. Even the marking duplicate link doesn't address this question! How can I examine \meaning\mbox ? It cannot be clicked into this. – user2925716 Feb 15 at 17:38
• @user2925716: There is a discussion in the linked answer about what each box does. – Werner Feb 15 at 17:52

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}


• I actually do not understand what difference makes leaving vertical mode in this example: \textbf{WHEN LEAVING VERTICAL MODE MAKES A DIFFERENCE}... – user2925716 Feb 16 at 17:43
• @user2925716 The vertical gap above the line "Irregular line space..." is less than a normal paragaph break. Why? Because that line (an \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 at 17:51