When I use titlesec
, hyperref
, and algorithm2e
together, sections after an \appendix
are not numbered properly.
\documentclass{article}
\usepackage{titlesec}
\usepackage{hyperref}
\usepackage{algorithm2e}
\begin{document}
\section{foo}
\appendix
\section{bar}
\end{document}
Compiling this gives the warning
pdfTeX warning (ext4): destination with the same identifier (name{section.1}) has been already used, duplicate ignored
Sure enough, the .aux file shows
\@writefile{toc}{\contentsline {section}{\numberline {1}foo}{1}{section.1}}
\@writefile{toc}{\contentsline {section}{\numberline {A}bar}{1}{section.1}}
- Removing
titlesec
changes the secondsection.1
toappendix.1
. - Removing
algorithm2e
changes the secondsection.1
tosection.A
. - Removing both changes the second
section.1
toappendix.A
.
Unlike last time, I tried all six permutations of the packages but had no luck.
Can this combination of packages be made to work?
Best Answer
It's always good to load
hyperref
last. (But you're right, that won't solve your problem.) I think the main source of the problem isalgorithm2e
. Based on this discussion (in German) here, it seems that there are a few possible solutions. The simplest two are:Add
after loading
hyperref
.or
add
after loading
algorithm2e
.