Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem with hyperref and language switch in optional arguments

6 views
Skip to first unread message

Uwe Stöhr

unread,
Feb 10, 2012, 10:57:48 PM2/10/12
to
I have the following problem that this won't compile:

\documentclass[ngerman,english]{report}
\usepackage{babel}
\usepackage{hyperref}

\begin{document}
hello
\chapter[\selectlanguage{ngerman}Fehler]{Fehler}
\selectlanguage{english}
error

\end{document}

But if I remove the hyperref call, it compiles fine.
I know that changing the language withing an optional argument is no good idea, the question is
nevertheless why it fails when hyperref comes into play.

Is this a bug in hyperref?

thanks and regards
Uwe

Heiko Oberdiek

unread,
Feb 11, 2012, 12:00:10 AM2/11/12
to
Uwe Stöhr <uwes...@web.de> wrote:

> \documentclass[ngerman,english]{report}
> \usepackage{babel}
> \usepackage{hyperref}
>
> \begin{document}
> hello
> \chapter[\selectlanguage{ngerman}Fehler]{Fehler}
> \selectlanguage{english}
> error
>
> \end{document}
>
> But if I remove the hyperref call, it compiles fine.
> I know that changing the language withing an optional argument is no good idea, the question is
> nevertheless why it fails when hyperref comes into play.

\selectlanguage breaks in the bookmarks.

\pdfstringdefDisableCommands{%
\renewcommand*{\selectlanguage}[1]{}%
}

Why don't you use \foreignlanguage?

--
Heiko Oberdiek

Uwe Stöhr

unread,
Feb 11, 2012, 9:20:30 PM2/11/12
to
Am 11.02.2012 06:00, schrieb Heiko Oberdiek:

> \selectlanguage breaks in the bookmarks.
>
> \pdfstringdefDisableCommands{%
> \renewcommand*{\selectlanguage}[1]{}%
> }
>
> Why don't you use \foreignlanguage?

Good question. \foreignlanguage works and I will use this now.

(I also think that using a different language in a short title than in the full section heading but
a got this from a LyX user so people use this.)

thanks and regards
Uwe
0 new messages