0

I would like to have theorems with ntheorem which have no number, but instead of the number a name is used. The referencing to such theorems is already discussed in https://stackoverflow.com/questions/2767389/referencing-a-theorem-like-environment-by-its-name

But I still have a formatting issue. (I am actually not sure what the ideal formatting would be, maybe you can help me with this, too?) MWE:

\documentclass{article}
\usepackage{ntheorem}
\usepackage{thmtools}

%https://stackoverflow.com/questions/2767389/referencing-a-theorem-like-environment-by-its-name
\makeatletter
\def\namedlabel#1#2{\begingroup
   \def\@currentlabel{#2}%
   \label{#1}\endgroup
}
\makeatother

\theoremstyle{nonumberplain}
\theoremseparator{.}
\newtheorem{goal}{Goal}

\begin{document}

\begin{restatable}{goal}{goalName}{\textbf{Name}}
\namedlabel{thm:name}{Name}
Goal without number, but with name.
\end{restatable}

We refer to the Goal~\ref{thm:name}:

\goalName*
\end{document}

produces:

enter image description here

And somehow the theoremseparator seems to be wrong the way it is? And is textbf+italics a good decision for the name?

Thank you, all the best, Markus

1

You misunderstood the way to use the optional argument in the restatable environment: it has to be given as the first argument,between brackets. I took the opportunity to redefine the nonumberplain theorem style, so as to automatically incorporate the optional argument in the label.

I wasn't sure whether you want the parentheses for the optional argument or not, so I didn't change this feature, but they're easy to remove from the redefinition of the style.

\documentclass{article}
\usepackage{ntheorem}
\usepackage{thmtools, thm-restate}

%https://stackoverflow.com/questions/2767389/referencing-a-theorem-like-environment-by-its-name
\makeatletter
\def\namedlabel#1#2{\begingroup
   \def\@currentlabel{#2}%
   \label{#1}\endgroup}
\renewtheoremstyle{nonumberplain}%
  {\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
  {\item[\theorem@headerfont\hskip \labelsep ##1\ (##3)\theorem@separator\namedlabel{thm:name}{##3}]}
\makeatother

\theoremstyle{nonumberplain}
\theoremseparator{.}
\newtheorem{goal}{Goal}

\begin{document}

\begin{restatable}[Name]{goal}{goalName}%
Goal without number, but with name.
\end{restatable}

We refer to the Goals~\ref{thm:name} :

\goalName*

\end{document} 

enter image description here

  • Thank you! Oooh I see, so the {\textbf{Name}} was simply rendered as text, and was not even interpreted as argument? Works fine with correct use of parameters. – markus23 Sep 17 '17 at 23:15

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.