2

I wanted to reduce the space between the items in all the enumerations in a document, so I renewed the environment using

\let\oldenum\enumerate
\let\oldendenum\endenumerate
\renewenvironment{enumerate}{\oldenum\setlength{\parskip}{\smallskipamount}}{\oldendenum}

But then when I tried to change the label of an enumeration to use roman number I got an error saying Missing number, treated as zero. Here is a simple code reproducing the error. Anybody has an idea what is the problem here??

Thanks in advance.

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{parskip}


\let\oldenum\enumerate
\let\oldendenum\endenumerate
\renewenvironment{enumerate}{\oldenum\setlength{\parskip}{\smallskipamount}}{\oldendenum}


\begin{document}

\begin{enumerate}[label=\roman*)] % THIS THROWS A COMPILATION ERROR
    \item one
    \item two
    \item three
\end{enumerate}

\end{document}
Rodrigo
  • 123
  • Welcome to TeX.SX! Where did you define \smallskipamount? – TeXnician Feb 08 '17 at 19:13
  • @TeXnician: \smallskipamount is a LaTeX built in, as far as I know –  Feb 08 '17 at 19:15
  • @ChristianHupfer Sorry, I did not know. But then why should someone use enumitem and set parskip manually? – TeXnician Feb 08 '17 at 19:16
  • 2
    there is no reason to redefine enumerate, all the spacing in the environment may be set by parameters either directly or using enumitem setup as you have loaded that package. – David Carlisle Feb 08 '17 at 19:17
  • @Rodrigo I tried it. But why don't you use enumitem's parsep property? It does your task. – TeXnician Feb 08 '17 at 19:17
  • your enviroment is equivalent to \begin{oldenum}\setlength{\parskip}{\smallskipamount}[label=\roman*)] so clearly the old environment will not see the optional argument. – David Carlisle Feb 08 '17 at 19:19
  • @TeXnician method works for me. I didn't know about it (I'm a still bit new to latex). Thank for your help people. – Rodrigo Feb 08 '17 at 19:24
  • @TeXnician: Someone who does not read manuals ;-) –  Feb 08 '17 at 19:38

2 Answers2

5

The solution with enumitem and itemsep is cleaner because it is supported by the package already.

I give a way using the redefinition of the environment, just for completeness.

Since enumerate has an optional argument, \let is not sufficient, but using \LetLtxMacro from the package \letltxmacro cares for this catching.

The optional argument must be catched for the \renewenvironment as well, otherwise the [....] will be misunderstood.

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{parskip}
\usepackage{letltxmacro}

\LetLtxMacro\oldenum\enumerate
\LetLtxMacro\oldendenum\endenumerate


\begin{document}

{%
\hrule
\begin{enumerate}[label=\roman*)] 
\item one 
\item two
\item three
\end{enumerate}
}


{%
\hrule
\parskip=\smallskipamount
\begin{enumerate}[label=\roman*)] % THIS IS THROWN A COMPILATION ERROR
\item one
\item two
\item three
\end{enumerate}
}


\renewenvironment{enumerate}[1][]{%
  \setlength{\parskip}{\smallskipamount}
  \oldenum[#1]}{\oldendenum}

\hrule
\begin{enumerate}[label=\roman*)] % THIS IS THROWN A COMPILATION ERROR
    \item one
    \item two
    \item three
\end{enumerate}


\end{document}

enter image description here

  • wow, that explains a lot, thanks for your answer! I'm still learning some of the basics, so I appreciate this. – Rodrigo Feb 09 '17 at 01:07
3

You can use enumitem's options to define distances between paragraphs. This code should work:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{parskip}

\setlist[enumerate]{parsep=\smallskipamount}

\begin{document}

\begin{enumerate}[label=\roman*)]
    \item one
    \item two
    \item three
\end{enumerate}

\end{document}
TeXnician
  • 33,589