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.

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?

share|improve this question
    
Why do you write “line/sentence”? Those usually don't coincide. –  Caramdir Jul 23 '11 at 17:46
add comment

4 Answers 4

up vote 13 down vote accepted

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:

Different inter word/stretch spacing

share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

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} 

enter image description here

share|improve this answer
    
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
add comment

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}
share|improve this answer
add comment

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.