Solicite a `\autoref` que muestre el nombre del entorno sin número

Solicite a `\autoref` que muestre el nombre del entorno sin número

Estoy usando la memoirclase y defino teoremas con thmtools. Los teoremas suelen tener un nombre, además de estar numerados. Estoy buscando escribir un \fullrefcomando 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, memoiry cleverefentran en conflicto entre sí. Así que me gustaría arreglármelas sin cleveref.

Parece que debería poder lograr el mismo efecto con autorefsolo. El comando

\newcommand{\fullref}[1]{\hyperref[#1]{\autoref*{#1}\ \nameref*{#1}}}

casihace lo que quiero, excepto que muestra el número del teorema entre Theoremy 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}

<code>cleveref</code> con <code>memorias</code>

Respuesta2

Los siguientes usoszrefcomo alternativa acleverefpara crear un nuevopropiedadllamado envname(similar a lo que proporciona el zref-envmódulo) que almacena \<env>autorefnameo \@currenvir- el nombre del elemento curr:envir

ingrese la descripción de la imagen aquí

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

información relacionada