Received: by nummer-3.proteosys id <01C19443.45C3478C@nummer-3.proteosys>; Thu, 3 Jan 2002 11:41:59 +0100 MIME-Version: 1.0 x-vm-v5-data: ([nil nil nil nil nil nil nil t nil][nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil]) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C19443.45C3478C" X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message Subject: beyond fragility Date: Fri, 30 Aug 1991 01:00:00 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: From: Sender: "LaTeX-L Mailing list" To: "Rainer M. Schoepf" Reply-To: "LaTeX-L Mailing list" Status: R X-Status: X-Keywords: X-UID: 368 This is a multi-part message in MIME format. ------_=_NextPart_001_01C19443.45C3478C Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Yo! In the last couple of weeks I've been working hard on finishing my book 'TeX by Topic, a TeXnician's Reference'. Since publication is drawing quite near, this was mainly implementing the style (for which Addison-Wesley generously offered some money so that I could hire a designer. Needless to say that the designer is again much better than anything that I could come up with myself. Or than the Addison-Wesley house style, for that matter!), and since I use my own macro package, this meant extensive alterations to even the most basic macros. I think it is converging to something that will be able to implement rather widely different designs. Anyhow, one of the things that I had to tackle was the eternal problem of how to handle heading texts. Fragile commands and such. I'm sure you all know all about it. I would like to show you what I did. First a word about my `Lollipop' format. This format (my article in the Cork proceedings explains it better than I'm going to do here) is a sort of programming language implemented in TeX. There, I cannot show you many complete macros: most of them are defined dynamically. For instance, here is how the macro \point (roughly: \section) in my book is defined: \DefineHeading:point whitebefore:{24pt minus 6pt} whiteafter:{12pt minus 4pt} counter:1 block:start Pointsize:12 SansSerif Style:bold block:start subjectCounter . pointCounter stickout:left=3Dmargin TITLE block:stop label:start command:subjectCounter literal:. command:pointCounter label:stop external:contents title external:stop Stop \GoverningCounter:point=3Dsubject The line 'external' tells the format that the 'title' is to be written to the file 'contents' which has been defined by the user as \DefineExternalFile:contents=3Dtoc Somewhere else the user can specify how exactly the table of contents is to be formatted. To business! The heading macros (or almost any macro, for that matter) can generate a call: \@extern{extension}{object}{counter}title\e@extern The \@extern call writes to the aux file: \write@to@external{extension}{object}{counter}{page}{tekst}\ew@extern as follows: \noeol \newtoks\ext@text@toks \def\x@extern#1#2#3#4\e@extern {\begingroup\normalesc \Tmessage{Write to aux `#2' for `\csname#1@name\endcsname'} \ext@text@toks{#4} \edef\cs@e{\write\aux@file {\string\write@to@external {#1}{#2}{#3} {\counter@@repr{Page} {\csarg\number{\counter@name{Page}}}} = \nxp\string@um@up\the\ext@text@toks\nxp\@bean\@space }}\cs@e \write\aux@file{\string\ew@extern} \endgroup} \normaleol \NewDummy{@roy}\NewDummy{@bean} \def\string@um@up#1 {\string@these@up#1\@roy\string@um@up} \def\string@these@up#1{\ifx#1\@bean\expandafter\take@two \else\ifx#1\@roy\@space \else\string#1\ifcat\nxp#1\relax\@space\fi \xp\xp\xp\string@these@up\fi\fi} Thatis: the title is put in a token list to prevent it >from expansion, and it's padded with \string@um@up...\@bean\@space Trick: this will \string the whole title when the write takes place, so that again there is no expansion. Trick$^2$: you don't want to lose spaces so the title is first split in words, then in tokens. Now the .aux file that a call to \write@to@external; when the aux file is loaded at the end of the job (I'm doing this the same way that LaTeX works), it gets executed: \def\write@to@external#1#2#3#4#5\ew@extern {\csname if@#1open\endcsname \Tmessage{Write `#2' to `\csname##1@name\endcsname'} \ext@text@toks{#5} \immediate\write\csname#1@file\endcsname {\csnaam{#2}{#3}{#4}\the\ext@text@toks\string\par} \else \Tmessage{Skipped `#2' for `\csname#1@name\endcsname'} \fi} Again, this first puts the title in a token list, and then writes it out. Summarizing: - no attempt to allow category code changes in the title - disallow all expansion in the title by applying \string to it. Victor Eijkhout Center for Supercomputing Research and Development University of Illinois at Urbana-Champaign 305 Talbot Laboratory phone: +1 217 244-0047 (office) 104 South Wright Street +1 217 356-0876 (home) Urbana, Illinois 61801-2932, USA fax: +1 217 244-1351 home: 2503 W. Springfield Av, Apt. K-4, Champaign 61821, USA ------_=_NextPart_001_01C19443.45C3478C Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable beyond fragility

Yo!

