Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am new to La Tex and wondering when to use a tilde, or a \mbox? A tilde prohibits a line break and so does \mbox, so when to use one or the other? For example, should I use:

\mbox{words to kept together} 

or,

 words~to~be~kept~together
share|improve this question
    
Welcome to TeX.SE. –  Peter Grill Jul 1 '12 at 18:31

1 Answer 1

There are probably other reasons, but I believe the space given by a ~ can stretch or shrink as other spaces in the line, while an \mbox gives you a fixed box, with fixed spaces.

And words joined with ~ can still be hyphenated, while an \mbox won't.

\documentclass[a5paper]{article}
\sloppy
\begin{document}
A text with~some~unbreakable~spaces might stretch to jusssssssssssstify the line.
A text \mbox{with some unbreakable spaces} might stretch to jusssssssssssstify the line.
A~text~with~unbreakable~spaces~might~be~hyphenated~if~necessary.
\mbox{A text with unbreakable spaces might be hyphenated if necessary.}
\end{document}

enter image description here

share|improve this answer
1  
I'd add that \mbox{...} is very useful for avoiding line breaks in a particular word. –  egreg Jul 2 '12 at 10:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.