[texhax] A macro programming question

Vafa Khalighi vafakh84 at gmail.com
Mon Apr 12 17:55:44 CEST 2010


On Tue, Apr 13, 2010 at 12:35 AM, Donald Arseneau <asnd at triumf.ca> wrote:

> Vafa Khalighi <vafakh84 at gmail.com> writes:
>
> > > To add to the other solutions... this one only defines one
> > > macro and works with both { } and \bgroup \egroup...
> > >
> > > \def\hboxR{\begingroup
> > >  \everyhbox{%
> > >   \aftergroup\endgroup
> > >   \everyhbox{}%
> > >    \beginR
> > >   \bgroup
> > >   \aftergroup\endR
> > >   \aftergroup\egroup
> > >  }\hbox}
> > >
> > >
> > \setbox0=\hboxR{This is a test.}
> > \box0
> >
> > Would not work here, because TeX expects a box. How can one fix this?
>
> Indeed a big shortcoming.
>
> One solution is to use another layer of \hbox{ } instead of
> \begingroup \endgroup
>
>  \def\hboxR{\hbox\bgroup
>  \everyhbox{%
>   \aftergroup\egroup
>    \everyhbox{}%
>    \beginR
>   \bgroup
>   \aftergroup\endR
>   \aftergroup\egroup
>  }\hbox}
>
> There is still the problem that \hboxR is an expandable macro
> instead of a primitive.  Since \beginR indicates that you
> have etex enabled, use
>
> \protected\def\hboxR...
>
>
>
Thanks Donald and all who replied. I have been learning a lot from the
answers you all gave.

Thanks again

-- 
Best wishes,
Vafa Khalighi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20100413/24dde091/attachment.html>


More information about the texhax mailing list