[texhax] grouping

Ross Moore ross at ics.mq.edu.au
Mon Mar 28 06:07:13 CEST 2005


Hello Moheb,

On 28/03/2005, at 12:27 PM, moheb missaghi wrote:

> Hi,
>  
> I am reading tabularx.sty as a means to learn how to write packages. 
> Not that it really matters for what I want to do but as a matter of 
> curiosity I don't understand the grouping opened by:
>  
>   {\ifnum0=`}\fi
>  
> in tabularx (tabularx.sty) and apparently closes by:
>  
> \ifnum0=`{\fi}%
>  
> in TX at endtabularx. How can a grouping go across 2 different macros and 
> what does it mean?

A grouping can certainly go across different macros.

Most LaTeX environments start with something that puts a
   \begingroup
and finishes with something else that puts the corresponding
   \endgroup

You can also use  \bgroup  and  \egroup  to do the same
kind of thing.

It's very common to use these, as when the grouping closes,
then the expansion values of any temporary macros revert
to what they were before entering the grouping.
This is important for scoping the values of variables and
pointers, and for memory-management.


This looks to me like a fancy trick to include a {
>   {\ifnum0=`}\fi

while keeping {..} balanced for an editor, while
also keeping the \ifnum ... balanced with a \fi .

That is, the group opens, but \ifnum returns \iffalse
so the grouping does not close right away.

Rather, when later we encounter the corresponding
> \ifnum0=`{\fi}%

then the closing bracket is found.

This could probably have been done much more easily using
first a  \bgroup ,  then close it later with \egroup .


However, this package was generated using  docstrip .
I've seen this style used there quite a lot.
Perhaps it meshes better with the need to use the
same source document for multiple purposes.
So there could be a good reason for this apparently
cryptic way to start and finish groupings.


See if you can find  tabularx.dtx  on your system,
or get it from  CTAN.
Maybe the context there will shed further light
on this question, and help you to learn how these
packages are constructed.



>  
> Thx,

Hope this helps,

	Ross Moore


>  
> Moheb
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> TeX newsgroup: http://groups.google.com/groups?group=comp.text.tex
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
>
> Automated subscription management: 
> http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org
------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia                                  fax: +61 +2 9850 8114
------------------------------------------------------------------------



More information about the texhax mailing list