1

I've been writing a document in portuguese and I've ran across a nasty problem. I've been trying for the past few hours to get hyperref and bookmark to play nice with my labels inside the appendices ambient to no avail. I keep getting weird, incomplete error messages (undefined control sequence) that I just can't seem to solve. I feel like it has something to do with the altered appendix page name, but I'm not so sure about that one.

Below, you'll find a non-working example that outputs the exact same error messages I'm getting on my main .tex file. I'd appreciate any help you can give me! I just can't seem to solve this one on my own.

\documentclass{article}
\usepackage[portuguese]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[unicode]{hyperref}
\usepackage{bookmark}
\usepackage{fancyvrb}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{float}
\usepackage[toc,page]{appendix}
\usepackage[margin=1.3in]{geometry}

\addto{\captionsportuguese}{\renewcommand{\appendixpagename}{Apêndice}}
\epstopdfsetup{outdir=./}

\begin{document}
\section{Test}
\subsection{SubTest}

Ref'ing an appendix \ref{figure_flowchart1}; \ref{figure_flowchart2}.

\begin{appendices}
\section{Diagrama 1 - Atualização de Paridade, 1 Bloco de Dados}\label{figure_flowchart1}
\begin{figure}[H]
\centering
\includegraphics[scale=0.5]{Flowchart1.eps}
\end{figure}

\section{Diagrama 2 - Atualização de Paridade, >1 Bloco de Dados}\label{figure_flowchart2}
\begin{figure}[H]
\centering
\includegraphics[scale=0.5]{Flowchart2.eps}
\end{figure}
\end{appendices}

\end{document}
Lopson
  • 125

1 Answers1

2

It is a bug in package appendix: Package hyperref uses \Hy@chapapp inside destination names at the place of the counter name. Then sections (class article) or chapters (class report or book) use the string "appendix" rather than "section"/"chapter" as counter name part of destinations in the appendix. Package appendix redefines \Hy@chapapp as \appendixname in the appendix. \appendixname is localized as "Apêndice" and the third UTF-8 letter causes the trouble. Using the original ASCII string "appendix" is much more robust. The name does not appear anywhere on the page. (Counter names "chapter" or "section" aren't localized either.)

The following example patches \Hy@chapapp to be "appendix" in the appendix:

\documentclass{article}
\usepackage[portuguese]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[unicode]{hyperref}
\usepackage{bookmark}
\usepackage[toc,page]{appendix}

\usepackage{etoolbox}
\makeatletter
\patchcmd\@resets@pp{%
  \def\Hy@chapapp{\appendixname}%
}{%
  \def\Hy@chapapp{appendix}%
}{}{\errmessage{Cannot patch \string\@resets@pp}}
\patchcmd\@resets@ppsub{%
  \def\Hy@chapapp{\appendixname}%
}{%
  \def\Hy@chapapp{appendix}%
}{}{\errmessage{Cannot patch \string\@resets@pp}}
\makeatother

\addto{\captionsportuguese}{\renewcommand{\appendixpagename}{Apêndice}}

\begin{document}
\section{Test}
\subsection{SubTest}

Ref'ing an appendix \ref{figure_flowchart1}; \ref{figure_flowchart2}.

\begin{appendices}
\section{Diagrama 1 - Atualização de Paridade, 1 Bloco de Dados}
\label{figure_flowchart1}

\section{Diagrama 2 - Atualização de Paridade, >1 Bloco de Dados}
\label{figure_flowchart2}

\end{appendices}

\end{document}
Heiko Oberdiek
  • 271,626
  • Isn't this the same as http://tex.stackexchange.com/questions/67627/conflict-between-babel-hyperref-and-appendix-package? And also http://tex.stackexchange.com/questions/41649/how-to-make-appendix-and-hyperref-packages-work-together-with-cyrillic-non-asci – egreg Jul 06 '14 at 18:12
  • Which one should be chosen as duplicate? – egreg Jul 06 '14 at 18:30
  • I looked at those threads before posting this question, since none of them solved my problem. And to be honest, neither did this answer do it! :( I guess MikTex doesn't like me. Thanks for the quick answer nonetheless.

    Also, yanking out the appendix package and using the \appendix command does the job. I just tested it, don't know why I hadn't thought of that before.

    – Lopson Jul 06 '14 at 20:09
  • @Lopson: "doesn't work" is not much helpful. What's the problem, error? – Heiko Oberdiek Jul 06 '14 at 20:12
  • Blimey, it seems all I had to do to get your code snippet to work was to remove all temporary files! Works fine now, thanks a bunch! – Lopson Jul 06 '14 at 21:35