I'm using thmtools for defining several environments for theorems, lemmas, etc.
Among these is an environment for corollaries. (I give the full definition of this environment at the end of this post). I'm restricting the designation of corollaries to immediate consequences of earlier items that I want to be able to refer to, but for which, instead of proofs, I will just provide cross-references to whatever earlier items they follow immediately from. For example, if corollary III.4.5 is the immediate consequence of items I.2.3 and II.3.4, I want something like:
Corollary III.4.5 (I.2.3 and II.3.4). Foo is equivalent to bar. ⬜
To do this in a way most consistent with the typographic conventions used elsewhere in the document (with the parenthesized reference coming before the period at the end of the corollary's head, as shown above), the thing to do is to use the built-in optional argument for theorem-like environments defined through thmtools' \declaretheorem
. In fact, I do get the desired placement of the cross-references in the corollary's head if I specify something like
\begin{corollary}[some theorem and some definition]
Foo is equivalent to bar. \qed
\end{corollary}
This indeed compiles without any problem, but, of course, puts the string "(some theorem and some definition)" in the place where there should be proper cross references (as illustrated above):
Corollary III.4.5 (some theorem and some definition). Foo is equivalent to bar. ⬜
But when I try to specify proper cross-references with:
\begin{corollary}[\ref{some theorem} and \ref{some definition}]
%% ...
...I get the error
! Missing \endcsname inserted.
<to be read again>
\protect
l.345 ...{some theorem} and \ref{some definition}]
?
Is there any way to protect the cross references so to avoid this error? (Edit: BTW, I get the same error even if I use \MakeRobustCommand\ref
from the makerobust package. FWIW.)
PS: FWIW, below are the relevant definitions for the code shown earlier:
\def\qed{\hfill $\Box$}
\declaretheoremstyle[%
spaceabove=4ex%
]{thmstyle}
\declaretheorem[%
name={Theorem},%
numberwithin=section,%
style=thmstyle,%
]{thm}
\declaretheorem[%
name={Corollary},%
style=thmstyle,%
sharenumber=thm,%
]{corollary}
EDIT BY LOCKSTEP: The following example works for me:
\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}
\declaretheoremstyle[%
spaceabove=4ex%
]{thmstyle}
\declaretheorem[%
name={Theorem},%
numberwithin=section,%
style=thmstyle,%
]{thm}
\declaretheorem[%
name={Corollary},%
style=thmstyle,%
sharenumber=thm,%
]{corollary}
\begin{document}
\section{foo}
\begin{thm}\label{a}
Some text.
\end{thm}
\begin{corollary}[\ref{a}]
Some text.
\end{corollary}
\end{document}
EDIT BY KJO: I copied and pasted lockstep's example, and ran it, but it does not work for me; the error I get is pretty much the same as the ones I got before:
! Missing \endcsname inserted.
<to be read again>
\protect
l.28 \begin{corollary}[\ref{a}]
? x
I re-ran the same code after prepending the \listfiles
command to it, and put the generated log file here. Please, let me know what other info I should post to zero in on the reason for this discrepancy.
thmtools
(50) is outdated. My version number is 61, and this is also the version curently listed at CTAN.thmtools
package. Your distribution lists it as2010/08/09 v50
while the most up-to-date bundle on CTAN is2011/06/02 v61
. Try this and report back.