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.

When using some other editors, when you type two spaces with your space bar, two spaces are effectively displayed. This is not the case in LaTeX (btw, that's not the case on these websites ;) ).

My question is barely simple I guess, but I didn't found some information about it on Google.

How to display two consecutive spaces in LaTeX (I mean two spaces horizontally, with the space bar).

share|improve this question
7  
What are you actually trying to achieve in your document? Since all good typesetting programs adjust word spacing to best fit the justification of the text, the concept of a "space" doesn't really exist. If you need to format code or something, then there are better ways to this this. –  Alan Munn Jan 1 '13 at 18:17
8  
Adding two consecutive spaces after an end-of-sentence period is nowadays considered old fashioned (see e.g. Bringhurst's Elements of Typographic Style). If I understand correctly, word users have to add the spaces explicitly, which is prone to errors. LaTeX can add them automatically: just put \nonfrenchspacing in your preamble (this is the default). However, if you want a modern look of your document, just put \frenchspacing in your document preamble. This is what I recommend in LaTeX and Friends. –  Marc van Dongen Jan 1 '13 at 19:43
    
@AlanMunn There are differences in spacing if \frenchspacing is disabled. –  Marc van Dongen Jan 1 '13 at 19:45
4  
As explained by Marc van Dongen, \frenchspacing controls the amount of space added by TeX/LaTeX after a sentence independent from the number of spaces in the source code. However, putting two spaces in the source code can still be useful, as editors like Vi and Vim use them to provide navigation like "move to the end of the current sentence". –  Christian Lindig Jan 1 '13 at 20:04
    
See this answer: tex.stackexchange.com/questions/220131/… –  Andrew Cashner Feb 14 at 20:22

3 Answers 3

up vote 23 down vote accepted
\documentclass[12pt]{article}
\usepackage{libertine}
\begin{document}
\noindent
Firstword\space             Secondword\\    
Firstword\space\space       Secondword\\
Firstword\space\space\space Secondword

% the space between words is \fontdimen2\font

\def\HS{\hspace{\fontdimen2\font}}\the\fontdimen2\font

\noindent
Firstword\HS       Secondword\\    
Firstword\HS\HS    Secondword\\
Firstword\HS\HS\HS Secondword

\fontdimen2\font = 5\fontdimen2\font\the\fontdimen2\font

\noindent
Firstword\HS       Secondword\\    
Firstword\HS\HS    Secondword\\
Firstword\HS\HS\HS Secondword
\end{document}

enter image description here

share|improve this answer
    
thanks for sharing. –  Nicholas Hamilton Jan 2 '13 at 1:33

You don't want to typeset two consecutive spaces, in general. If your aim is to have larger space after periods, it's already built in TeX:

Some words. Other words.

\frenchspacing

Some words. Other words.

will produce

enter image description here

Note that \frenchspacing is not the default, so we have larger space after the period in the first line.

According to TeX's rules, a normal space is inserted, with an additional space with a value set for the font, because the \sfcode for the period is 3000 (greater than 2000); in the Computer Modern font the extra space is one third of the normal interword space.

If you really want a double space after a period, you have to change the font parameter, which is not an easy task because it should be done for every font in the document.

Here's how one could do, but please, don't.

\documentclass{article}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\selectfont}
  {\pickup@font\font@name}
  {\pickup@font\font@name\fontdimen7\font=\fontdimen2\font}
  {}{}
\makeatother

\begin{document}

Some words. Other words.

\frenchspacing

Some words. Other words.

\end{document}

enter image description here

If you instead want to occasionally have a double space (also Knuth uses them somewhere in the TeXbook), use <space>\<space>:

[...] followed by the recent contributions beginning with the
page break. \ (Deep breath.) \ You got that?

enter image description here

share|improve this answer

{} gives you an empty word, so you could put one in between each space:

two {} spaces
three {} {} spaces

Or, if they must be nonbreaking, use ~ for a non-breaking space

two~~spaces
three~~~spaces
share|improve this answer
    
You could also use a { }b to the same effect. I think you would be interested in reading the TeXbook or TeX by Topic – they both go over why this works. It's a subject matter called grouping. –  Sean Allred Feb 14 at 18:11
2  
Two \ spaces is easier, isn't it? –  egreg Feb 14 at 18:12

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.