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.

In my answer to How can I get following layout? I've used non-breaking spaces ~ (ties) to align monospaced text. Actually I rather meant control spaces \ , but they're less convenient to type (and read), and line breaks were not of interest anyway. Some experiments concerning line breaking are documented in the code below.

Question: Besides their line-breaking behaviour, is there any difference between \ and ~? In particular, do (or may) they by nature have a different width?

 

\documentclass{article}
\usepackage{lipsum}
\usepackage{parskip}

\begin{document}

\lipsum[75]

%non-breaking space
lorem lorem lorem lorem lorem lorem lorem lorem lorem 
lorem lorem lo~lo~lo~lo~lo~lo~lo~lo~ip~ip~ip~sum sum sum sum sum sum sum sum sum

lorem lorem lorem lorem lorem lorem lorem lorem lorem 
lorem lorem lo~lo~lo~lo~lo~ %input line break doesn't affect non-breaking space
lo~lo~lo~ip~ip~ip~sum sum sum sum sum sum sum sum sum

lorem lorem lorem lorem lorem lorem lorem lorem lorem 
lorem lorem lo~lo~lo~lo~lo  %breaks at input line break
lo~lo~lo~ip~ip~ip~sum sum sum sum sum sum sum sum sum

%breaks at protected space
lorem lorem lorem lorem lorem lorem lorem lorem lorem 
lorem lorem lo~lo~lo~lo~lo\ lo~lo~lo~ip~ip~ip~sum sum sum sum sum sum sum sum sum

\end{document}

enter image description here

share|improve this question

1 Answer 1

up vote 16 down vote accepted

Control space \ and a tie ~ have the same width and only differ in their line-breaking behaviour. The definition of the latter, taken from latex.ltx is:

\DeclareRobustCommand{\nobreakspace}{%
   \leavevmode\nobreak\ }
\catcode `\~=13
\def~{\nobreakspace{}}
share|improve this answer
1  
I'm wondering why it's LaTeX that defines the tie. Is it not a TeX primitive? –  dgs Jun 9 '12 at 23:34
    
@dgs: Yes, TeX actually defines it as \penalty\@M\ , but LaTeX redefines it. –  Werner Jun 9 '12 at 23:40
8  
@Werner ~ is not a primitive in plain TeX, it is an active character with a macro definition (\penalty\@M\ , as you say). –  Joseph Wright Jun 10 '12 at 7:30

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.