I'm not sure whether the order of \texorpdfstring inside headings matters or if some part of the newcommands/NewDocumentCommands are messing with my MWE:

% !TeX program = lualatex


colorlinks=false, %


\setabbreviationstyle[acronym]{long-short} % Stil des Abkürzungen im Text

\newacronym{ac:test}{TEST}{Only an acronym for testing purposes}

\NewDocumentCommand{\GT}{m m}{

\NewDocumentCommand{\TESTGLS}{s m}{%TEST


\chapter{Different Tests}

\gls{ac:test}: \lipsum[1]


\gls{ac:test}: \lipsum[2]


\gls{ac:test}: \lipsum[3]


\gls{ac:test}: \lipsum[4]


\gls{ac:test}: \lipsum[5]


In the first two section headings everything is fine, but in the last two (that contain my own commands) I get a warning Token not allowed in a PDF string (Unicode):(hyperref) removing '\TESTGLS' in both cases. Looking at the log-file unfortunately didn't reveal any further information for me.

  • 1
    If you hide \texorpdfstring inside robust commands (defined e.g. with \NewDocumentCommand) hyperref will never see it and it does nothing. You always need something expandable at the outer level: May 4 at 21:56
  • @UlrikeFischer Is there no chance to have it expand inside these robut commands?
    – Lukas
    May 5 at 5:10

1 Answer 1


A command defined with \NewDocumentCommand is protected and doesn't change inside an \xdef. When writing the bookmarks hyperref will either throw it away or handle it with a definition stored with \pdfstringdefDisableCommands, but it will not look inside such a definition and so every \texorpdfstring there is useless.

If you want it to have some effect the outer definition must be expandable:



 {something complicated \IfBooleanT{#1}{with star and }#2}

\newcommand\TESTbookmarks[1]{simple #1} 

\section{a heading with \TEST*{text}}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.