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.

Here is a minimal example:

\documentclass{amsart}

\usepackage{amsthm}
\usepackage[pdftex]{hyperref}

\newtheoremstyle{myexercise}{\baselineskip}{\baselineskip}{}{}{\bfseries}{.}{ }{\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}}
\newtheoremstyle{mypart}{\baselineskip}{\baselineskip}{}{}{\bfseries}{}{\newline}{\thmname{#1}\thmnumber{ #2}\thmnote{ -- #3}}

\theoremstyle{myexercise}
\newtheorem{Exo}{Exercise}
\theoremstyle{mypart}
\newtheorem{Part}{Part}[Exo]
\renewcommand*\thePart{\Roman{Part}}

\begin{document}
\begin{Exo}[A cool exercise]
\begin{Part}
\label{p:ex1:I}
Prove that $1=0$.
\end{Part}
\begin{Part}
Deduce from Part~\ref{p:ex1:I} that this exercise is wrong.
\end{Part}
\end{Exo}

\begin{Exo}
\begin{Part}
Let $a=b$. Deduce that $0=0$.
\end{Part}
\begin{Part}
Let $a=42$. For what values of $b$ do we have $a=b$?
\end{Part}
\end{Exo}
\end{document}

The warning I get is the following:

pdf TeX warning (ext4): destination with the same identifier (name{Part.1.1}) has b een already used, duplicate ignored

\AtBegShi@Output ...ipout \box \AtBeginShipoutBox \fi \fi l.35 \end{document} pdfTeX warning (ext4): destination with the same identifier (name{Part.2.1}) has been already used, duplicate ignored

\AtBegShi@Output ...ipout \box \AtBeginShipoutBox \fi \fi l.35 \end{document} ] (./TestHyperref.aux) )

This looks like a strange behavior to me. Or have I done anything wrong?

Besides, the error completely disappears if I use, e.g., enumerates inside the Part environment, as in

...
\begin{Part}
\begin{enumerate}
\item Prove that $1=0$.
\end{enumerate}
\end{Part}
...

Also, there's no error if I remove the hyperref package. Unfortunately, I need to use hyperref.

Any idea?

share|improve this question
    
Note that this is not an error, only a warning. Actually, as long as you have only one reference to a part, there won't be a problem. Only if you have a reference to e.g. Part I in Exercise 1 and Part I in Exercise 2, the hyperlinks that hyperref creates will point to the same target. –  Michael Ummels Mar 10 '11 at 14:44
    
@Michael Indeed, and the weirdest is that the warnings disappear altogether when I put an enumerate environment inside the Part (which is what I almost always do, since there are usually numbered questions in Parts). –  gniourf_gniourf Mar 10 '11 at 14:52

1 Answer 1

It's possible to use nested theorems with article.cls and ntheorem, now the problem seems to come from a conflict between amsart and hyperref. ntheorem has an option to avoid compatibility with hyperref.

\documentclass{article}
\usepackage[pdftex]{hyperref}
\usepackage[hyperref]{ntheorem}  

\newtheorem{Exo}{Exercise}
\newtheorem{Part}{Part}[Exo]
\renewcommand*\thePart{\Roman{Part}} 

\begin{document} 
\begin{Exo}[A cool exercise]
\begin{Part}
\label{p:ex1:I}
Prove that $1=0$.
\end{Part}
\begin{Part}
Deduce from Part~\ref{p:ex1:I} that this exercise is wrong.
\end{Part}
\end{Exo}

\begin{Exo}
\begin{Part}
Let $a=b$. Deduce that $0=0$.
\end{Part}
\begin{Part}
Let $a=42$. For what values of $b$ do we have $a=b$?
\end{Part}
\end{Exo} 
\end{document}

The problem seems to be between amsartand hyperref.

share|improve this answer
    
Thanks for your answer. I'm actually using (a modification of) the amsbook class. I don't quite understand why nesting several theorem environments should be a problem, since these environments are (supposedly from what I read from the LaTeX Companion) lists... –  gniourf_gniourf Mar 10 '11 at 14:34
    
@gniourf-gniourf: Yes it's possible to nested theorem environments. I try my example with amsart and I get the chaos. So I'm perplex, I don't know amsart.cls and I suppose this class defines some theorem environments. I try my example with scrartcl.cls and it's fine –  Alain Matthes Mar 10 '11 at 14:51
    
@gniourf-gniourf: In amsart.clsyou can find this : \renewcommand{\newtheorem} .... The class modifies newtheorem and perhaps` there is a little conflict between the class and hyperref. It's only a warning but it would be good to know why ! –  Alain Matthes Mar 10 '11 at 14:59

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.