# acro: show long acronym name in PDF bookmark

I am using the package acro. I have the following acronym:

\DeclareAcronym{SDP}{
short = SDP,
long  = Sequential Decision Process,
long-plural-form = Sequential Decision Processes,
class = abbrev
}


And then I have the section titles:

\section{\aclp{SDP}}
\section{\acsp{SDP}}


Which correctly prints "Sequential Decision Processes" and "SDPs" in the PDF. However, the PDF bookmarks for the sections both say "SDPs".

In the documentation, it says you can specify the property pdfstring to set what will be printed in the PDF bookmarks. But that gives no options for long and short forms. How can I change the PDF bookmark depending on what the section title is?

• If I can use the long-form code manually where it is needed, either thing works fine. I'll also file a feature request. I can wait a few days for a solution, that is fine. Thank you! – rhaps0dy Jun 11 '16 at 15:05

This should work:

\documentclass{article}
\usepackage{acro}

\ExplSyntaxOn
\cs_new:Npn \acro_expandable_long:n #1
{ \prop_item:Nn \l__acro_long_prop {#1} }

\cs_new:Npn \acro_expandable_long_plural:n #1
{
\bool_if:nTF
{ \prop_item:Nn \l__acro_long_plural_form_prop {#1} }
{ \prop_item:Nn \l__acro_long_plural_prop {#1} }
{
\prop_item:Nn \l__acro_long_prop {#1}
\prop_item:Nn \l__acro_long_plural_prop {#1}
}
}

\cs_new:Npn \acro_pdf_string_long:n #1
{
\acro_if_star_gobble:nTF {#1}
{ \acro_expandable_long:n }
{ \acro_expandable_long:n {#1} }
}

\cs_new:Npn \acro_pdf_string_long_plural:n #1
{
\acro_if_star_gobble:nTF {#1}
{ \acro_expandable_long_plural:n }
{ \acro_expandable_long_plural:n {#1} }
}

\AtBeginDocument
{
\pdfstringdefDisableCommands
{
\cs_set_eq:NN \acl  \acro_pdf_string_long:n
\cs_set_eq:NN \aclp \acro_pdf_string_long_plural:n
}
}
\ExplSyntaxOff

\usepackage{hyperref}

\DeclareAcronym{SDP}{
short = SDP,
long  = Sequential Decision Process,
long-plural-form = Sequential Decision Processes
}

\DeclareAcronym{CD}{
short = CD,
long  = Compact Disc
}

\begin{document}

\section{\acs{CD}, \acs{SDP}}
\section{\acsp{CD}, \acsp{SDP}}
\section{\acl{CD}, \acl{SDP}}
\section{\aclp{CD}, \aclp{SDP}}

\end{document}


Until now the decision that acro only supports the short form in bookmarks is deliberate – I didn't think long forms were necessary there as bookmarks only serve a limited purpose: linking to the “real” headings where the acronyms are printed as specified. (And at least on my system the bookmarks are truncated most of the time anyway…)

I'll see if I add a more thorough support to the next version.

• "I didn't think long forms where necessary there" Well, it is possible to write out the long version in the section title, there is not that much section title text. Maybe I should have just done that, but I got into the habit of just using \ac.* for everything. This will be very handy, thank you! – rhaps0dy Jun 12 '16 at 11:04
• @rhaps0dy Without these modifications the long form still was there in the “real” titles – they were only replaced by the short forms in the bookmarks. And those never get printed. – clemens Jun 12 '16 at 11:12