[Tex/LaTex] Extreme vertical spacing between lines

line-spacing

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

Best Answer

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}