[texhax] Building a command like this: \newcommand*[ ]{ }
Philip G. Ratcliffe
philip.ratcliffe at uninsubria.it
Wed Jul 4 14:31:43 CEST 2007
> Thanks. Here what I've tried to make:
>
> \def\hola{\@ifnextchar*
> {\@ifnextchar[{\threea}{\twoa}}
> {\onea}}
> \def\threea*[#1]#2{#1\quad{\itshape#2}}
> \def\twoa*#1{{\bfseries#1}\quad{\sffamily#1}}
> \def\onea#1{{\itshape#1}}
>
> for obtaining the following 3 cases:
> \hola*[ ]{ }
> \hola*{ }
> \hola{ }
>
> But the first doesn't work, I don't know why.
>
> For example:
> \hola*[Hugo]{E}
> \hola*{Hugo E}
> \hola{Hugo E}
I think this does what you want (though it could probably be written
better):
\def\hola{\@ifstar\holastar\onea}
\def\holastar{\@ifnextchar[\threea\twoa}
\def\threea[#1]#2{#1\quad{\itshape#2}}
\def\twoa#1{{\bfseries#1}\quad{\sffamily#1}}
\def\onea#1{{\itshape#1}}
You were warned.
Cheers, Phil
P.S. A lot of us prefer UNformatted postings.
More information about the texhax
mailing list