2

This is a continuation of my previous question on manually increasing the theorem counter.

So I was able to manually increase and then access the theorem counter, but I am not able to make reference to it using \ref. Here is a minimal NON-WORKING example:

\documentclass{amsart}
\usepackage{amsmath}
\newtheorem{thm}{Theorem}

\begin{document}

\begin{thm}
   \label{first}
First theorem.
\end{thm}

\stepcounter{thm}
   \label{special}
\begin{quote}
   Here is an in-text theorem:  \textbf{Theorem \thethm.} \textit{Special one!}
\end{quote}
Make reference to theorem \ref{first} and my special theorem \ref{special}.
\end{document}

It is NOT WORKING because it could not print the second \ref. I tried moving the \label line within the \begin{quote} ... \end{quote}, but to no avail.

Many thanks for your help!


EDIT: Turns out my MWE is too minimal. Here is an expanded example that better illustrates the problem:

\documentclass{amsbook}
\usepackage{amsthm,fancyhdr}
\newtheorem{thm}{Theorem}[chapter]

\begin{document}

\chapter{New Chapter}

\refstepcounter{thm}
         \label{manual}
\textbf{Theorem \thethm.}  \textit{blah blah}.

\begin{thm}
  \label{second}
  Second theorem.
\end{thm}

\[
\begin{array}{c|c}
A   &  B
\\  \hline
x=y
&
\refstepcounter{thm}
         \label{special}
\text{\textbf{Special Theorem \thethm}.}
\end{array}
\]

\begin{thm}
  \label{last}
  Last theorem.
\end{thm}

Refer to theorem \ref{manual}, theorem \ref{second}, Special Theorem \ref{special},
and last theorem \ref{last}.

\end{document}

In this version I use \refstepcounter, but it does not seem to record the correct theorem number.

Many thanks for your help!

1 Answer 1

6

This answer contains an answer to both the original and at least one later version of the question.

Original answer

Replace \stepcounter with \refstepcounter to update the target for \labels.

However, I would recommend

\begin{quote}
   Here is an in-text theorem:  \textbf{Theorem \thethm.}
  \refstepcounter{thm}%
  \label{special}%
  \textit{Special one!}
\end{quote}

so that hyperlinks, for example, will work if a page break occurs before the quotation.

Additional answer

The AMS classes redefine \label locally in various maths environments. This means that even though the current label is updated by \refstepcounter, that is not the value written to the .aux. You can get the desired value by saving the original definition and using the saved version directly.

For example,

\documentclass{amsbook}
\usepackage{fancyhdr}
\newtheorem{thm}{Theorem}[chapter]
\NewCommandCopy\latexlabel\label
\begin{document}

\chapter{New Chapter}

\refstepcounter{thm}
\label{manual}
\textbf{Theorem \thethm.}  \textit{blah blah}.

\begin{thm}
  \label{second}
  Second theorem.
\end{thm}

\[
    \begin{array}{c|c}
      A   &  B 
      \\  \hline
      x=y &
      \text{\refstepcounter{thm}\latexlabel{special}\textbf{Special Theorem \thethm}.}
    \end{array}
\]
\begin{thm}
  \label{last}
  Last theorem.
\end{thm}

Refer to theorem \ref{manual}, theorem \ref{second}, Special Theorem \ref{special},
and last theorem \ref{last}.

\end{document}

Here \latexlabel{special} uses the text-mode definition of \label rather than the redefined AMS one:

\relax 
\newlabel{tocindent-1}{0pt}
\newlabel{tocindent0}{56.7pt}
\newlabel{tocindent1}{0pt}
\newlabel{tocindent2}{0pt}
\newlabel{tocindent3}{0pt}
\@writefile{toc}{\contentsline {chapter}{\tocchapter {Chapter}{1}{New Chapter}}{1}{}\protected@
file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\newlabel{manual}{{1.1}{1}{}{thm.1.1}{}}
\newlabel{second}{{1.2}{1}{}{thm.1.2}{}}
\newlabel{special}{{1.3}{1}{}{thm.1.3}{}}
\newlabel{last}{{1.4}{1}{}{thm.1.4}{}}
\gdef \@abspage@last{1}

However, it is questionable whether this is good practice. More specifically, if you are supposed to use amsbook for publication, this usage may or may not be acceptable to the publisher. Certainly the usage seems sure to confuse the reader, since all of the usual formatting expected for theorems is absent. So it would probably be better not to do this, but the code above will nonethess do for you what it may be better, IMHO, not to do.

3
  • Thanks @cfr. Unfortunately it does not work in my actual document. I have expanded upon my MWE to show what the issue is. Thanks for your help! Commented Nov 21 at 4:02
  • @underflow it does work in your updated document. what you mean is that it doesn't work in all cases. that's because \label is redefined inside array. I don't think it is a good idea to confuse readers this way, but see edit above. Commented Nov 21 at 4:45
  • Thanks for solving my problem, and you are right, my wording of my comment is imprecise. Commented Nov 22 at 18:01

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.