Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}    
share|improve this question
    
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
add comment

2 Answers

up vote 7 down vote accepted

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

enter image description here

\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}  ​
share|improve this answer
1  
Thanks that works. And with aliascnt it even works for Lemma and Korollar. –  pirad Mar 1 '12 at 8:35
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.