我正在尝试使用非常实用的nameref
lncs 包(下载的 sty 文件这里)。不幸的是,它没有显示定义的实际名称,而是显示了最后一节的名称。知道为什么吗?
\documentclass{llncs}
%\documentclass{article} %% <== works with article/below definitions
%% Already defined in LLNCS
% \usepackage{amssymb, amsthm, amsmath}
% \newtheorem{definition}{Definition}
\providecommand*\definitionautorefname{Definition}
\usepackage{nameref}
\usepackage{hyperref}
\begin{document}
\section{The name of the section}
\begin{definition}[Nice name for my definition]\label{def:propertiesF}
I am a nice definition with a nice name
\end{definition}
\section{Use of nameref}
The following nameref should display ``Nice name for my definition''. But the display is \nameref{def:propertiesF}.
\end{document}
答案1
该类llncs
使用定义类似定理的环境,\spnewtheorem
并且nameref
无法像在amsthm
(或原始 LaTeX \newtheorem
)中那样挂接到它们。
你必须自己做一个钩子。
\documentclass{llncs}
\providecommand*\definitionautorefname{Definition}
\usepackage{nameref}
\usepackage{hyperref}
\makeatletter
\let\ORIGINAL@spythm\@spythm
\def\@spythm#1#2#3#4[#5]{%
\NR@gettitle{#5}%
\ORIGINAL@spythm{#1}{#2}{#3}{#4}[#5]%
}
\makeatother
\begin{document}
\section{The name of the section}
\begin{definition}[Nice name for my definition]\label{def:propertiesF}
I am a nice definition with a nice name
\end{definition}
\section{Use of nameref}
The following nameref should display ``Nice name for my definition''.
And it does: \nameref{def:propertiesF}.
\end{document}