# Why do I see this weird behavior when using the acmart class and the todonotes package?

The following (not quite) MWE

\documentclass{acmart}
\usepackage{todonotes}
\begin{document}
\title{ACM Class and the todonotes package}
\author{Author}
\maketitle
\todo{A todo.}
\listoftodos
\end{document}

yields the following error:

! Missing \endcsname inserted.
\@@par
l.9 \end
{document}

while the following code

\documentclass{acmart}
\usepackage{todonotes}
\begin{document}
\title{ACM Class and the todonotes package}
\author{Author}
\maketitle
\todo{A todo.}
\listoftodos\\
\end{document}

compiles nicely (using TeX Live 2017).

With the article class I don't have to add a line break \\ or, more generally, a {} after \listoftodos as a workaround. It seems there is an incompatibility? Can this be seen as a bug in either the acmart class or the todonotes package? Thank you!

acmart somewhat bravely redefines the internal \@starttoc command to take two arguments rather than one, the second one being some kind of subheading in the list. You can put that text (or just {}) after \listof...

\documentclass{acmart}
\usepackage{todonotes}
\begin{document}
\title{ACM Class and the todonotes package}
\author{Author}
\maketitle
\todo{A todo.}

\listoftodos{list of todos}

\end{document}
• Reminds me of amsart – egreg Jan 14 '19 at 22:14
• @egreg so it is, the code is almost identical. – David Carlisle Jan 14 '19 at 22:15
• @davidcarlisle and egreg It turns out that listoftodos is not working at all (and without error!) in my second MWE. – Mario Jan 16 '19 at 10:57
• @Mario I don't have llncs and that edit seems to be a completely different question and should be asked as a new question, unless llncs uses the same definition of \@starttoc in which case your llncs example should be \listoftodos{} not \\listoftodos. – David Carlisle Jan 16 '19 at 11:02
• @Mario oh that egreg bloke and the answer worked? amazing:-) – David Carlisle Jan 16 '19 at 16:37