0

Enumerate exhibits unexpected behavior when renamed In the example below I renamed enumerate to enum for brevity.

\documentclass{article}
\usepackage{enumerate}

\newcommand{\enum}{\enumerate}

\title{}
\author{}
\date{}
\begin{document}

\begin{enumerate}
\item A
\item B
\item C
\end{enumerate}

\begin{enum}
\item A
\item B
\item C
\end{enum}

%\begin{\enum}
%\item A
%\item B
%\item C
%\end{\enum}

\end{document}

However the outputs of when the fullname is used and shortname is used are different. As expected, fullname gives

    1. A
    2. B
    3. C

But shortname gives

    1. A
    2. B
3. C

And \enum does not compile. For some other environments shortnames do not work at all. Can someone explain why this happens and how to properly shorten environment names?

3
  • 2
    you need to copy the whole environment, including the end code. But don't do it. It is easy to create clashes with existing commands and you make your code less readable for other if you are looking for help (as you do now). Better setup your editor so that it automatically creates such environments and eases the typing. Commented Sep 28, 2022 at 7:25
  • The package defines a macro \@@enum@ to handle optional arguments. Your definition may clash with that. See page 3 of the enumerate package documentation on CTAN
    – Elad Den
    Commented Sep 28, 2022 at 7:37
  • 1
    @EladDen That isn't a problem here Commented Sep 28, 2022 at 10:02

1 Answer 1

2

The problem is that \end{enum} wants to execute \endenum and, since the token is undefined, TeX treats it as \relax (because \csname is used).

Thus \endenumerate never gets executed and you're left with wrong output.

Add \let\endenum\endenumerate.

\documentclass{article}
\usepackage{enumerate}

\newcommand{\enum}{\enumerate}
\let\endenum\endenumerate

\title{}
\author{}
\date{}
\begin{document}

\begin{enumerate}
\item A
\item B
\item C
\end{enumerate}

\begin{enum}
\item A
\item B
\item C
\end{enum}

\end{document}

enter image description here

I recommend using the more flexible enumitem package instead of enumerate.

Don't even try \begin{\enum}. It's very wrong.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .