31

When I try to cite a book in such a way

\begin{theorem}[\cite[p.~90]{bibitem}]
Theorem body.
\end{theorem}

I've got an error because of multiple use of [ and ]. Is it possible to cite in such a way in theorem argument? Would be great if it could be done without redefine of \cite command.

36

If you need to pass a ] inside an optional argument, just enclose the argument in figure braces:

\begin{theorem}[{\cite[p.~90]{bibitem}}]
Theorem body.
\end{theorem}

Without this, it's the \cite[p.~90 (everything up to the first ]) that gets passed as the argument, while the remaining text is typeset afterwards.

  • Oh, so simple! I have forgot about that. Thanks! – xen Mar 20 '11 at 22:01
  • 13
    It may be worth pointing out why this happens. The [ and ] bracketing of optional arguments in LaTeX isn't as robust as the { ... } bracketing of TeX. In particular, [ is matched by the next ] that is in the same group (with regard to { ... } grouping) as it. It doesn't look to see if the ] should have matched an intervening [. The solution is (as Andrey says) to ensure that any intervening [ and ]s are in a different TeX group by enclosing them in braces. – Loop Space Mar 21 '11 at 8:09

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.