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 am trying to condense a two-level enumeration of some kind of requirements in a figure, with the text referencing the items of the enumeration. I am using a table to separate the two columns (tried \twocolumn and \onecolumn but this didn't have the desired effect) and generate the figure border.

Here is an example of what I managed to do:

examples

Figure 1.2 is essentially what I want, except that references to the items in the list do not work: a \ref refering to e.g. item 1e displays as "5", i.e. only the nested list is shown, and it is shown using arabic numerals instead of letters.

Figure 1.2 was created using the bare list environment, i.e. like this:

\begin{figure}
\newcounter{ctr:templatelang-req}
\newcounter{ctr:templatelang-req:sub}[ctr:templatelang-req]
\begin{tabular}{|p{0.48\textwidth}p{0.45\textwidth}|}
\hline
\begin{list}{\arabic{ctr:templatelang-req}.}{\usecounter{ctr:templatelang-req}\leftmargin=1.4em}
  \item SDF
    \begin{list}{\alph{ctr:templatelang-req:sub}.}{\usecounter{ctr:templatelang-req:sub}\leftmargin=1.4em}
      \item \label{templatelang-req:target-sort}Target sort
      \item \label{templatelang-req:cons-attr}Constructor attribute
      \item \label{templatelang-req:other-attrs}Other attributes
      \item \label{templatelang-req:sort-refs}References to other sorts
      \item \label{templatelang-req:literals-1}Literal text (excl. layout)
      \item \label{templatelang-req:option-op}Option operator \texttt{A?}
      \item \label{templatelang-req:repetition-op}Repetition operators \texttt{A*} and \texttt{A+}
      \item \label{templatelang-req:list-op}List operators \texttt{\{A S\}*} and \texttt{\{A S\}+}
    \end{list}
  \end{list} &
\begin{list}{\arabic{ctr:templatelang-req}.}{\usecounter{ctr:templatelang-req}\leftmargin=1.4em}
  \setcounter{ctr:templatelang-req}{1}
  \item Pretty printer
    \begin{list}{\alph{ctr:templatelang-req:sub}.}{\usecounter{ctr:templatelang-req:sub}\leftmargin=1.4em}
      \item \label{templatelang-req:literals-2}Literal text (incl. layout)
      \item \label{templatelang-req:wordwrap}Optional: word wrap
      \item \label{templatelang-req:alignment}Optional: alignment
      \item \label{templatelang-req:tabstops}Optional: tab stops
    \end{list}\vspace{1ex}
  \item Completion templates
    \begin{list}{\alph{ctr:templatelang-req:sub}.}{\usecounter{ctr:templatelang-req:sub}\leftmargin=1.4em}
      \item \label{templatelang-req:literals-3}Literal text (incl. layout)
      \item \label{templatelang-req:placeholder-text}Placeholder text
    \end{list}
\end{list} \\
\hline
\end{tabular}
\caption{Required information to encode in our syntax templates}
\label{fig:templatelang:requirements}
\end{figure}

Figure 1.3 is the result of using the enumerate environment. The only "hack" here is the use of \setcounter{enumi}{1} to start the outer enumeration in the second column at the proper number. With figure 1.3, \ref works fine: it includes both levels and uses the correct type of numbers. I.e., a reference to item 1e is displayed as 1e.

Code for figure 1.3:

\begin{figure}
\begin{tabular}{|p{0.48\textwidth}p{0.45\textwidth}|}
\hline
\begin{enumerate}
  \item SDF
    \begin{enumerate}
      \item \label{templatelang-req:target-sort}Target sort
      \item \label{templatelang-req:cons-attr}Constructor attribute
      \item \label{templatelang-req:other-attrs}Other attributes
      \item \label{templatelang-req:sort-refs}References to other sorts
      \item \label{templatelang-req:literals-1}Literal text (excl. layout)
      \item \label{templatelang-req:option-op}Option operator \texttt{A?}
      \item \label{templatelang-req:repetition-op}Repetition operators \texttt{A*} and \texttt{A+}
      \item \label{templatelang-req:list-op}List operators \texttt{\{A S\}*} and \texttt{\{A S\}+}
    \end{enumerate}
  \end{enumerate} &
\begin{enumerate}
  \setcounter{enumi}{1}
  \item Pretty printer
    \begin{enumerate}
      \item \label{templatelang-req:literals-2}Literal text (incl. layout)
      \item \label{templatelang-req:wordwrap}Optional: word wrap
      \item \label{templatelang-req:alignment}Optional: alignment
      \item \label{templatelang-req:tabstops}Optional: tab stops
    \end{enumerate}\vspace{1ex}
  \item Completion templates
    \begin{enumerate}
      \item \label{templatelang-req:literals-3}Literal text (incl. layout)
      \item \label{templatelang-req:placeholder-text}Placeholder text
    \end{enumerate}
\end{enumerate} \\
\hline
\end{tabular}
\caption{Required information to encode in our syntax templates}
\label{fig:templatelang:requirements}
\end{figure}

So my question is foremost: how do I reduce the indentation of the list items in the enumerate environment, when using the memoir class?

I tried the things suggested here on stackoverflow, which is how I arrived at figure 1.2, but since this breaks \ref it doesn't really help me.

I also tried to insert \setlength{\leftmargin}{0pt} at various places, as is suggested by figure 8.2 on page 149 (the layout parameters of general lists) of the memoir manual, but this didn't help either.

Do I really need to use an extra package just to reduce the indentation of these enumerations, as suggested here?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

The memoir class, by default, adds a bit of horizontal space in front of the labels. In the code below -- which I believe achieves your formatting objectives -- this extra space is suppressed by specifying explicitly the desired forms of the labels ([1.], [a.]) as the argument of each \begin{enumerate} command. In addition, I've allocated a bit more horizontal widths to the left-hand column. The instruction \firmlists* reduces the amount of vertical spacing, and the command \frenchspacing suppresses the extra space after periods.

An additional suggestion: consider placing the tabular stuff in a table rather than in a figure environment: people tend to associate "figures" with graphical information, not tabular information.

\documentclass[a4paper]{memoir}
\frenchspacing

\begin{document}

\begin{figure}
\firmlists*

\begin{tabular}{|p{0.51\textwidth}p{0.45\textwidth}|}
\hline
\begin{enumerate}[1.]
  \item SDF
    \begin{enumerate}[a.]
      \item \label{templatelang-req:target-sort}Target sort
      \item \label{templatelang-req:cons-attr}Constructor attribute
      \item \label{templatelang-req:other-attrs}Other attributes
      \item \label{templatelang-req:sort-refs}References to other sorts
      \item \label{templatelang-req:literals-1}Literal text (excl. layout)
      \item \label{templatelang-req:option-op}Option operator \texttt{A?}
      \item \label{templatelang-req:repetition-op}Repetition operators 
            \texttt{A*} and \texttt{A+}
      \item \label{templatelang-req:list-op}List operators 
            \texttt{\{A S\}*} and \texttt{\{A S\}+}
    \end{enumerate}
  \end{enumerate} &
\begin{enumerate}
  \setcounter{enumi}{1}
  \item Pretty printer
    \begin{enumerate}[a.]
      \item \label{templatelang-req:literals-2}Literal text (incl. layout)
      \item \label{templatelang-req:wordwrap}Optional: word wrap
      \item \label{templatelang-req:alignment}Optional: alignment
      \item \label{templatelang-req:tabstops}Optional: tab stops
    \end{enumerate}
  \vspace{1.8ex}
  \item Completion templates
    \begin{enumerate}[a.]
      \item \label{templatelang-req:literals-3}Literal text (incl. layout)
      \item \label{templatelang-req:placeholder-text}Placeholder text
    \end{enumerate}
\end{enumerate} \\
\hline
\end{tabular}
\caption{Required information to encode in our syntax templates}
\label{fig:templatelang:requirements}
\end{figure}

\end{document}
share|improve this answer
    
This works great, thanks! –  Tobi Sep 5 '11 at 13:51
    
As for your suggestion to table for tabular stuff - I used that before, but my daily advisor suggested to use only a single environment for all figures/tables, as two separate numberings and two separate "List Of XXXs" would be confusing... So thanks for the suggestion, but for the moment I stick with figures everywhere ;-) –  Tobi Sep 5 '11 at 13:54
    
That was an odd advise, it is two separate things, one is data the other often images. –  daleif Sep 5 '11 at 13:55

Oh well, the enumitem package works, using code like this:

\usepackage{enumitem}

\begin{enumerate}[leftmargin=1.4em]
  \item ...
\end{enumerate}

I'd still be interested in hearing other answers though!

(LaTeX keeps surprising me that sometimes such seemingly simple things appear to be so hard to find out...)

share|improve this answer
2  
memoir does not provide interfaces for changing the lists, other than the \firmlist and \tightlist features. I recommend using the enumitem package as it can provide much more than memoir would have the space for. –  daleif Sep 5 '11 at 11:48
1  
Also, one cannot mess with \leftmargin within a list because at that point it has already been used. –  daleif Sep 5 '11 at 11:49

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.