
Estou usando a memoir
classe e defino teoremas com thmtools
. Os teoremas geralmente têm um nome, além de serem numerados. Estou tentando escrever um \fullref
comando que produza o nome do ambiente (aqui, Theorem
) junto com seu nome, mas sem seu número. (Este comando deve funcionar para qualquer ambiente para o qual um nome seja definido, por exemplo, via \myenvautorefname
.)
Eu costumava usar o seguinte comando, encontrado aqui no TeX SE:
\newcommand{\fullref}[1]{\hyperref[#1]{\namecref{#1}\ \nameref*{#1}}}
Infelizmente, memoir
e cleveref
conflitam entre si. Então eu gostaria de viver sem cleveref
.
Parece que eu deveria conseguir o mesmo efeito autoref
apenas com. O comando
\newcommand{\fullref}[1]{\hyperref[#1]{\autoref*{#1}\ \nameref*{#1}}}
quasefaz o que eu quero, exceto exibir o número do teorema entre Theorem
e o nome do teorema.
Aqui está um MWE que ilustra o comando acima:
\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}
Desde já, obrigado!
Responder1
Por que não usar 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}
Responder2
Os seguintes usoszref
como uma alternativa paracleveref
para criar um novopropriedadechamado envname
(semelhante ao que é fornecido pelo zref-env
módulo) que armazena ou \<env>autorefname
- \@currenvir
o nome curr
da entidade 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}