# How to shorten/shrink spaces between words?

My objective is to fit more words within one line.

In order to show what I mean, I will exaggerate the word spacing here:

Pretend this is a normal line in the document:

Lorem   ipsum   dolor   sit   amet,   consectetuer   adipiscing   elit.


Since I want to fit more words in the same line, I would like to change the word spacing to look like:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Add more words.


What command will allow me to shrink the word spacing in the entire line?

-
Why do you write “line/sentence”? Those usually don't coincide. –  Caramdir Jul 23 '11 at 17:46

There are a number of factors involved in font spacing, including inter word spacing, inter character spacing, inter word stretch, etc. Stefan Kottwitz' blog on Full justification with typewriter font covers all these in an example based on the Computer Modern Typewriter font (\ttfamily, \texttt, etc.).

More specifically, the following dimensions may be set for a font:

• Slant: \fontdimen1
• Inter word space: \fontdimen2
• Inter word stretch: \fontdimen3
• Inter word shrink: \fontdimen4
• Extra space: \fontdimen7
• xspace skip: \xspaceskip
• Hyphenation character: \hyphenchar

In order to decrease the space between words, you can either change the inter word space/stretch. here are some examples that show the difference:

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\newdimen\origiwspc%
\newdimen\origiwstr%
\origiwspc=\fontdimen2\font% original inter word space
\origiwstr=\fontdimen2\font% original inter word stretch
\lipsum[1]% normal text
\fontdimen2\font=0.2ex% inter word space
\lipsum[1]% decreased inter word space
\fontdimen2\font=\origiwspc% (original) inter word space
\fontdimen3\font=0.1em% inter word stretch
\lipsum[1]% decreased inter word stretch
\fontdimen3\font=\origiwstr% (original) inter word stretch
\fontdimen2\font=1em% inter word space
\lipsum[1]% increased inter word space and stretch
\fontdimen2\font=\origiwspc% (original) inter word space
\fontdimen3\font=\origiwstr% (original) inter word stretch
\lipsum[1]% original/normal text
\end{document}


This is what it looks like:

-
Nice answer, also learned about the other functions that may come in handy in the future. How do I change back to default values if I don't need to word space/shrink anymore? –  Level1Coder Jul 23 '11 at 18:33
@Level1Coder: I've updated my answer to reflect how you can store the original/default values. Scoping via {...} doesn't work here. So, it works best to set it the beginning and reset after using it. –  Werner Jul 23 '11 at 18:56

With pdfTeX, I would use the microtype package. Besides providing an interface to pdfTeX’s micro-typographic extensions, it can also be used to modify interword spacing and additional kerning and also letterspacing.

Interword spacing can be customized by \SetExtraSpacing, described in the section 5.5 Interword spacing in the microtype manual.

microtype can improve the justification and may also save space for you. Have a look at this example, where just loading that package removes bad boxes and improves the appearance: Full Justification: pdfLaTeX vs. LaTeX.

-

here an example where the interword space is really small with 1pt

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
%current value: \the\fontdimen2\font
\blindtext

\fontdimen2\font=1pt
\blindtext

\end{document}


-
What is the default pt value for \fontdimen2\font=?pt –  Level1Coder Jul 23 '11 at 18:25
you can output into your tex file with \the\fontdimen2\font. It is for my system 3.33333pt. But there are are two more values for plus and minus (stretching and shrinking) –  Herbert Jul 23 '11 at 18:38

If you are interested in stretching or shrinking the spaces between letters (not words), microtype's \textls macro does wonders:

\documentclass{memoir}
\usepackage{microtype}

\newcommand{\dummytext}{Some words that demonstrate the effect of typographic tracking. Some words that demonstrate the effect of typographic tracking. Some words that demonstrate the effect of typographic tracking. Some words that demonstrate the effect of typographic tracking. Some words that demonstrate the effect of typographic tracking. Some words that demonstrate the effect of typographic tracking. Some words that demonstrate the effect of typographic tracking. Some words that demonstrate the effect of typographic tracking. Some words that demonstrate the effect of typographic tracking. Some words that demonstrate the effect of typographic tracking. Some words that demonstrate the effect of typographic tracking.}

\begin{document}

\dummytext{} \textbf{Start of tracking.} \textls[-60]{\dummytext} \textbf{End of tracking.} \dummytext

\end{document}

-