# autoref names messed up when defining certain ntheorem theoremstyles

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

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

-

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}

-
It works... I actually tried \providecommand* before, but without the star, so that didn't work. Thanks. – einpoklum Jul 31 '11 at 17:45

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.

-
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