This is a follow up to this post whose problem statement (roughly): create a macro that saves a macro and options (\includepdf[angle=90, scale=0.85]
), such as to be able to invoke it later (presumably repeatedly). Now I'd like to be able to do the same, but optionally with a star. (\newwatermark*[page=\thepage,angle=45]
). For now, I'm trying to create a function that take as argument a macro and optionally a star, and that dispatches to different implementations whether that star is present or not. The code below compiles forever...
PS : preferably with package expl3
.
\documentclass{article}\usepackage{xparse}\ExplSyntaxOn\cs_new_protected:Npn \__erw_test:w #1 #2 \q_stop{ \token_if_eq_charcode:NNTF *#2{T}{F}}\cs_new_protected:Nn \__erw_test:n{ \__erw_test:w #1 \q_stop \q_stop}\NewDocumentCommand\Foo{s}{ foo\IfBooleanT{#1}{star}}\ExplSyntaxOff\begin{document}\ExplSyntaxOn%\peek_charcode:NTF* { star } { no~star }\__erw_test:n{\Foo}%\__erw_test:n{\Foo*}\ExplSyntaxOff\end{document}