[texhax] Delimited arguments and ProvidesFile macro in hyphen.cfg

Doug McKenna doug at mathemaesthetics.com
Tue Jan 3 02:13:30 CET 2012


This is a basic TeX macro syntax question.  I think, anyway.

I've been trying to wrap my head around (some of) the innards of LaTeX, 
by tracing through little parts of its source code in "latex.ltx" to see 
what happens (by saying "tex -ini latex.ltx" while in the directory 
"./texmf-dist/tex/latex/base", after unpacking the ".ins" install file to 
create "latex.ltx").

Towards the end of LaTeX's compilation, it processes a file "hyphen.cfg", 
a copy of which I tweeked with tracing commands and placed in the same 
directory.  I know it's the file being processed, because the log file 
contains the traces of the code I tweeked.

The first thing that happens in that file is the macro \ProvidesFile is 
(re)defined as follows:

\def\ProvidesFile#1[#2 #3 #4]{\toks 8{Babel <#3> and hyphenation patterns 
for }\b
bl at tempa #1[#2 #3 #4]\let \ProvidesFile \bbl at tempa }

The definition doesn't matter; what I'm focused on is how it's collecting 
its 4 delimited arguments, a few lines later when the macro is invoked.

When I trace this macro's execution, the output TeX creates begins:

\ProvidesFile #1[#2 #3 #4]->\toks 8{Babel <#3> and hyphenation patterns 
for }\b
bl at tempa #1[#2 #3 #4]\let \ProvidesFile \bbl at tempa 
#1<-{hyphen.cfg} 
#2<-2008/07/06
#3<-v3.8l
#4<-Babel language switching mechanism
{\toks}
etc.

My question is, why does the argument token list for parameter #1 include 
the open and closed braces (followed by a space)?  I thought TeX stripped 
the outermost set of braces during argument collection.

The reason I'm confused is because if I trace the following simple test 
macro with parallel argument delimiter structure

{
	\def\tester#1[#2 #3 #4]{}
	\tracingcommands=3
	\tracingmacros=3
	\tester{sweet}[babel onion tears]%
}

during a normal run of TeX (using the LaTeX format), the log file contains

\tester #1[#2 #3 #4]->
#1<-sweet
#2<-babel
#3<-onion
#4<-tears

and the first argument has had its outermost braces stripped, as I 
expected.

How can both traces be correct?  I'm clearly missing something about 
delimited macro arguments, or about some secret thing LaTeX's code does, 
or both.

Thanks in advance for any illumination.


Doug McKenna



More information about the texhax mailing list