I understand that it's possible to have \autoref generate references like Theorem 12, or Thm. 12, etc. where the label is always the same. Is there any way to have a short and long version of autoref? Sometimes I'll be referencing a theorem in equations, and I don't want Proposition 12 or something, but an abbreviation. In the main text, I will always want the long form. Is there a pain-free way of doing this?
2 Answers
Instead of using \autoref
, I suggest you also load the cleveref
package and then assign the abbreviated labels to \cref
(via a \crefname
directive) and the non-abbreviated labels to \Cref
(via a \Crefname
directive).
\documentclass{article}
\usepackage{ntheorem}
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink]{cleveref} % make look of \cref emulate that of \autoref
\newtheorem{prop}{Proposition}
\crefname{prop}{Prop.}{Props.} % abbreviated labels
\Crefname{prop}{Proposition}{Propositions} % non-abbreviated labels
\begin{document}
\begin{prop} \label{prop:hello}
Hello.
\end{prop}
\cref{prop:hello}, \Cref{prop:hello}
\end{document}
The following example defines a macro \shortautoref
, which redefines the names for \autoref
. As example, a section reference is used. Just extend the list of redefinitions to your needs.
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\newcommand*{\shortautoref}[1]{%
\begingroup
\def\sectionautorefname{sec.}%
\autoref{#1}%
\endgroup
}
\begin{document}
\section{First section}
\label{sec:first}
Autoref: \autoref{sec:first}\\
Short autoref: \shortautoref{sec:first}
\end{document}