I am trying to programme a command in x parse that has one optional argument, but which can behave in three ways in the following situations: a) no argument specified, b) optional argument specifies a specific value (p), c) optional argument specifies a different value (q).
The commands would look as follows:
\command
\command[p]
\command[q]
and would give the result
command
command preface
command q
I have tried to use the star and token arguments instead of the standard optional argument but the documentation is very sparse for the package and I cannot work out, even from looking at examples on this site, how I might achieve the above.
My attempt was as follows:
\documentclass{article}
\usepackage{xparse}
\NewDocumentCommand \command { tp } {%
\IfNoValueTF{#1}{%
command}%
{{\IfBooleanTF{#1}%
{command preface}%
{command #1}%
}}}
\begin{document}
\command
\command[p]
\command[10]
\end{document}
xparse
is meant to grab arguments: further processing of the content is left to 'other code'. What have you tried so far?@
in front of a name to get the user notified …)