1

I am trying to use the same type of formatting for all enumerated lists, so I thought it would had been easier to write a macro with the formatting, and then to just write in the macro every time I had to use a list, so to avoid repeating myself and messing up the formatting, here's the code.

\documentclass[11pt, a4paper]{article}
\usepackage{enumitem}

\setlist[itemize]{noitemsep, topsep=0pt}

\newcommand{\enumFormatting}{topsep=0pt,itemsep=-1ex,partopsep=1ex,parsep=1ex}

\begin{document} \begin{enumerate}[\enumFormatting] \item first item \item second item \item third item \item fourth item
\end{enumerate}

\end{document}

Unluckly this didn't work out since an error is returned when I use \enumFormatting as an argument, I must be getting something wrong. Hopefully you can help me fix this, thanks.

1 Answers1

1

This is not the "proper" way to do this but works (in this case in which the key list can be expanded without harm, things would be different if it contained \bfseries, say). The proper way can presumably be found under campa's comment.

\documentclass[11pt, a4paper]{article}
\usepackage{enumitem}

\setlist[itemize]{noitemsep, topsep=0pt}

\newcommand{\enumFormatting}{topsep=0pt,itemsep=-1ex,partopsep=1ex,parsep=1ex}

\begin{document} \expanded{\noexpand\begin{enumerate}[\enumFormatting]} \item first item \item second item \item third item \item fourth item
\end{enumerate}

\end{document}

  • If there was something in the option list that shouldn't be fully expanded, you could use \expanded{\noexpand\begin{enumerate}[\unexpanded\expandafter{\enumFormatting}]} instead, that would only expand the macro once. – Skillmon Apr 20 '21 at 12:18