2

I'm using amsthm and thmtools for my theorem environments. Is there any way to print the name of a theorem? For example, given the following code:

\documentclass[paper=a4]{scrreprt}
\usepackage{amsthm}
\usepackage{thmtools}

\declaretheorem[name=Theorem]{theorem}

\begin{document}
  \begin{theorem}[name=My Title]
    \label{myonlytheorem}
    My theorem text.
  \end{theorem}
\end{document}

Is there a command, say \thmname{myonlytheorem}, that prints the theorem's name, i.e., "My Title"?

  • you're using amsthm. amsthm provides a \newtheorem* command that allows you to define a theorem with a unique name; it's described on page 2 of the manual (texdoc amsthm). – barbara beeton Oct 15 '14 at 20:03
  • Yes, I know. However, I want it to be a "normal" theorem without a unique name. Most of the times, it shall be referenced like "Theorem 1". There is only one exception, where I want some kind of reminder like "Theorem 1 (My Title)" to be printed additionally. – Jens Oct 15 '14 at 20:15
  • it seems that you want this as a reference. that's not crystal clear in your question. no, that isn't provided by amsthm. you might just define a command yourself, since there's only one of these, say \newcommand{\mytheoremname}{my title} and use that in both the theorem heading option and as the reference in the text. – barbara beeton Oct 15 '14 at 20:37
1

You can use the package nameref to cross-reference the name of theorem myonlytheorem by writing \nameref{myonlytheorem}

\documentclass[paper=a4]{scrreprt}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{nameref}

\declaretheorem[name=Theorem]{theorem}

\begin{document}
  \begin{theorem}[name=My Title]
    \label{myonlytheorem}
    My theorem text.
  \end{theorem}

  My theorem is called \nameref{myonlytheorem}
\end{document}
|improve this answer|||||

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.