9

My question refers to the minimal example pasted below. I would like to change the title of the second theorem (the one with yyy) to Theorem 7' without affecting the theorem counter. That is, the theorems should be labelled as follows:

Theorem 1 xxx
Theorem 7' yyy
Theorem 2 zzz
Theorem 3 uuu

Possibly this can be done using \setcounter, but this does not solve the problem with the prime after the 7. So my question is whether it is possible to manipulate particular theorem labels?

\documentclass{scrartcl}
\usepackage{ntheorem}
\newtheorem{thm}{Theorem}   
\begin{document}
\begin{thm} %Theorem 1
xxx
\end{thm}
\begin{thm} % Theorem 7'
yyy
\end{thm}
\begin{thm} %Theorem 2
zzz
\end{thm}
\begin{thm} %Theorem 3
uuu
\end{thm}
\end{document}

I am getting back to Marco Daniels answer. Consider the following three minimal examples. I do not understand why the first doesn't work while the second and third is fine. Can anyone tell me?

First example (produces strange error):

\documentclass{article}

\usepackage[thmmarks,hyperref]{ntheorem} 
\usepackage[colorlinks=false, citecolor=blue, pdfstartview=FitH,plainpages=false] {hyperref}

\newtheorem{thm}{Theorem}                            
\newtheorem{prop}[thm]{Proposition}

\begin{document}
\begingroup
\def\thethm{\ref{a}'}
\addtocounter{thm}{-1}
\begin{prop} 
yyy
\label{test}
\end{prop}
\endgroup
\end{document}

Second example, hyperref removed, otherwise identical code (works fine):

\documentclass{article}

\usepackage[thmmarks]{ntheorem} 

\newtheorem{thm}{Theorem}                            
\newtheorem{prop}[thm]{Proposition}

\begin{document}
\begingroup
\def\thethm{\ref{a}'}
\addtocounter{thm}{-1}
\begin{prop} 
yyy
\label{test}
\end{prop}
\endgroup
\end{document}

Third example, code as in the first example but \thethm is changed (also works well):

\documentclass{article}

\usepackage[thmmarks,hyperref]{ntheorem} 
\usepackage[colorlinks=false, citecolor=blue, pdfstartview=FitH,plainpages=false] {hyperref}

\newtheorem{thm}{Theorem}                            
\newtheorem{prop}[thm]{Proposition}

\begin{document}
\begingroup
\def\thethm{1'}
\addtocounter{thm}{-1}
\begin{prop} 
yyy
\label{test}
\end{prop}
\endgroup
\end{document}

I am really confused about this. Cannot interpret the error message.

1

2 Answers 2

10

The output of a counter is stored in the macro \the<counter>. So you have to change \thethm. Based on your request you have to do this local. In the example below I do this with \begingroup...\endgroup. Of course you must decrease the counter thm too.

\documentclass{scrartcl}
\usepackage{ntheorem}
\newtheorem{thm}{Theorem}   
\begin{document}
\begin{thm} %Theorem 1
xxx
\end{thm}
\begingroup
\def\thethm{7'}
\addtocounter{thm}{-1}
\begin{thm} % Theorem 7'
yyy
\label{test}
\end{thm}
\endgroup
\begin{thm} %Theorem 2
zzz
\end{thm}
\begin{thm} %Theorem 3
uuu
\end{thm}
\ref{test}
\end{document}
1
  • All right. Works fine.
    – lpdbw
    Jul 22, 2012 at 13:56
3

You can make this automatic:

\documentclass{article}
\usepackage{ntheorem}
\newtheorem{thm}{Theorem}

\theoremstyle{nonumberplain}
\newcommand\specialref{}
\newtheorem{thmx}{Theorem \specialref}
\newenvironment{thmref}[2][$'$]
  {\renewcommand\specialref{\ref{#2}#1}\thmx}
  {\endthmx}

\begin{document}
\begin{thm}\label{A}
$1+1=2$.
\end{thm}

\begin{thmref}{A}
$2=1+1$.
\end{thmref}

\begin{thmref}[*]{A}[Variation on the theme]
$2\le 1+1$.
\end{thmref}
\end{document}

The thmref environment wants as argument the label corresponding to the main theorem. In this way you don't need to hard code the number in the input. The last example shows how to change the default prime to, for instance, an asterisk and shows also that the optional attribution can still be specified.

If you also want to assign a \label to these "modified versions", then say

\usepackage{refcount}

and modify the definition of thmref as

\newenvironment{thmref}[2][$'$]
  {\edef\thethmx{\getrefnumber{#2}\unexpanded{#1}}%
   \renewcommand\specialref{\ref{#2}#1}\thmx}
  {\endthmx}

while leaving the rest unchanged. Now

\begin{thmref}{A}\label{B}
$2=1+1$.
\end{thmref}
\ref{B}

will print

1′

The thmx theorem environment is auxiliary. Its label will be determined dynamically by redefining \specialref. The thmref environment redefines \specialref to expand to the required number and also redefines the counter associated to thmx (which is not useful for any other purpose) via \getrefnumber (see the documentation of refcount): with \edef we get the "current value" of the reference, to which we add the prime (or other marker, specified in the optional argument) which is \unexpanded because it may contain tokens that are dangerous in an \edef.

You must log in to answer this question.

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