[OS X TeX] Re: Eliminate extra vertical space in enumerate? (Gary L. Gray)

Ross Moore ross.moore at mq.edu.au
Sun May 6 18:52:47 EDT 2012


Hi José and Gary,

On 07/05/2012, at 6:45 AM, Juan José Torrens wrote:

> Hi Gary,
> 
> I would change your code as follows:
> 
> \documentclass{article}
> \usepackage{enumitem}
> \begin{document}
> 
> \noindent
> \framebox[\textwidth]{%
> \parbox{\dimexpr\textwidth-2\fboxrule-2\fboxsep}{%
> \begin{enumerate}[topsep=0pt]
> \item
> First item.
> \item
> Second item.
> \item
> Third item.
> \end{enumerate}%
> }}
> 
> \noindent
> \framebox[\textwidth]{%
> \parbox{\dimexpr\textwidth-2\fboxrule-2\fboxsep}{%
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
> Proin sollicitudin arcu quis leo molestie ut porttitor 
> nibh ullamcorper. Duis quis urna nec mauris aliquet 
> convallis.}}
> 
> \end{document}
> 
> The enumitem package is quite useful to customize list environments. Please note also that the boxes were too wide, so there were some warnings about that.

Thanks for that tip about {enumitem},
and it allowing extra options too enumerate environments.

However, it clashes with  \usepackage{enumerate}  which also
provides an optional argument.
You certainly cannot use the two together. 
Besides, having to edit all your enumerate environments to add the
extra option is a hassle, assuming Gary is reusing a lot of stuff
already coded.

So here's a way to get the same effect of setting the  \topsep
parameter, automatically whenever there is an {enumerate} instead
of a text paragraph.


%%% Preamble stuff %%%%
\makeatletter
\def\my at listi{%
 \leftmargin \leftmargini 
 \parsep 4\p@ \@plus 2\p@ \@minus \p@ 
 \topsep 0\p@ \@plus 2\p@ \@minus 4\p@  % was 8\p@
 \itemsep 4\p@ \@plus 2\p@ \@minus \p@
}
% implement this for 1st-level lists only
\def\usemylisti{\expandafter\let\csname @list\romannumeral 1 \endcsname\my at listi}
\makeatother


%%% Usage:  %%%%
\framebox{%
\parbox{\textwidth}{\usemylisti
\begin{enumerate}
\item
First item.
\item
Second item.
\item
Third item.
\end{enumerate}%
}}


\framebox{%
\parbox{\textwidth}{\usemylisti
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sollicitudin arcu quis leo molestie ut porttitor nibh ullamcorper. Duis quis urna nec mauris aliquet convallis.}}



So Gary can define a macro or environment for:

   \framebox{\parbox{\textwidth}{\usemylisti #1}}

and use it with both kinds of material.

*except*
  if the {enumerate} is nested within other list environments.

In that case he needs to identify which levels of nesting are being
used, and provide local redefinitions for:

  \csname @list\romannumeral 2 \endcsname
  \csname @list\romannumeral 3 \endcsname
  \csname @list\romannumeral 4 \endcsname
etc.

as appropriate.


> Regards
> 
> Juanjo


Hope this helps,

	Ross

------------------------------------------------------------------------
Ross Moore                                       ross.moore at mq.edu.au 
Mathematics Department                           office: E7A-419      
Macquarie University                             tel: +61 (0)2 9850 8955
Sydney, Australia  2109                          fax: +61 (0)2 9850 8114
------------------------------------------------------------------------






More information about the MacOSX-TeX mailing list