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.

How can I fine tune and reduce the vertical spacing of lines so characters from lines above and below are almost pixel-touching each other?

Example:

Example of lines barely touching each other

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

While \offinterlineskip\lineskip1pt might seem to give the desired result, lines will be irregularly spaced, because the distance between base lines will depend on the presence of ascenders (letters like "d") or descenders (letters like "y"). Moreover not all descenders and ascenders are equal.

Tight typesetting can be obtained by calling, say, \fontsize{10}{10} for ten point size. One can get cheaply such a setting by modifying the internal function \set@fontsize:

\documentclass[a4paper]{article}
\usepackage{etoolbox,lipsum}
\makeatletter
\patchcmd\set@fontsize{#3}{#2}{}{}
\makeatother

\begin{document}
\lipsum[1]
\large\lipsum[2]
\end{document}

Only etoolbox is required, of course. The patch will substitute the call of the third argument to \set@fontsize with the second; the third parameter is indeed the baselineskip and the second is the font size.

Note that this will affect all text at all sizes.

enter image description here

If only some paragraphs are to be "tightly typeset", then the environment tight defined as follows will do the job. The \addvspace commands have been used on the assumption that the code is used for examples. Variations on the theme are possible.

\makeatletter
\let\tightset@fontsize\set@fontsize
\patchcmd\tightset@fontsize{#3}{#2}{}{}
\newenvironment{tight}
  {\par\addvspace\topsep
   \let\set@fontsize\tightset@fontsize
   \fontsize{\f@size}{\f@baselineskip}\selectfont}
  {\par\addvspace\topsep}
\makeatother

If tight typesetting is needed for captions, it's simpler. With the caption package define the font used by saying something like

\DeclareCaptionFont{tight}{\fontsize{9}{9}\selectfont}
\captionsetup{font=tight,labelfont=bf}
share|improve this answer
    
Indeed, the other answers have the result of irregular spacing when rendered. I thought this cannot be fixed but your answer renders beautifully. Is it possible to use \set@fontsize to control and design vertical spacing for lists like my question here? Or is the current selected answer the best way to control vertical height for lists? –  Level1Coder Jul 24 '11 at 16:12
add comment

\offinterlineskip is what you want.

\documentclass{article}
\usepackage{lipsum}

\begin{document}
\lipsum[1]
{% Use it LOCALLY
  \offinterlineskip
  \lipsum[2]
}
\lipsum[3]
\end{document}

You can add \lineskip=1pt after \offinterlineskip, if the lines are too close.


There're mainly three parameters about line spacing: \baselineskip, \lineskip and \lineskiplimit.

A good explanation of parameters about line spacing, is Chapter 12 (Glue) in TeXbook. Or you can see Chapter 15 (Baseline Distances) in TeX by Topic, it said:

  • \baselineskip: The ‘ideal’ baseline distance between neighbouring boxes on a vertical list. Plain TeX default: 12pt.
  • \lineskiplimit: Distance to be maintained between the bottom and top of neighbouring boxes on a vertical list. Plain TeX default: 0pt.
  • \lineskip: Glue added if the distance between bottom and top of neighbouring boxes is less than \lineskiplimit. Plain TeX default: 1pt.

In LaTeX, we usually only change \baselineskip through \fontsize and \linespread, \lineskiplimit and \lineskip are not often used.

If you want to pry, in LaTeX kernel, \offinterlineskip is defined as:

\def\offinterlineskip{\baselineskip-\@m\p@
  \lineskip\z@ \lineskiplimit\maxdimen}
share|improve this answer
    
How do I expand the vertical space a bit if I think it's too squished? What parameter value should I tweak? –  Level1Coder Jul 24 '11 at 5:06
    
@Level1Coder: In that case, Werner's solution is OK. I suggest \linespread{0} instead of \linespread{0.5}. I'll add some more information minutes later. –  Leo Liu Jul 24 '11 at 5:14
    
@Level1Coder: See my update. –  Leo Liu Jul 24 '11 at 5:31
    
I'm new to LaTeX and I really would like to understand every part of example code given here. What does the code within {% Use it LOCALLY do? Why is it necessary to have those specific commands in curly brackets? –  Level1Coder Jul 24 '11 at 5:48
    
Both answers work, in general cases Werner's answer works fine. But in my usage, I really like how there is finer grain control in your method. Modifying your line \lineskip=0.2pt in 0.1 increments I can see changes in the final PDF render. Whereas with Werner's \linespread{0.5}\selectfont, I only see changes in 0.5 increments. So in my case, yours is the best answer. –  Level1Coder Jul 24 '11 at 5:54
add comment

For stretching (or increasing) the line spacing, you can use the setspace package, or use \linespread{<factor>}. Using the latter, the following minimal example showcases some of the effects of changing the \linespread:

\documentclass{minimal}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\linespread{0.5}\selectfont
\lipsum[1]
\linespread{2}\selectfont
\lipsum[1]
\end{document}

The output looks like this:

Different line spreads

Here is also a short discussion on this topic on the UK TeX FAQ.

share|improve this answer
    
Do not use \linespread{0.5}\selectfont. It has no meaning. And for this question, it is not correct for many cases. The right way is to set \baselineskip less than \lineskiplimit, and set \lineskip to 0pt, that's what \offinterlineskip do. –  Leo Liu Jul 24 '11 at 4:56
    
@Leo: Without more context and the minimal requirement specified by the OP, there are many other ways of fulfilling the request, I'm sure. –  Werner Jul 24 '11 at 5:00
    
In LaTeX, \lineskip is 1pt by default. Set small \baselineskip will not suffie the request, if the OP really want no space between lines. After all, the default 1pt value of \lineskip makes the texts more readable. –  Leo Liu Jul 24 '11 at 5:10
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.