Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 16 down vote accepted

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.

share|improve this answer
    
Oh, so simple! I have forgot about that. Thanks! –  xen Mar 20 '11 at 22:01
4  
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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