[lltx] issue with \texorpdfstring{}

Heiko Oberdiek heiko.oberdiek at googlemail.com
Thu Dec 23 11:37:16 CET 2010


On Thu, Dec 23, 2010 at 10:13:51AM +0100, Pablo Rodríguez wrote:

> \documentclass{article}
> \usepackage[spanish]{babel}
> \usepackage{hyperref}
> \begin{document}
> \section{Ley (\texorpdfstring{\begin{hyphenrules}{ancientgreek}??????????\end{hyphenrules}}{??????????})}
> \end{document}
> 
> which uses \texorpdfstring to enable hyphenation and aviod problems
> with hyperref.
> 
> I must be missing something extremely basic, but I don't know why it
> doesn't work (I get an error: "! Argument of \@sect has an extra
> }.").

\begin and \end are fragile in LaTeX already. Thus you also need
\protect.

You can avoid \texorpdfstring here by using \pdfstringdefDisableCommands:

\pdfstringdefDisableCommands{%
  \def\begin#1{\csname#1\endcsname}%
  \def\end#1{\csname end#1\endcsname}%
  \def\hyphenrules#1{}%
  \def\endhyphenrules{}%
  \def\foreignlanguage#1#2{#2}%
}

In 6.82a hyperref will do this for \begin, \end, and
\foreignlanguage automatically.

Yours sincerely
  Heiko Oberdiek


More information about the lualatex-dev mailing list