Quantcast
Viewing all articles
Browse latest Browse all 63

Defining a command with star argument to be used in pdf strings (e.g. via \section)

I want to define a command with an optional star argument and be able to use it inside pdf strings, e.g. via \section. With the MWE below, I get a Token not allowed in a PDF string warning and \foo is just removed.

I can't think of a safe expandable way to replace \@ifstar in order to do this. For my application, it would be okay to default to \s@foo inside a pdf string, but the * should be removed if present.

Is there any way to achieve this?


\documentclass{article}\usepackage{hyperref}\makeatletter  \protected\def\foo{%    \@ifstar\s@foo\@foo  }  \def\@foo#1{one #1 one}  \def\s@foo#1{two #1 two}\makeatother\begin{document}\section{\foo{bar}}\end{document}

Viewing all articles
Browse latest Browse all 63

Trending Articles