# How to get correct autoref for theorems

I have some own theorem environments. And my theorems are numbered like the chapter. Now I would like to use autoref with that. But it does not work like it is described here (http://www.tug.org/applications/hyperref/manual.html) with aliascnt. So how can I get that?

\documentclass[ngerman,halfparskip,12pt,pointednumbers]{scrreprt}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts,amssymb,amsthm,bbm}
\usepackage{hyperref}
\newtheoremstyle{absatz}
{17pt}{10pt}{}{-1pt}{\scshape\bfseries}{.}{\newline}{}

\theoremstyle{absatz}

\newtheorem{satz}{Satz}[chapter]
\newtheorem*{satz*}{Satz}
\newtheorem{lemma}[satz]{Lemma}
\newtheorem{corollar}[satz]{Korollar}

%\renewcommand*{\theoremautorefname}{Satz}
\begin{document}
\begin{satz}
\label{Satz}
text text theorem
\end{satz}

In \autoref{Satz} we have shown...
\end{document}

-
I tried this with the following example  \begin{satz} \todo{citation needed} \label{satz} theorem text \end{satz} In \autoref{satz} ... And of course this did not work, because of the \todo before the label. Just for anyone to remember, who stumbles upon this topic. (sorry I did not get a code environment working here.) –  pirad Mar 1 '12 at 8:52

\autoref requires the name of the environment in the form \<name>autorefname to work. So, in order to properly "auto reference" your satz theorem, you should use

\newcommand{\satzautorefname}{Satz}


\documentclass[ngerman,halfparskip,12pt,pointednumbers]{scrreprt}
%\usepackage{babel}
%\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts,amssymb,amsthm,bbm}
\usepackage{hyperref}
\newtheoremstyle{absatz}
{17pt}{10pt}{}{-1pt}{\scshape\bfseries}{.}{\newline}{}

\theoremstyle{absatz}

\newtheorem{satz}{Satz}[chapter]
\newtheorem*{satz*}{Satz}
\newtheorem{lemma}[satz]{Lemma}
\newtheorem{corollar}[satz]{Korollar}
\newcommand{\satzautorefname}{Satz}

\begin{document}
\begin{satz}
\label{Satz}
text text theorem
\end{satz}

In \autoref{Satz} we have shown...
\end{document}  ​

-
Thanks that works. And with aliascnt it even works for Lemma and Korollar. –  pirad Mar 1 '12 at 8:35

I like all of my theorems etc numbered in sync with equations. For this I use the following macro to create my theorem-like environments:

% Some trickery to make \NewTheorem{} define theorem like environments
% work correctly with \autoref{}
\usepackage{aliascnt}
\def\NewTheorem#1{%
\newaliascnt{#1}{equation}
\newtheorem{#1}[#1]{#1}
\aliascntresetthe{#1}
\expandafter\def\csname #1autorefname\endcsname{#1}
}


Then I define

\NewTheorem{Theorem}
\NewTheorem{Corollary}


etc and use \begin{Theorem}...\end{Theorem} etc in the text.

Note that the environment name (Theorem, Corollary etc) is the label that is used by \autoref.

-