Can theorems, lemmas, etc., be automatically displayed without numbers if not referenced (like \mathtoolsset{showonlyrefs} for equation tags)?

  • You might want to refer to a lemma when exposing the contents of the paper; a number can be handy anyway.
    – egreg
    Jan 13, 2014 at 12:41
  • That is true. The question remains though.
    – user66081
    Jan 13, 2014 at 14:14
  • 4
    Damn, where is my please-do-not-do-that tag when I need it?
    – yo'
    Jan 29, 2014 at 18:07
  • If you know what it looks like, just fake it. In other words, don't use \begin{theorem} etc. Jan 29, 2014 at 19:00
  • right now I'm using starred environments, but this is not good enough. I'm writing lecture notes, and it is not always clear where to put a star; I think it is helpful to omit numbers as an indication that a particular Example/Lemma/etc has local impact. (It would be even better to have a list of where it is used, if at all).
    – user66081
    Jan 29, 2014 at 19:02

1 Answer 1


This is certainly not the most elegant solution but it works:


\ifcsname r@thm#1\endcsname\begin{theorem}\else\begin{theorem*}\fi\label{#1}
\ifcsname r@thm\helpercommand\endcsname\end{theorem}\else\end{theorem*}\fi


This theorem is referenced later.

This is not.

This is again.

Theorems \thmref{labelA} and \thmref{labelC} are great!

referenced theorems

  • doesn't this produce multiply defined labels if, say, \thmref{labelA} is used multiple times?
    – user66081
    Feb 3, 2014 at 18:01

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.