3

I am working on a small project and am using the enumitem package reasons for beyond this example. I read the docs and managed to produce this example. Currently, I am using the before argument on the \begin{description} (uncomment part of line 6).

To facilitate reuse I would like to move it into the global settings for description the description environment (line 4). However, it appears to be beyond my understanding.

Thanks for the help

\documentclass{article}
  \usepackage{enumitem}

  %\setlist[description]{before={\renewcommand{\makelabel}[1]{\textit{##1}: }}} % Illegal parameter number in definition of \enit@@description.
  \begin{document}
    \begin{description}%[before={\renewcommand{\makelabel}[1]{\textit{##1}: }}]
      \item[square]{a four-sided polygon is a square if and only if all sides are equal and its vertex angles are all right angles.}
    \end{description}
  \end{document}
  • Maybe I'm missing something here, but why don't you just use \setlist[description]{font=\normalfont\itshape} rather than using the before code? – Alan Munn Jun 01 '13 at 20:52

2 Answers2

4

If your goal is simply to change the formatting of the description label, then you shouldn't be using the before argument at all, but instead just specifying the format for the label. If you're just changing font properties you can use the font argument (e.g. font=\normalfont\itshape) If you want to add material to the label (as you state in the comment), the best way to do that is to make a command to add the colon (or do any other formatting you want) and use that command as the last in the format argument. There should generally be very little need for the before argument with respect to formatting the parts of the list itself.

\documentclass{article}
\usepackage{enumitem}
\newcommand\addcolon[1]{#1:}
\setlist[description]{format=\normalfont\itshape\addcolon}.
\begin{document}
  \begin{description}
    \item[square]{a four-sided polygon is a square if and only if all sides are
     equal and its vertex angles are all right angles.}
  \end{description}
\end{document}
Alan Munn
  • 218,180
2

The package apparently passes that argument through three levels of macro definition so you need

\documentclass{article}
  \usepackage{enumitem}

  \setlist[description]{before={\renewcommand{\makelabel}[1]{\textit{########1}: }}} % Illegal parameter number in definition of \enit@@description.
  \begin{document}
    \begin{description}%[before={\renewcommand{\makelabel}[1]{\textit{##1}: }}]
      \item[square]{a four-sided polygon is a square if and only if all sides are equal and its vertex angles are all right angles.}
      \item[square]{a four-sided polygon is a square if and only if all sides are equal and its vertex angles are all right angles.}
    \end{description}
  \end{document}
David Carlisle
  • 757,742