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}
ABC
  • 111
  • 2
  • 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
  • I have not redefined \theequation. Here is a quick copy and paste: \def\thechapter{\Roman{chapter}}

    \newtheorem{definition}[theorem]{Definition}

    \theoremstyle{remark} \newtheorem{ex}{Problem}[section] \newtheorem{example}{Example}[section]

    \theoremstyle{remark} \newtheorem{remark}{Remark}[section]

    \numberwithin{equation}{section} \numberwithin{figure}{chapter}

    – ABC Sep 17 '14 at 15:52
  • I just saw the linked page. It does not work with amsbook, however. – ABC Sep 17 '14 at 19:03
  • 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 04:14
  • The instruction \numberwithin{equation}{section} does redefine the way equation numbers are displayed -- by redefining \theequation... – Mico Sep 18 '14 at 05:12
  • I think it's worth re-opening this posting -- the solution method offered in the posting "Cross-referencing in multiple chapters" needs more than slight adapting to make it work with equations. – Mico Sep 18 '14 at 05:31
  • @ABC - Please post a real MWE so that people interested in providing a solution understand your setup fully. So far, you've only posted code snippets that don't add up to a full MWE. – Mico Sep 18 '14 at 05:33
  • I updated my question. – ABC Sep 22 '14 at 14:50
  • Bump. Any ideas how to make it work with amsbook? – ABC Nov 02 '14 at 15:20

0 Answers0