3

I want to use the macro \as for abbreviations in my document. However, siunitx interferes with its use in pdf bookmarks. The following MWE produces a document with a section named "foo" in the document, but "as" in the pdf bookmarks.

\documentclass{article}

\usepackage{hyperref}
\usepackage{siunitx}

\begin{document}

\def\as{foo}
\section{\as}

\end{document}

This seems to be due to the fact that siunitx defines \as as a unit shorthand (attosecond) and seems to want to help me use it in pdf bookmarks. However, it fails to detect that I am not using \as inside a unit macro.

  • Is this a bug or just an unfortunate feature?
  • Is there a workaround to avoid this behavior? I did not find anything about removing units in the siunitx documentation.
6
\documentclass{article}

\usepackage{hyperref}
\usepackage{siunitx}
\AtBeginDocument
{\pdfstringdefDisableCommands{\def\as{foo}}}
\begin{document}

\def\as{foo}
\section{\as}

\end{document}

enter image description here

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.