[Tex/LaTex] How to shorten/shrink spaces between words

spacing

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?

Best Answer

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[margin=1in]{geometry}
\usepackage{lipsum}
\begin{document}
  \newdimen\origiwspc%
  \newdimen\origiwstr%
  \origiwspc=\fontdimen2\font% original inter word space
  \origiwstr=\fontdimen3\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:

enter image description here

Related Question