我正在用 amsbook 样式写一本书。我希望在章节内引用公式和定理时不显示章节编号,否则显示章节编号。例如,我希望
...参见(3.2)...[如果该等式在同一章中]
和
...参见(II.3.2)...[如果这出现在第 IV 章中,但等式出现在第 II 章中]
有没有简单的方法可以做到这一点?我现在可以在后一种情况下通过写入 (\ref{ChapterII}.\ref{3.2}) 来实现,在前一种情况下只需写入 (\ref{3.2}) 即可,但我想知道是否有自动的方法可以做到这一点。
编辑:我看到了链接的答案 - 但它不适用于 amsbook!有什么想法吗?
=======
这是一个基于链接的示例。它可以工作(没有方程式数字),但不能与 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}