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

Gary L. Gray glgray at me.com
Sun May 6 19:38:52 EDT 2012


On May 6, 2012, at 6:52 PM, Ross Moore wrote:

> 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,

That does look interesting. Note that enumitem does have an option that makes it backward compatible with the feature of enumerate that we use. That is, one can load enumitem with the shortlabels option as:

\usepackage[shortlabels]{enumitem}

Does this change your suggestion?

-- 
All the best,
Gary





More information about the MacOSX-TeX mailing list