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"?

3
  • 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). Oct 15, 2014 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, 2014 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. Oct 15, 2014 at 20:37

1 Answer 1

2

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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .