5

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

Example:

enter image description here

UPDATE 1:

@egreg:

When I try:

\begin{enumerate}[label=\arabic*.,before*=\tighten,noitemsep]
\item List 1
\begin{enumerate}[label=\Alph*.,before*=\tighten,noitemsep]
\item Item Aabcg
\item Item Bagcb
\item Item Cabcg
\item Item Dagcb
\end{enumerate}
\end{enumerate}

there is a tall space between List 1 and Item Aabcg

Can you further modify your answer to fix this?

UPDATE 2:

@egreg:

Thanks but I still get:

1. List 1

     A. Item Aabcg
     B. Item Bagcb
     C. Item Cabcg
     D. Item Dagcb

Can you get rid of that space between List 1 and Item Aabcg to get:

1. List 1
     A. Item Aabcg
     B. Item Bagcb
     C. Item Cabcg
     D. Item Dagcb
Level1Coder
  • 7,029

3 Answers3

9

You can use the enumitem package in order to tweak the item spacing in lists (either enumerate or itemize). The following example highlights some of the spacing needs you are looking for:

\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=\arabic*.]
  \item List 1
  \begin{enumerate}[label=\Alph*.,itemsep=-1ex,topsep=-2ex]
    \item Item A
    \item Item B
    \item Item C
    \item Item D
  \end{enumerate}
\end{enumerate}

\begin{enumerate}[label=\arabic*.,resume]
  \item List 2
  \begin{enumerate}[label=\Alph*.]
    \item Item A
    \item Item B
    \item Item C
    \item Item D
  \end{enumerate}
\end{enumerate}

\end{document}

...which looks like this:

List spacing

Read the enumitem package documentation to see all the different settings that can be used.

Werner
  • 603,163
3

If you want the text lines touch each other, use this:

\documentclass{article}
\usepackage{enumitem}
\setenumerate{nolistsep} % kills all vertical spacing
\begin{document}

\begingroup
\offinterlineskip % It's ugly, don't use it unless necessary
\begin{enumerate}
  \item List 1
  \begin{enumerate}[label=\Alph*.]
    \item Item A
    \item Item B
    \item Item C
    \item Item D
  \end{enumerate}
\end{enumerate}
\endgroup

\end{document}

enter image description here

It that is not what you want, you may want to delete \offinterlineskip as well as \begingroup and \endgroup.

You can increase \lineskip parameter after \offinterlineskip to set the space between line boxes. e.g.

\offinterlineskip
\setlength{\lineskip}{1pt}

For more information, see my answer in your previous question.

Leo Liu
  • 77,365
  • Yes, this is what I'm looking for. I want to start out with characters overlapping each other, then expand the vertical spacing to my liking. What parameter value should I tweak to increase the vertical spacing now that they are vertically squished? – Level1Coder Jul 24 '11 at 05:07
  • Great, so just like my previous question, I'll just add \lineskip=1pt after \offinterlineskip and modify the value to my preferences. Thanks! – Level1Coder Jul 24 '11 at 05:58
3

Based on the answer to this other question, here is a solution that preserves even distance between baselines.

\makeatletter
\let\tightset@fontsize\set@fontsize
\patchcmd\tightset@fontsize{#3}{#2}{}{}
\newcommand{\tighten}{\let\set@fontsize\tightset@fontsize
  \fontsize{\f@size}{\f@baselineskip}\selectfont}
\makeatother

Then the list can be input as

\begin{enumerate}[parsep=0pt]
\item List 1
  \begin{enumerate}[label=\Alph*.,before*=\tighten,noitemsep,topsep=0pt]
  \item Item Aabcg
  \item Item Bagcb
  \item Item Cabcg
  \item Item Dagcb
  \end{enumerate}
\end{enumerate}

Minimal example:

\documentclass[a4paper]{article}
\usepackage{etoolbox,enumitem}

\makeatletter
\let\tightset@fontsize\set@fontsize
\patchcmd\tightset@fontsize{#3}{#2}{}{}
\newcommand{\tighten}{\let\set@fontsize\tightset@fontsize
  \fontsize{\f@size}{\f@baselineskip}\selectfont}
\makeatother

\begin{document}
\begin{enumerate}[parsep=0pt]
  \item List 1
  \begin{enumerate}[label=\Alph*.,before*=\tighten,nolistsep,topsep=0pt]
    \item Item A
    \item Item B
    \item Item C
    \item Item D
  \end{enumerate}
\end{enumerate}

\end{document}

Checking the output with \showbox proves that the spacing is the same: between the "List 1" line and the "Item A" line, TeX inserts 3.16669pt glue, exactly the same as the glue inserted between the "Item A" and the "Item B" lines (and the others as well), which is right, since those lines have no descenders. The height of the "Item A" line is 6.83331pt, which added to 3.16669pt gives 10pt.

There might be a slight difference in a real document if \topsep in the inner list is not set to zero (the nolistsep key sets it to 0pt plus 0.1pt), but not with the article class which does \raggedbottom.

egreg
  • 1,121,712