标签多重定义警告,但我只有一个标签 LNCS 模板

标签多重定义警告,但我只有一个标签 LNCS 模板

没什么大不了的,但是我收到一个奇怪的警告标签“PolyApx”被多次定义。即使我的整个文档中只有一个标签。

\documentclass[runningheads]{llncs}
\usepackage{hyperref}
\usepackage{environ}
\newcommand{\repeattheorem}[1]{%
  \begingroup
  \renewcommand{\thetheorem}{\ref{#1}}%
  \expandafter\expandafter\expandafter\theorem
  \csname reptheorem@#1\endcsname
  \endtheorem
  \endgroup
}

\NewEnviron{reptheorem}[1]{%
  \global\expandafter\xdef\csname reptheorem@#1\endcsname{%
    \unexpanded\expandafter{\BODY}%
  }%
  \expandafter\theorem\BODY\unskip\label{#1}\endtheorem
}
\begin{document}
%
\title{adsnvuadsipnvewjl\thanks{Supported by University of Alberta}}
 \author{Hao Sun\inst{1}\orcidID{0000-0002-2000-8080} 
 }
%
\authorrunning{Hao Sun}
\institute{University of Alberta, Alberta, Canada}
%
\maketitle            
%
\begin{abstract}
 jasdkflasdgfhudafyhebvkcyfhdsuifgakhewnfcgyuzshvcdsyuafcgkdsh 
nbcvasdkfhvuban,vcyuaebvndskaguyrhvba.
\keywords{advdasv dav}
\end{abstract}
\section{Introduction}
Our problem is one of Karp's original 21 NP-hard problems \cite{Karp1972}. 

\begin{reptheorem}{thmDFVSapprox}\label{PolyApx}
jsafhlsdajlkfhdsjaklfdshfjasldfjdskafhdjskflhasdjkfldsha
\end{reptheorem}

adfasdf \autoref{PolyApx}

\repeattheorem{thmDFVSapprox}
adsfasdf \autoref{PolyApx}
 \bibliographystyle{splncs04}
 \bibliography{main}

\end{document}

答案1

作为大卫·卡莱尔写道,您只需\autoref在标签上使用\repeattheorem,而不应该\label在定理陈述中使用单独的。

参见下文,它应该会生成所需的输出。

\documentclass[runningheads]{llncs}
\usepackage{hyperref}
\usepackage{environ}
\newcommand{\repeattheorem}[1]{%
  \begingroup
  \renewcommand{\thetheorem}{\ref{#1}}%
  \expandafter\expandafter\expandafter\theorem
  \csname reptheorem@#1\endcsname
  \endtheorem
  \endgroup
}

\NewEnviron{reptheorem}[1]{%
  \global\expandafter\xdef\csname reptheorem@#1\endcsname{%
    \unexpanded\expandafter{\BODY}%
  }%
  \expandafter\theorem\BODY\unskip\label{#1}\endtheorem
}
\begin{document}
%
\title{adsnvuadsipnvewjl\thanks{Supported by University of Alberta}}
 \author{Hao Sun\inst{1}\orcidID{0000-0002-2000-8080} 
 }
%
\authorrunning{Hao Sun}
\institute{University of Alberta, Alberta, Canada}
%
\maketitle            
%
\begin{abstract}
 jasdkflasdgfhudafyhebvkcyfhdsuifgakhewnfcgyuzshvcdsyuafcgkdsh 
nbcvasdkfhvuban,vcyuaebvndskaguyrhvba.
\keywords{advdasv dav}
\end{abstract}
\section{Introduction}
Our problem is one of Karp's original 21 NP-hard problems \cite{Karp1972}. 

\begin{reptheorem}{thmDFVSapprox}
jsafhlsdajlkfhdsjaklfdshfjasldfjdskafhdjskflhasdjkfldsha
\end{reptheorem}

adfasdf \autoref{thmDFVSapprox}

\repeattheorem{thmDFVSapprox}
adsfasdf \autoref{thmDFVSapprox}
 \bibliographystyle{splncs04}
 \bibliography{main}

\end{document}

相关内容