4

I am writing a book using the amsbook style. I would like references to formulas and theorems to appear without chapter numbers when I cite within the chapter, and with them otherwise. For example, I want

... see (3.2) ... [if that equation is in the same chapter]

and

... see (II.3.2)... [if this appears in, say, Chapter IV but the equation is in Chapter II]

Is there an easy way to do this? I can do it now by writing (\ref{ChapterII}.\ref{3.2}) in the latter case, and just (\ref{3.2}) in the former but I wonder if there is an automatic way of doing it.

EDIT: I saw the linked answer - but that does not work with amsbook! Any idea?

=======
Here is an example based on the linked one. It works (without eq. numbers) but it does not with amsbook!

===============

\documentclass{book}  \% does not work with amsbook  
\usepackage{ntheorem}


% From your post I assume you have settings like this:
\renewcommand*\thechapter{\Roman{chapter}}
\newtheorem{mytheo}{MyTheo}[chapter]

% Redefine the format of the theorem number:
\renewcommand*\themytheo{%
\protect\maybechapter{\arabic{chapter}}\arabic{section}.\arabic{mytheo}%
}

% May print the chapter number
\newcommand*\maybechapter[1]{%
% Tests if current chapter is equal to the chapter number of label)
\ifnum\value{chapter}=0#1\relax
 % Print nothing if so
\else
 % Set 'chapter' locally (=> no \setcounter) to the label chapter and
 % print it in the usual format followed by a dot
 {\value{chapter}=#1\relax\thechapter.}%
\fi
}

% Test document:
\begin{document}
\chapter{One}
Here \ref{theo:11}  % prints "1.1"
and there \ref{theo:21}. % print "II.1.1" 

\section{Section1}
\begin{mytheo}\label{theo:11}
\begin{equation}\label{11}
x^n+y^n=z^n
\end{equation}
\end{mytheo}
The eq. number should be (1.1) (section.eq). 


\section{Section 2}
\begin{mytheo}
Theo1-2\label{theo:12}
\end{mytheo}


\chapter{Two}
There \ref{theo:11}  % prints "I.1.1"
and here \ref{theo:21}. % print "1.1"

\section{S1}
\begin{mytheo}
Theo2-1\label{theo:21}
\end{mytheo}

See (\ref{11}) for more details. I expected (I.1.1). 

\end{document}
  • 2
    Related: Cross-referencing in multiple chapters – Werner Sep 16 '14 at 19:23
  • 1
    The amsbook document class uses arabic rather than uppercase-Roman "numbers" for chapter. Have you redefined the numbering system? If so, please show the code you've utilized, as it may have some bearing on how your objective may be achieved. – Mico Sep 16 '14 at 19:41
  • Yes, I have this command: \def\thechapter{\Roman{chapter}} – ABC Sep 16 '14 at 19:44
  • And how have you redefined \theequation? As chapter_number.section_number.eq_num or as section_number.eq_num? Ideally, you would be providing this information up front, in the form of an MWE (minimum working example). – Mico Sep 16 '14 at 20:33
  • 2
    Could you post a minimal example of where it doesn't work, then? The example should be complete—from \documentclass{amsbook} to \end{document}. – Sean Allred Sep 18 '14 at 4:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.