46

How do I create something like this without getting any errors?

\begin{thm}[\cite[page 10]{ABC2011}]
...
\end{thm}

I tried putting various things into {...} brackets, but not eliminating any errors. I probably have misunderstood something about how LaTeX works in the background and the AMS packet:

\usepackage[amsmath,thmmarks]{ntheorem}
lockstep
  • 250,273
user46365
  • 543

4 Answers4

50

Mask the content of thm' s optional argument with an additional set of braces.

EDIT: For what it's worth, with ntheorem loaded one needs two additional sets of braces.

\documentclass{article}

\usepackage{ntheorem}

\newtheorem{thm}{Theorem}

\begin{document}

\begin{thm}[{{\cite[page 10]{ABC2011}}}]
A theorem.
\end{thm}

\begin{thebibliography}{9}
\bibitem{ABC2011} A bibitem.
\end{thebibliography}

\end{document}
lockstep
  • 250,273
  • Thanks for the fast response. I get these errors, when I do that: Argument of @citex has an extra }.

    Runaway argument?

    page 10\color@endgroup 
    

    Latex Error: Paragraph ended before @citex was complete. Latex Error: Extra }, or forgotten \endgroup.

    – user46365 May 01 '11 at 19:01
  • It must be some other package which is causing troubles :\ – user46365 May 01 '11 at 19:03
  • Tried it on a fresh file and it worked like a charm.. bummer. – user46365 May 01 '11 at 19:04
  • @user46365: What packages that might affect theorems do you use (amsthm, ntheorem)? What document class? A working example would be even better. – lockstep May 01 '11 at 19:04
  • @user46365: Strange enough, my example still works if I load amsthm, but not with ntheorem. Obviously you don't use ntheorem if it works for you now. – lockstep May 01 '11 at 19:07
  • it worked when I opened up a new file and just copy pasting what you did above, but as you said it seems to be ntheorem which is causing the troubles. – user46365 May 01 '11 at 19:12
  • I edited my question above to reflect this – user46365 May 01 '11 at 19:12
  • @user46365: I edited my answer. – lockstep May 01 '11 at 19:16
  • 1
    two brackets, who would have thought. thanks! have a great day. – user46365 May 01 '11 at 19:23
  • @user46365: You're welcome! If you're allowed to do so as an unregistered user, please don't forget to also upvote my answer. ;-) – lockstep May 01 '11 at 19:26
  • just registered so I could upvote it. :D – user46365 May 01 '11 at 19:27
  • thanks. I had the same issue with the pdfcomment package and references to includegraphics and SIunitx. adding two extra sets of curly brackets solved the problem. – Foad Aug 05 '19 at 10:09
10
\documentclass{article}
\usepackage{ntheorem}
\newtheorem{thm}{Theorem}

\begin{document}

\begin{thm}[\protect{\cite[page 10]{ABC2011}}]
A theorem.
\end{thm}

\begin{thebibliography}{9}
\bibitem{ABC2011} A bibitem.
\end{thebibliography}

\end{document}

regards

Marco Daniel
  • 95,681
2

There seems to be conflict between the packages ntheorem and amsthm. As a slightly different solution to Fiandrino's, I change

[\cite[page 10]{ABC2011}] to [{\cite[page 10]{ABC2011}}],

then it works.

\documentclass{article}
\newtheorem{theorem}{Theorem}[section]

\begin{document}

\begin{theorem}[{\cite[page 10]{ABC2011}}] A theorem. \end{theorem}

\begin{thebibliography}{9} \bibitem{ABC2011} A bibitem. \end{thebibliography}

\end{document}

-1

I have another solution. I don't use the package theorem.

I just change [\cite[page 10]{ABC2011}] to --> {[\cite[page 10]{ABC2011}]}.

  • 1
    Welcome! This answer has already been given by others, please make sure that your answer is really a "new answer" before clicking that button. Small improvements on existing answers can be suggested in the comments or with the "edit" button. – T. Verron Sep 29 '14 at 14:19