在我如何才能结合两个 newtheorem 环境,使得一个环境继续另一个环境的编号并添加一些额外的编号?我发现了如何为我的词条创建子编号。
现在我遇到了以下问题:当我单击文本后面对子词条的引用时,我会被带到包含该词条的部分的开头。我必须在下面提供的示例中进行哪些更改才能使引用的位置正确?
(我尝试在子词义前面添加 /phantomsection,但是没有起到作用。)
我创建了一个示例工作表来阐明我的意思:
\documentclass{article}
\usepackage{amsmath,amsfonts}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[pdfpagemode=UseNone,bookmarksopen=false,colorlinks=true,urlcolor=blue,citecolor=blue,citebordercolor=blue,linkcolor=blue]{hyperref}
\newtheorem{firsttheorem}{Proposition}
\newtheorem{lemma}[firsttheorem]{Lemma}
\numberwithin{equation}{section}
\numberwithin{firsttheorem}{section}
\newcounter{parentlemma}
\newenvironment{sublemmas}
{%
~\refstepcounter{firsttheorem}%
\setcounter{parentlemma}{\value{firsttheorem}}%
\edef\theparentlemma{\thefirsttheorem}%
\setcounter{firsttheorem}{0}%
\renewcommand{\thefirsttheorem}{\theparentlemma(\Roman{firsttheorem})}%
\ignorespaces
}
{\setcounter{firsttheorem}{\value{parentlemma}}\ignorespacesafterend}
\begin{document}
\section{Test A}
\begin{lemma}
This is a lemma
\end{lemma}
\section{Test B}
\textcolor{red}{I land here when I click~\ref{sublemmas1}!}
\begin{lemma}
This is a lemma
\end{lemma}
\begin{lemma}
This is a lemma
\end{lemma}
\lipsum
\begin{sublemmas}
\textcolor{red}{I want to jump here if I click on~\ref{sublemmas1}!}
\begin{lemma}
\label{sublemmas1}
This is a lemma
\end{lemma}
\begin{lemma}
This is a lemma
\end{lemma}
\end{sublemmas}
I want to jump here if I click on~\ref{lemma2}!
\begin{lemma}
\label{lemma2}
This is a lemma
\end{lemma}
\begin{sublemmas}
\begin{lemma}
This is a lemma
\end{lemma}
\begin{lemma}
This is a lemma
\end{lemma}
\end{sublemmas}
\newpage
\section{Test C}
When I click on~\ref{lemma2} I jump to the right location, but clicking on~\ref{sublemmas1} brings me to the beginning of Section Test B.
\end{document}
答案1
添加
\renewcommand{\theHfirsttheorem}{\theparentlemma(\Roman{firsttheorem})}
到环境定义,以便 hyperref 可以创建不同的目的地。