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 define a theorem style pretty innocuously, to get things looking a bit more like amsthm theorems. But - my \autoref{}s become messed up with optional arguments of theorem environments.

\documentclass{article}

\usepackage{hyperref}
\usepackage[hyperref]{ntheorem}

\makeatletter
\newtheoremstyle{nicestyle}%
  {\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}
  {\item[\hskip\labelsep {\theorem@headerfont ##1\ ##2}{\normalfont\ (##3)}
   {\theorem@headerfont \theorem@separator}]}
\makeatother

\theoremstyle{nicestyle}
\newtheorem{lemma}{Lemma}[section]

\begin{document}

\begin{lemma}
\label{lem:first}
The quick brown fox jumped over the lazy dog.
\end{lemma}

\begin{lemma}[Apple]
\label{lem:second}
The second brown fox jumped over the second dog.
\end{lemma}

I want to refer to the two lemmata above, and should be getting
``Lemma 0.1'' and ``Lemma 0.2''. But autoref gives me ``Apple 0.1''
and ``Apple 0.2'': \autoref{lem:first} and \autoref{lem:second}.

\end{document}

And the output: output

Am I doing something wrong or is this an ntheorem bug? (using MikTex 2.9).

share|improve this question
add comment

2 Answers 2

up vote 7 down vote accepted

Hyperref mentions something to this effect in the package documentation (p 15). To avoid this, you can 'suggest' what \autoref should use by means of

\theoremstyle{nicestyle}
\newtheorem{lemma}{Lemma}[section]
\providecommand*{\lemmaautorefname}{Lemma}

Forcing \autoref to pick the right name

share|improve this answer
    
It works... I actually tried \providecommand* before, but without the star, so that didn't work. Thanks. –  einpoklum Jul 31 '11 at 17:45
add comment

Load \usepackage[thref,hyperref]{ntheorem} and change the references into \thref{lem:first} and \thref{lem:second}.

\autoref is a hyperref command, so it might well collide with ntheorem's way of communicating information to the second compilation pass via the .aux and .thm files.

The adaptation towards hyperref is a kind of hack, as hyperref forces its definitions at \AtBeginDocument.

share|improve this answer
1  
What's the benefit of using \thref in general? Or rather - where do I read about \thref vs \autoref ? Are they supposed to behave the same (specifically, does \thref create a clickable link in the PDF)? –  einpoklum Sep 20 '11 at 6:30
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.