wspr / herries-press

A collection of LaTeX packages by Peter Wilson
http://wspr.github.com/herries-press/
29 stars 5 forks source link

appendix: \Hy@chapapp uses \appendixname #34

Open moewew opened 5 years ago

moewew commented 5 years ago

Via https://tex.stackexchange.com/q/461125/35864 and ultimately as it turns out a few other questions, most notably https://tex.stackexchange.com/q/67627/35864, https://tex.stackexchange.com/q/58848/35864, https://tex.stackexchange.com/q/41649/35864

The following MWE fails for me (with pdfLaTeX)

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[magyar]{babel}
\usepackage[titletoc]{appendix}
\usepackage{hyperref}

\begin{document}
\tableofcontents

\begin{appendices}
\chapter{test appendix}
\end{appendices}
\end{document}

with many error messages of the form

! Undefined control sequence.
\GenericError  ...                                
                                                    #4  \errhelp \@err@     ...
l.1 ...ggel�k.a.A}{f\374ggel\351k test appendix}{}
                                                  % 1
? 
! Undefined control sequence.
\GenericError  ...                                
                                                  \let \@err@               ...
l.1 ...ggel�k.a.A}{f\374ggel\351k test appendix}{}
                                                  % 1
? 
! Undefined control sequence.
\GenericError  ...                                
                                                  \@empty \def \MessageBreak...
l.1 ...ggel�k.a.A}{f\374ggel\351k test appendix}{}
                                                  % 1
? 

The issue seems to be the use of the localised term \appendixname as anchor in \Hy@chapapp instead of a safe ASCII-only like \Hy@appendixstring.

moewew commented 5 years ago

In case it helps, https://github.com/wspr/herries-press/compare/master...moewew:issue34 contains a possible fix for this issue.

u-fischer commented 2 years ago

Why did the patch change \def to \xdef? Now the setting leaks out of the appendix, see https://tex.stackexchange.com/questions/617916/reference-name-issue-with-multiple-appendices

If I switch back to \def with

\usepackage{etoolbox}
\makeatletter
\patchcmd\@resets@pp{\xdef}{\def}{}{\fail}
\patchcmd\@resets@ppsub{\xdef}{\def}{}{\fail}
\makeatother

The example compiles again.

moewew commented 2 years ago

As detailed in the linked https://tex.stackexchange.com/a/461142/35864 the \xdef came from hyperref's definition of \appendix, but since that is a switch and with appendices we have an environment a local \edef (or possibly only \def - since expansion then happens when the file is written) might make more sense here.