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.

I want to adjust the length parameters in a list (happens to be to make it more condensed, but that's not relevant). I do this infrequently enough that I don't remember all the lengths that are involved and have to look them up every time. But the references I usually find (via some search engine or other) tend to be purely descriptive. Being a very visual learner, I would find it much easier to remember if I had a diagram to look at (something like what is produced by the layout package).

Does such a diagram exist showing how the lengths fit together in a list?

Note that even if I were using a package such as enumitem to do the actual adjusting, I'd still have to have a reasonable idea of which lengths were involved.

(If the answer to this is "no" and someone draws one, or the answer is "yes, but here's a better one", then I'll happily add a bounty to this question when I'm allowed and award it to the nicest diagram.)

share|improve this question
    
Such diagrams are indeed very useful. For this reason I created one for tikztimingtable of my tikz-timing package. –  Martin Scharrer May 11 '11 at 10:09
    
I promised a bounty if anyone drew a picture so I've put it on. I think that both of the drawn pictures (ie not the layouts one) are very good pictures, but Leo's already gotten 220 rep from this question! –  Loop Space May 20 '11 at 18:01
    
(Just re-read that comment. I should clarify that I also think that the layouts-generated picture is good, but wouldn't qualify for the bonus by my rules in the question.) –  Loop Space Jun 1 '11 at 10:46

3 Answers 3

up vote 33 down vote accepted

You need layouts package.

\documentclass{article}
\usepackage{layouts}

\begin{document}
\drawlist

\begin{enumerate}
\item foo
\currentlist
\begin{figure}
\listdesign
\end{figure}
\end{enumerate}
\end{document}

enter image description here

enter image description here

share|improve this answer
3  
Yet another useful package that I was completely unaware of! That's fantastic, thanks. –  Loop Space May 11 '11 at 10:04
3  
Having a layout and layouts package is a little confusing. –  Martin Scharrer May 11 '11 at 10:07
    
And by seeing them all so nicely laid out, I've almost instantly fixed my problem! (I couldn't get the list flush with the left margin, even with setting \leftmargin to 0pt just before the list. Seeing the diagram made it clear that something must be resetting the value of \leftmargin as that is the only length involved. Sure enough, the document class defines a \leftmargini and sets \leftmargin to it.) –  Loop Space May 11 '11 at 10:08
    
@Martin: "What's in a name? That which we call the layouts package, by any other name would be as useful." –  Loop Space May 11 '11 at 10:09
    
@Martin: Indeed. I knew layout long time ago, but I met with layouts just when I tried to search document of layout several months ago. –  Leo Liu May 11 '11 at 10:11

The picture in Guide to TeX section 4.4.2, using TikZ:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains}
\usepackage{makecell}

\begin{document}
  \begin{tikzpicture}[start chain=going below,node distance=8mm,
  main/.style={minimum width=10cm},
  para/.style={minimum width=5cm,minimum height=1.5cm}]
  \scope[very thick]
  \node[on chain,main,anchor=south west] (prec) {Text};
  \draw (prec.north west) -- (prec.south west) -| (prec.north east);

  \node[on chain,para] (item1-1) {\hspace{4em}\makecell[l]{Item 1\\Para 1}};
  \coordinate (p1-1) at (item1-1.150 |- item1-1.175);
  \draw (p1-1) |- (item1-1.north east) |- (item1-1.south west)
               -- (p1-1 -| item1-1.south west) -- cycle;

  \node[on chain,para] (item1-2) {\hspace{4em}\makecell[l]{Item 1\\Para 2}};
  \coordinate (p1-2) at (item1-2.130 |- item1-2.175);
  \draw (p1-2) |- (item1-2.north east) |- (item1-2.south west)
               -- (p1-2 -| item1-2.south west) -- cycle;

  \node[on chain,para] (item2) {\hspace{4em}Item 2};
  \coordinate (p2) at (item2.150 |- item2.175);
  \draw (p2) |- (item2.north east) |- (item2.south west)
             -- (p2 -| item2.south west) -- cycle;

  \node[on chain,main] (follow) {Text};
  \draw (follow.south west) -- (follow.north west) -| (follow.south east);

  \node[left=0.5cm of item1-1.north west,anchor=north east,draw]
    (label1) {Label};
  \node[left=0.5cm of item2.north west,anchor=north east,draw]
    {Label};
  \endscope

  \scope[>=latex,<->,shorten <=1pt,shorten >=1pt,font={\ttfamily\small},auto,
    every node/.style={midway}]
  \draw (prec) -- (item1-1)
    node{\string\topsep\ + \string\parskip\ [+ \string\partopsep]};
  \draw (item1-1) -- (item1-2)
    node{\string\parsep};
  \draw (item1-2) -- (item2)
    node{\string\itemsep\ + \string\parsep};
  \draw (item2) -- (follow)
    node{\string\topsep\ + \string\parskip\ [+ \string\partopsep]};
  \draw[<->|] (item1-1) -- (item1-1 -| prec.south west)
    node {\string\leftmargin};
  \draw[<->|,swap] (item1-1) -- (item1-1 -| prec.south east)
    node {\string\rightmargin};
  \draw (label1) -- (label1 -| p1-1)
    node{\string\labelsep};
  \draw[|<->|,transform canvas={yshift=2mm}]
    (label1.north west) -- (label1.north east)
    node{\string\labelwidth};
  \draw[|<->,transform canvas={yshift=-2mm}]
    (p1-1) -- (p1-1 -| item1-1.north west)
    node[near end,anchor=north west]{\string\itemindent};
  \draw[<->|,transform canvas={yshift=5mm},swap]
    (p1-2) -- (p1-2 -| item1-2.north west)
    node{\string\listparindent};
  \endscope
  \end{tikzpicture}

