~
stands for a non-breaking space, and \mbox{<text>}
creates a box with text in it that cannot be broken (since its a "box").
I understand that \mbox
has broader application than ~
(e.g. when you put not text only, but also pictures in it).
However, considering text only, what is the difference between ~
and \mbox
? And when should I use the one or the other in following circumstances?
- A phone number: 0123
4567
8901
- A page number abbreviation : p.
210
sq.
- A two-parts family name : Jean de La
Fontaine
- Punctuation: (in french) «
Oh là là
: c'est un cul-de-sac
!
»
\mbox
produces non-streatchable spaces, while~
produces a space which stretches as the other spaces on the same line\mbox
with text is to disallow breaking of things that contain hyphens. For example, I write a lot of documents that contain our company's part numbers. An example is\mbox{040-24800}
.