On Tue, Jun 14, 2011 at 11:48:26PM +0200, Stephan Hennig wrote:

> schrieb Joseph Wright:
> > On 14/06/2011 22:00, Stephan Hennig wrote:
> >> 
> >> 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.
> > 
> > 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.
> 
> OK, thanks!  I'll have a look at how \pdfstringdefDisableCommands can
> help me.  I have already used \texorpdfstring, but having to maintain
> two arguments is no fun.

Example:

\pdfstringdefDisableCommands{%
  \let\MyDocumentCommand\MyExpandableDocumentCommand
} 

Yours sincerely
  Heiko Oberdiek