LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Joseph Wright <[log in to unmask]>
Tue, 14 Jun 2011 22:22:28 +0100
text/plain (49 lines)
On 14/06/2011 22:00, Stephan Hennig wrote:
> Hi,
> xparse's \NewDocumentCommand doesn't seem to play well with hyperref
> bookmarks.  In this code
> \listfiles
> \documentclass{article}
> \usepackage{xparse}
> \usepackage{hyperref}
> \begin{document}
> \NewDocumentCommand{\fooa}{}{FooA}
> \DeclareExpandableDocumentCommand{\foob}{m}{FooB}
> \section{aaa \fooa\ bbb \foob{} ccc}
> \end{document}
> text from macro \fooa doesn't show up in the bookmark.  Fortunately, it
> works at least for macro \foob.
> Is that expected behaviour?  Would it be possible to make
> \NewDocumentCommand macros work with hyperref bookmarks?  I'd prefer
> using \NewDocumentCommand macros because of the mandatory argument of
> \DeclareExpandableDocumentCommand macros which I don't need in my context.
> Best regards,
> Stephan Hennig

Hello Stephan,

That is not trivial in general because you need to know what definition
to use in an expansion context (arguments or not). That can only really
be done by a programmer, not an automated system. For example, in
siunitx I do provide appropriate 'shortcut' definitions and hook them
into hyperref using \pdfstringdefDisableCommands. Doing that means
making some pretty careful judgements on what should happen in
bookmarks: many things simply do not make sense there.

In the case case you mention, I'm not sure why you have used


rather than


which works fine.
Joseph Wright