当点击某一节中第一个词条的引用时,我会被带到该节的开头,而不是词条

当点击某一节中第一个词条的引用时,我会被带到该节的开头,而不是词条

更新内容以粗体显示

这里当我在自己创建的自定义子词干环境中单击对某个词干的引用时,系统会将我带到该节的开头,而不是该词干有人帮助我将超链接修复到我创建的自定义 sublemma 环境(请参阅下面的最小工作示例)。

这个解决方案带来了两个新的错误:

  • 当单击某一节中第一个词条的引用时,我被带到该节的开头(参见最小工作示例)(解决了
  • 将文件上传到 arxiv.org 时,对词干的引用根本不再起作用。(只有对子命题的引用不起作用,请参阅更新后的工作示例

有人可以帮忙吗?

以下是示例:

\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}
 
\renewcommand{\theHfirsttheorem}{\theparentlemma(\Roman{firsttheorem})}

\begin{document}

\section{Test A}
\textcolor{red}{I land here when I click~\ref{firstlemmainsection}!}
\begin{lemma}
This is a lemma
\end{lemma}
\lipsum
\section{Test B}
\begin{lemma}
\label{firstlemmainsection}
This is a lemma
\end{lemma}

\begin{lemma}
This is a lemma
\end{lemma}

\lipsum 

\begin{sublemmas}
\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 in~\ref{firstlemmainsection} I get redirected to the beginning of Section Test A.




\end{document}

同时,我发现,当将鼠标悬停在本地生成的 PDF 中的超链接上时,它显示 ''/.../#firsttheorem.2.3(I)",但在 arxiv.org 生成的文件中,它显示为 ''/.../#firsttheorem.2.3(I)%00''。不知何故 arxiv.org 添加了一个 %00,从而导致了错误。

我可以使用 LaTeX 编译器而不是 pdfLaTeX 编译器在本地重现此问题。

我发现了错误:arxiv 默认不使用 pdflatex 编译器,所以我不得不在主文件的前 5 行内添加命令“\pdfoutput=1”。

更新了实际工作的示例:


\pdfoutput=1

\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})}%
  \let\theHfirsttheorem\thefirsttheorem
  \ignorespaces
 }
 {\setcounter{firsttheorem}{\value{parentlemma}}\ignorespacesafterend}
 


\begin{document}

\section{Test A}
% \textcolor{red}{I land here when I click~\ref{firstlemmainsection}!}
\begin{lemma}
This is a lemma
\end{lemma}
\lipsum
\section{Test B}
\begin{lemma}
\label{firstlemmainsection}
This is a lemma
\end{lemma}

\begin{lemma}
This is a lemma
\end{lemma}

\lipsum 

\begin{sublemmas}
\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{firstlemmainsection} it works.

When I click on~\ref{sublemmas1} in the PDF generated by arxiv.org nothing happens.


\end{document}

答案1

您对 的重新定义\theHfirstheorem在错误的地方。

\newcounter{parentlemma}
\newenvironment{sublemmas}
 {%
  \refstepcounter{firsttheorem}%
  \setcounter{parentlemma}{\value{firsttheorem}}%
  \edef\theparentlemma{\thefirsttheorem}%
  \setcounter{firsttheorem}{0}%
  \renewcommand{\thefirsttheorem}{\theparentlemma(\Roman{firsttheorem})}%
  \renewcommand{\theHfirsttheorem}{\theparentlemma(\Roman{firsttheorem})}%
  \ignorespaces
 }
 {\setcounter{firsttheorem}{\value{parentlemma}}\ignorespacesafterend}

我还删除了杂散的~

更简单地说,

\newcounter{parentlemma}
\newenvironment{sublemmas}
 {%
  \refstepcounter{firsttheorem}%
  \setcounter{parentlemma}{\value{firsttheorem}}%
  \edef\theparentlemma{\thefirsttheorem}%
  \setcounter{firsttheorem}{0}%
  \renewcommand{\thefirsttheorem}{\theparentlemma(\Roman{firsttheorem})}%
  \let\theHfirsttheorem\thefirsttheorem
  \ignorespaces
 }
 {\setcounter{firsttheorem}{\value{parentlemma}}\ignorespacesafterend}

请记住,为了让 arXiv 用于pdflatex你的文档,你必须指定

\pdfoutput=1

最好位于文档的最开始处。

相关内容