\end{document}

It looks better than the one produced by layouts. I used this in a book (in Chinese) of mine.

enter image description here

share|improve this answer
    
How many answers are you going to give? –  Loop Space May 11 '11 at 18:30
    
Well, this is a very different answer. And I just have this code in hand. No more answers anyway :) –  Leo Liu May 11 '11 at 23:43

I made one with TikZ for my LaTeX cheat sheet (in french), but only for {itemize} (so it does not show \labelwidth). It uses real text instead of boxes to show things:

diagram showing the lengths of an itemize

Here's the (not elegant at all) source code of the diagram:

\documentclass[a4paper]{article}

\usepackage[garamond]{mathdesign}

\usepackage{calc}
\usepackage{colortbl}

\usepackage{tikz}
\usetikzlibrary{positioning,calc}

\begin{document}

\begin{center}\tabcolsep=0.5em
\begin{tabular}{ll}\cellcolor{orange!7}
\begin{minipage}[b]{8.1cm}
\newcommand{\chosenlistbullet}{\textbullet}
\newcommand{\showlistlength}[1]{\texttt{\scriptsize#1}}
\newcommand{\showlistlengthprecision}[1]{\textnormal{\scriptsize(#1)}}
\begin{tikzpicture}[inner sep=0pt]

\node (text before) {\begin{minipage}[t]{\linewidth}
Bla bla bla bla bla bla bla bla bla bla bla bla bla bla 
bla bla bla bla bla bla bla bla bla bla.
\end{minipage}};

\node (first item par1) [below=10mm of text before] {\hspace*{1.5cm}\begin{minipage}[t]{\linewidth-3cm}\leavevmode
\llap{\chosenlistbullet\hspace{0.33cm}}%
\hspace*{0.33cm}\llap{\smash{\tikz[baseline] \draw[<->,color=violet] (0,0) -- (0.66cm,0) node[pos=0.5,below left,inner sep=3pt] {\showlistlength{labelsep}};}}\llap{\smash{\tikz[baseline=-1ex] \draw[<->,color=green!40!black] (0,0) -- (0.33cm,0) node[above left,inner sep=3pt] {\showlistlength{itemindent}};}}Bla bla bla bla bla bla bla bla bla 
bla bla bla bla bla bla bla.
\end{minipage}\hspace*{1.5cm}};

\node (first item par2) [below=5mm of first item par1] {\hspace*{1.5cm}\begin{minipage}[t]{\linewidth-3cm}\leavevmode
\hspace{0.5cm}\llap{\smash{\tikz[baseline] \draw[<->,color=green!40!black] (0,0) -- (0.5cm,0) node[above left,inner sep=3pt] {\showlistlength{listparindent}};}}Bla bla bla bla bla bla bla bla bla 
bla bla bla bla bla bla. 
\end{minipage}\hspace*{1.5cm}};

\node (second item) [below=5mm of first item par2] {\hspace*{1.5cm}\begin{minipage}[t]{\linewidth-3cm}\leavevmode
\llap{\chosenlistbullet\hspace{0.33cm}}%
\hspace*{0.33cm}\llap{\smash{\tikz[baseline] \draw[<->,color=violet] (0,0) -- (0.66cm,0) node[pos=0.5,below left,inner sep=3pt] {\showlistlength{labelsep}};}}\llap{\smash{\tikz[baseline=-1ex] \draw[<->,color=green!40!black] (0,0) -- (0.33cm,0) node[above left,inner sep=3pt] {\showlistlength{itemindent}};}}Bla bla bla bla bla bla bla bla bla 
bla bla bla bla bla bla bla.
\end{minipage}\hspace*{1.5cm}};

\node (text after) [below=10mm of second item] {\begin{minipage}[t]{\linewidth}
Bla bla bla bla bla bla bla bla bla bla bla bla bla bla 
bla bla bla bla bla bla bla bla bla bla bla bla bla.
\end{minipage}};

\draw[<->,color=blue] (text before.south) -- ($ (text before.south)!.5!(first item par1.north) $) node[pos=0.5,right,inner sep=3pt] {\showlistlength{partopsep} \showlistlengthprecision{if blank line before the list}};

\draw[<->,color=blue] ($ (text before.south)!.5!(first item par1.north) $) -- (first item par1.north) node[pos=0.5,right,inner sep=3pt] {\showlistlength{topsep\,+\,parskip}};

\draw[<->,color=blue] (first item par1.south) -- (first item par2.north) node[pos=0.5,right,inner sep=3pt] {\showlistlength{parsep}};

\draw[<->,color=blue] (first item par2.south) -- (second item.north) node[pos=0.5,right,inner sep=3pt] {\showlistlength{itemsep\,+\,parsep}};

\draw[<->,color=blue] (second item.south) -- ($ (second item.south)!.5!(text after.north) $) node[pos=0.5,right,inner sep=3pt] {\showlistlength{topsep\,+\,parskip}};

\draw[<->,color=blue] ($ (second item.south)!.5!(text after.north) $) -- (text after.north) node[pos=0.5,right,inner sep=3pt] {\showlistlength{partopsep} \showlistlengthprecision{if blank line before the list}};

\draw[<->,color=violet] (first item par2.west) -- ($ (first item par2.west) + (1.5cm,0cm) $) node[pos=0.5,below,inner sep=3pt] {\showlistlength{leftmargin}};

\draw[<->,color=violet] (first item par2.east) -- ($ (first item par2.east) + (-1.5cm,0cm) $) node[pos=0.5,below,inner sep=3pt] {\showlistlength{rightmargin}};

\end{tikzpicture}
\end{minipage}
&
\newcommand{\showlistlength}[2][blue]{\textcolor{#1}{\texttt{#2}}:}
\begin{tikzpicture}
\node {\begin{minipage}{6cm}\parskip=2pt
\showlistlength{topsep} space before and after \par
\showlistlength{partopsep} additional space before and after if the list is preceded by a blank line \par
\showlistlength{itemsep} space between items \par
\showlistlength{parsep} space between paragraphs of an item \par
\showlistlength[violet]{leftmargin} left margin \par
\showlistlength[violet]{rightmargin} right margin \par
\showlistlength[violet]{labelsep} space between label and text \par
\showlistlength[green!40!black]{itemindent} indentation of the first paragraphs of an item \par
\showlistlength[green!40!black]{listparindent} indentation of the other paragraphs of an item\par
\end{minipage}};
\end{tikzpicture}
\\
\end{tabular}\end{center}

\end{document}
share|improve this answer
    
Very nice. I'd be interested in seeing the source of that document ... –  Loop Space May 11 '11 at 10:57
    
@Andrew: what would you like to see exactly? (The document itself has too many hacks to be really useful.) –  Philippe Goutet May 11 '11 at 22:36
    
(I thought I'd replied .. must have been in my imagination). I wanted to see the source because I was tempted to translate it. –  Loop Space May 20 '11 at 17:57
    
@Andrew: sorry for the late reply. I have wanted to translate it for some while to put it on CTAN, but never found the time to do it, so if you're still interested in translating the document, drop me an e-mail, and I'll send it to you (my e-mail is available on the website where the document is). –  Philippe Goutet Jun 1 '11 at 9:02

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.