1

I'm trying to use the very practicle nameref package with lncs (sty file downloaded here). Unfortunately, instead of displaying the actual name of the definition, it displays the name of last section. Any idea why?

enter image description here

\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}
2

The llncs class defines theorem-like environments with \spnewtheorem and nameref is unable to hook into them as it does when amsthm (or the vanilla LaTeX \newtheorem).

You have to make a hook yourself.

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.