In the last couple of weeks I've been working = hard
on finishing my book 'TeX by Topic, a TeXnician's = Reference'.
Since publication is drawing quite near, this was = mainly
implementing the style (for which Addison-Wesley = generously
offered some money so that I could hire a designer. = Needless
to say that the designer is again much better than = anything
that I could come up with myself. Or than the = Addison-Wesley
house style, for that matter!), and since I use my = own
macro package, this meant extensive alterations to = even
the most basic macros. I think it is converging to = something
that will be able to implement rather widely = different
designs.

Anyhow, one of the things that I had to tackle was the = eternal
problem of how to handle heading texts. Fragile = commands and such.
I'm sure you all know all about it. I would like to = show you what I did.

First a word about my `Lollipop' format. This format = (my article
in the Cork proceedings explains it better than I'm = going to do
here) is a sort of programming language implemented = in TeX.
There, I cannot show you many complete macros: most = of them are
defined dynamically.
For instance, here is how the macro \point (roughly: = \section)
in my book is defined:
\DefineHeading:point whitebefore:{24pt minus = 6pt}
    whiteafter:{12pt minus 4pt}
    counter:1
    block:start Pointsize:12 SansSerif = Style:bold
        = block:start subjectCounter . pointCounter stickout:left=3Dmargin
        TITLE = block:stop
    label:start command:subjectCounter = literal:.
        = command:pointCounter label:stop
    external:contents title = external:stop
    Stop
\GoverningCounter:point=3Dsubject

The line 'external' tells the format that the 'title' = is to be written
to the file 'contents' which has been defined by the = user as
\DefineExternalFile:contents=3Dtoc
Somewhere else the user can specify how exactly the = table of
contents is to be formatted.

To business!
The heading macros (or almost any macro, for that = matter)
can generate a call:
  = \@extern{extension}{object}{counter}title\e@extern

The \@extern call writes to the aux file:
  = \write@to@external{extension}{object}{counter}{page}{tekst}\ew@extern
as follows:
\noeol
\newtoks\ext@text@toks
\def\x@extern#1#2#3#4\e@extern
   {\begingroup\normalesc
     \Tmessage{Write to aux `#2' = for `\csname#1@name\endcsname'}
     \ext@text@toks{#4}
     = \edef\cs@e{\write\aux@file
          &nbs= p;         = {\string\write@to@external
          &nbs= p;           = {#1}{#2}{#3}
          &nbs= p;           = {\counter@@repr{Page}
          &nbs= p;            = ;   {\csarg\number{\counter@name{Page}}}}
          &nbs= p;           = \nxp\string@um@up\the\ext@text@toks\nxp\@bean\@space
          &nbs= p;    }}\cs@e
     = \write\aux@file{\string\ew@extern}
    \endgroup}
\normaleol
\NewDummy{@roy}\NewDummy{@bean}
\def\string@um@up#1 = {\string@these@up#1\@roy\string@um@up}
\def\string@these@up#1{\ifx#1\@bean\expandafter\take@two
    \else\ifx#1\@roy\@space
         = \else\string#1\ifcat\nxp#1\relax\@space\fi
          &nbs= p;   \xp\xp\xp\string@these@up\fi\fi}

Thatis: the title is put in a token list to prevent = it
>from expansion, and it's padded with = \string@um@up...\@bean\@space
Trick: this will \string the whole title when the = write
takes place, so that again there is no = expansion.
Trick$^2$: you don't want to lose spaces so the = title
is first split in words, then in tokens.

Now the .aux file that a call to = \write@to@external;
when the aux file is loaded at the end of the job = (I'm
doing this the same way that LaTeX works), it gets = executed:
\def\write@to@external#1#2#3#4#5\ew@extern
       {\csname = if@#1open\endcsname
          &nbs= p; \Tmessage{Write `#2' to `\csname##1@name\endcsname'}
          &nbs= p; \ext@text@toks{#5}
          &nbs= p; \immediate\write\csname#1@file\endcsname
          &nbs= p;      = {\csnaam{#2}{#3}{#4}\the\ext@text@toks\string\par}
        = \else
          &nbs= p; \Tmessage{Skipped `#2' for `\csname#1@name\endcsname'}
        = \fi}
Again, this first puts the title in a token list, and = then
writes it out.

Summarizing:
- no attempt to allow category code changes in the = title
- disallow all expansion in the title by applying = \string to it.

Victor Eijkhout
 Center for Supercomputing Research and = Development
 University of Illinois at = Urbana-Champaign
 305 Talbot = Laboratory          &nb= sp;      phone: +1 217 244-0047 (office)
 104 South Wright = Street           &= nbsp;          +1 217 = 356-0876 (home)
 Urbana, Illinois 61801-2932, = USA        fax: +1 217 = 244-1351

home: 2503 W. Springfield Av, Apt. K-4, Champaign = 61821, USA


------_=_NextPart_001_01C19443.45C3478C--