Extreme vertical spacing between list items & nested lists

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:

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

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

-
–  Stefan Kottwitz Jul 24 '11 at 10:04

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.

-
Please check the UPDATE section of this original post. –  Level1Coder Jul 24 '11 at 17:55
The parameter to modify is \parsep in the outer list; however a "real life" example is needed to be sure. –  egreg Jul 24 '11 at 17:55
tried [parsep=0pt] but the space between 1. List 1 and A. Item Aabcg is greater than the space between each item within the inner list. –  Level1Coder Jul 24 '11 at 18:01
On my computer the spaces appear the same. –  egreg Jul 24 '11 at 18:08
Please check the UPDATE 2 section of this original post. –  Level1Coder Jul 24 '11 at 18:10

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:

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

-

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}


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}


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 5:58