0

I am using the enumerate environment and something strange happened. Here's the line of LaTeX code that causes the strange behavior:

\begin{enumerate}[{\bf Some List  \#1:\ }] 

With this, the list produced has headings of the following form:

Some L1st #1: Blah Blah Blah

Some L2st #2: Blah Blah Blah

The way I eventually corrected this was to modify that specific line to read as follows:

\begin{enumerate}[{\bf {Some List}  \#1:\ }] 

Thus my question about this is somewhat academic, because I have a fix. I just have no idea why it happens, and I have no idea why this fix works. Another reason to ask this question is that while for me the answer is somewhat academic, the discussion of this issue may help someone else. Finally, a reason for asking this is that while this strange behavior was perplexing, both my discovery of it and of my solution just made me laugh, and I think I have no right to deprive others of that moment of mirth. :)

  • 1
    really 1 2..?? I would have expected roman numerals i ii iii iv ... In either case it isn't the standard enumerate behaviour. I would guess you are using the enumerate package but you have not said. It would be a lot clearer if you provided a small complete document that showed the problem, so people could debug. – David Carlisle Jun 24 '18 at 21:17
  • I can reproduce the problem adding the enumerate package. Strange the i from ‘List’ is output as an arabic value of the counter… – Bernard Jun 24 '18 at 21:22
  • @Bernard it's a documented feature:-) The argument has both i and 1 so the last one (1 here) wins. – David Carlisle Jun 24 '18 at 21:32
  • I knew about the feature, but I expected both a roman number, then an arabic. – Bernard Jun 24 '18 at 21:50
  • @Bernard each special character is replaced by \thexxxx and \thexxxx defined to be the appropriate command so first i defines it to be \roman then 1 defines it to be arabic but both are replaced by \thexxxx – David Carlisle Jun 24 '18 at 23:54
1

The output you get is essentially random.

\documentclass{article}
\usepackage{enumerate}

\begin{document}

Wrong:
\begin{enumerate}[{\bf Some List  \#1:\ }]
\item A
\item B
\end{enumerate}

Right:
\begin{enumerate}[\bfseries Some {List} \#1:\ ]
\item A
\item B
\end{enumerate}

\end{document}

enter image description here

On the other hand, the enumitem package is easier:

\documentclass{article}
\usepackage{enumitem}

\begin{document}

\begin{enumerate}[label=\bfseries Some List \#\arabic*:]
\item A
\item B
\end{enumerate}

\end{document}

enter image description here

Please, note that \bf has been obsolete for more than twenty years.

1

note that \bf should not be used in latex.

You are presumably using the enumerate package although you have not said.

In the optional argument to enumerate as defined by that package i triggers the use of roman numerals so

\documentclass{article}

\usepackage{enumerate}

\begin{document}

\begin{enumerate}[{List}]
\item zzzz
\item zzzz
\end{enumerate}
\end{document}

produces List, Liist

But you also have 1 in the option so this redefines the counter to use 1,2

\begin{enumerate}[{List 1}]

produces L1st 1, L2st 2.

Normally {} hides the special tokens, but low level tex parse rules mean that a {} group that is the entire optional argument is dropped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.