Nested acronyms in section titles with hyperref and pdflatex (2.4a)

Issue #69 resolved
Joshua A. Bockenek
created an issue

In 2.4, I am able to place \ac{} in a section title with the short/long forms using another acronym internally with no issues, but in 2.4a I am getting a warning that \acpdfstring cannot be used in PDF bookmarks and the bookmark falls back to the acronym key. e.g.

\documentclass{article}

\usepackage{acro}
\usepackage{hyperref}

\DeclareAcronym{a}{short=A, long=alpha}
\DeclareAcronym{b}{
  short=B\acs*{a},
  long=beta \acl*{a},
  pdfstring=B\acpdfstring{a}
}

\begin{document}
\section{Some \ac{b}}
\end{document}

Results in

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing `\acpdfstring' on input line 14.

Comments (9)

  1. Clemens Niederberger repo owner

    I know what the problem is:

    \documentclass{article}
    
    \usepackage{acro}
    \usepackage{hyperref}
    
    \DeclareAcronym{a}{
      short = A ,
      long = alpha
    }
    \DeclareAcronym{b}{
      short = B\acs*{a} ,
      long = beta \acl*{a} ,
      pdfstring = B\acpdfstring{a}
    }
    
    \begin{document}
    \section{Some \ac{a} \ac{b} \acpdfstring{a}}
    
    \edef\foo{\acpdfstring{a}}\show\foo
    % > \foo=macro:
    % ->A.
    
    \edef\foo{\acpdfstring{b}}\show\foo
    % > \foo=macro:
    % ->B\acpdfstring {a}.
    
    \end{document}
    

    but I don't know if there is a way around it. What would be needed is a property pdfstringx which expands its argument before saving.

  2. Clemens Niederberger repo owner

    I'll probably change acro's behavior such that it expands the pdfstring before saving it. While generally user input never should be expanded this case should be safe as PDF strings need to be expandable anyway.

  3. Joshua A. Bockenek reporter

    That makes sense. I'm still not sure why I was able to get it to work with 2.4; it may be that the editor I use (Kile) or the tools it calls was doing something that fully expanded section titles before they were used in the bookmarks.

  4. Clemens Niederberger repo owner

    That's not possible. Everything the editor does is a tool for writing the file. The compilation process may be started by the editor but the program doing the actual compilation – pdflatex – is independent from the editor!

  5. Joshua A. Bockenek reporter

    Then it was something in the pdflatex/toolchain configuration. I suppose it will remain a mystery as I am not that interested in figuring out why it actually worked at one point.

  6. Log in to comment