
Estoy usando la memoir
clase y defino teoremas con thmtools
. Los teoremas suelen tener un nombre, además de estar numerados. Estoy buscando escribir un \fullref
comando que genere el nombre del entorno (aquí Theorem
) junto con su nombre de pila, pero sin su número. (Este comando debería funcionar para cualquier entorno para el que se defina un nombre, por ejemplo, mediante \myenvautorefname
.)
Solía usar el siguiente comando, que se encuentra aquí en TeX SE:
\newcommand{\fullref}[1]{\hyperref[#1]{\namecref{#1}\ \nameref*{#1}}}
Desafortunadamente, memoir
y cleveref
entran en conflicto entre sí. Así que me gustaría arreglármelas sin cleveref
.
Parece que debería poder lograr el mismo efecto con autoref
solo. El comando
\newcommand{\fullref}[1]{\hyperref[#1]{\autoref*{#1}\ \nameref*{#1}}}
casihace lo que quiero, excepto que muestra el número del teorema entre Theorem
y el nombre del teorema.
Aquí hay un MWE que ilustra el comando anterior:
\documentclass{memoir}
\usepackage{amsthm,thmtools}
\usepackage{nameref}
\usepackage{hyperref}
\declaretheorem{theorem}
\renewcommand{\theoremautorefname}{Theorem}
\newcommand{\fullref}[1]{\hyperref[#1]{\autoref*{#1}\ \nameref*{#1}}}
\begin{document}
\begin{theorem}[Whatever]
\label{thm:whatever}
Some witty theorem.
\end{theorem}
% The following outputs "Theorem 1 Whatever".
% I would like "Theorem Whatever".
Consider \fullref{thm:whatever}.
\end{document}
¡Gracias de antemano!
Respuesta1
¿Por qué no usarlo cleveref
?
\documentclass{memoir}
\usepackage{amsthm,thmtools}
\usepackage{nameref}
\usepackage{hyperref}
\usepackage{cleveref}
\declaretheorem{theorem}
\renewcommand{\theoremautorefname}{Theorem}
\newcommand{\fullref}[1]{\hyperref[#1]{\namecref{#1}\ \nameref*{#1}}}
\begin{document}
\begin{theorem}[Whatever]
\label{thm:whatever}
Some witty theorem.
\end{theorem}
% The following outputs "Theorem 1 Whatever".
% I would like "Theorem Whatever".
Consider \fullref{thm:whatever}.
\end{document}
Respuesta2
Los siguientes usoszref
como alternativa acleveref
para crear un nuevopropiedadllamado envname
(similar a lo que proporciona el zref-env
módulo) que almacena \<env>autorefname
o \@currenvir
- el nombre del elemento curr
:envir
\documentclass{memoir}
\usepackage{amsthm,thmtools,zref}
\usepackage{hyperref}% Loads nameref
\makeatletter
\zref@newprop{envname}[??]{%
\expandafter\ifx\csname\@currenvir autorefname\endcsname\relax
\@currenvir
\else
\csname \@currenvir autorefname\endcsname
\fi}%
\AtBeginDocument{
\let\oldlabel\label
\renewcommand{\label}[1]{\zref@labelbyprops{#1}{envname}\oldlabel{#1}}
}
\newcommand{\fullref}[1]{%
\zref@refused{#1}% Mark label as used
\hyperref[#1]{\zref@extract{#1}{envname}\ \nameref*{#1}}}
\makeatother
\declaretheorem{theorem}
\renewcommand{\theoremautorefname}{Theorem}
\begin{document}
\begin{theorem}[Whatever]
\label{thm:whatever}
Some witty theorem.
\end{theorem}
% The following outputs "Theorem Whatever".
Consider \fullref{thm:whatever}.
\end{document}