[texhax] A macro programming question

Wolfgang Schuster schuster.wolfgang at googlemail.com
Sat Apr 10 19:40:52 CEST 2010


Am 10.04.10 18:41, schrieb Vafa Khalighi:
>
> Is not there a way that this \hboxR can accept \bgroup and \egroup? 
> i.e. \hboxR\bgroup This is a test\egroup
\def\beginR{B}
\def\endR  {E}

\def\hboxR{\bgroup\toks0={}\futurelet\next\dohboxR}

\def\dohboxR
   {\ifx\next\bgroup
      \expandafter\dodohboxR
    \else
      \expandafter\nodohboxR
    \fi}

\def\dodohboxR
   
{\hbox\the\toks0\bgroup\beginR\bgroup\aftergroup\endR\aftergroup\egroup\aftergroup\egroup\let\next=}

\def\nodohboxR#1%
   {\toks0=\expandafter{\the\toks0 #1}%
    \futurelet\next\dohboxR}

\hboxR{a}
\hboxR to 4cm{a}
\hboxR spread 1cm{a}

\hboxR\bgroup a\egroup
\hboxR to 4cm\bgroup a\egroup
\hboxR spread 1cm\bgroup a\egroup

\bye

Spaces after the value (e.g. \hboxR to 3cm {...}) are not allowed in 
this solution.

Wolfgang


More information about the texhax mailing list