21

I am writing a paper where I have a stated a theorem, and then a short time later I state another theorem which is equivalent to the first. Is it possible to number them so that the second is a primed version of the first? In other words, if the first gets numbered as Theorem 7, I would like its equivalent version to be numbered as Theorem 7'. Ideas? Thanks.

lockstep
  • 250,273
Jim Bryan
  • 213

2 Answers2

14
\documentclass[a4paper]{article}

\newtheorem{thm}{Theorem}
\newenvironment{thmbis}[1]
  {\renewcommand{\thethm}{\ref{#1}$'$}%
   \addtocounter{thm}{-1}%
   \begin{thm}}
  {\end{thm}}

\begin{document}
\begin{thm}
$1+1=2$
\end{thm}
\begin{thm}\label{comm}
$a+b=b+a$
\end{thm}
\begin{thmbis}{comm}
$x+y=y+x$
\end{thmbis}
\begin{thm}
$0\ne0$
\end{thm}
\end{document}

In this way the "primed" theorem doesn't need to be near the main one. The thmbis environment takes as argument the label given to the main one.

If the "primed" theorem is always immediately after the main one, you can say

\newenvironment{thmbis}
  {\addtocounter{thm}{-1}%
   \renewcommand{\thethm}{\arabic{thm}$'$}%
   \begin{thm}}
  {\end{thm}}

If hyperref is used, one has to hack its automatic mechanism for creating hyperlinks; the following seems to work:

\makeatletter
\newcommand{\neutralize}[1]{\expandafter\let\csname c@#1\endcsname\count@}
\makeatother

\newtheorem{thm}{Theorem}

\newenvironment{thmbis}[1]
  {\renewcommand{\thethm}{\ref{#1}$'$}%
   \neutralize{thm}\phantomsection
   \begin{thm}}
  {\end{thm}}

Use \ref*{#1} if you don't want to make a link pointing to the "main theorem".

egreg
  • 1,121,712
  • Would ^\prime not be better than ' for "priming"? – Seamus Jun 24 '11 at 09:24
  • 3
    it's a bad idea to use \addtocounter{thm}{-1} as it doesn't work well with hyperref. Here, in your second example, if you use the \label/ref mechanism to refer to the primed theorem, the hyperlink will go to the wrong place (the unprimed theorem). – Philippe Goutet Jun 24 '11 at 12:13
  • @Seamus: $'$ and $^\prime$ are equivalent. – egreg Jun 24 '11 at 12:38
  • Is there any chance to have this or one of the like solutions have hyperref jump to the primed theorem (and not the original one)? – Bubaya Mar 27 '20 at 11:49
  • What is the difference between \ref and \ref*? – Stephen Jan 01 '23 at 06:39
  • @Stephen The latter is defined when hyperref is loaded and doesn’t make a hyperlink. – egreg Jan 01 '23 at 09:50
0

An idea but ... finally I undelete

\documentclass[12pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath,latexsym}

\newtheorem{theo}{Theorem}
\newcounter{biscompt}

\newtheorem{bis}[biscompt]{Theorem}
\renewcommand{\thebiscompt}{% 
\setcounter{biscompt}{\thetheo} 
\arabic{theo}'}
\usepackage{hyperref}   

\begin{document}

\chapter{}

\section{}  
\begin{theo}
On vérifie que :  $1\not= 1$
\end{theo}

\newpage
\section{}
\begin{theo}
On vérifie que :  $2\not= 3$
\end{theo}

\newpage   
\section{}   



\begin{theo}
On vérifie que :  $1\not= 1$
\end{theo}

\begin{bis}\label{bis}
On vérifie que :  $1\not= 1$
\end{bis}

\newpage
\section{}

With \ref{bis} 
\end{document}   
Alain Matthes
  • 95,075