Received: by nummer-3.proteosys id <01C19443.4A89D68C@nummer-3.proteosys>; Thu, 3 Jan 2002 11:42:07 +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.4A89D68C" X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message Subject: marks Date: Sat, 26 Oct 1991 00:13:43 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: From: Sender: "LaTeX-L Mailing list" To: "Multiple recipients of" Reply-To: "LaTeX-L Mailing list" Status: R X-Status: X-Keywords: X-UID: 418 This is a multi-part message in MIME format. ------_=_NextPart_001_01C19443.4A89D68C Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable The other day I had to solve another cute problem (and this one cost me a full day, because all problems of unwanted expansion were coming back full blast), concerning marks. I think this is relevant for the development of LaTeX. The user macro \section is defined in terms of \@sect, which executes for a section the command \sectionmark. However, that command has no generality: it has a different definition for every \ps@... Furthermore, it explicitly determines what information to set in the mark. If there are many people who can potentially set marks, this is dangerous. If the next LaTeX is going to be serious about it's meta-ness (so the basic format doesn't know that there will be a \section macro, just that there will be headings), then a more general approach is necessary. Here's what I did. - There is a list \mark@items of everything that can wind up in a mark. - The macro \DefineHeading executes statements (\xp=3D=3D\expandafter) \xp\add@mark@item\xp{\naam Counter} \xp\add@mark@item\xp{\naam Title} where \naam expands to the name of whatever is being defined at the moment. - Adding a mark item is \csarg\newtoks{mark@toks@#1}% \mark@items\xp{\the\mark@items{#1}}\fi} which allocates a private token list \mark@toks@sectionTitle for = instance. - A \section command then executes (\nxp=3D=3D\noexpand) \edef\cs@e{\nxp\refresh@mark@item {\naam Title}{\the\title@toks}}% \cs@e where \def\refresh@mark@item#1#2{\csarg\global{mark@toks@#1}{#2}} which refreshes the token list corresponding to a \mark'able item. - Furthermore it calls \place@mark, where \def\place@mark{\mark{\xp\get@mark@items\the\mark@items{SM}}} \def\get@mark@items#1{\if\ifEqualStringX{#1}{SM}% \else{#1}{\csarg\the{mark@toks@#1}}\xp\get@mark@items \fi} Note that because I stored everything in a token list this means that I won't get any unwanted expansion. !!!!! Also note (and this is a big one!) that because this occurs in = \mark everything, including the string test (!!) has to be done by expansion = !!!! - You access a mark by requesting (for instance for the \botmark) \LastPlaced:sectionTitle Example: here is the running head for my book: \subjectCounter \if\TestCounter:point >0 \ifrighthandpage .\LastPlaced:pointCounter \fi \fi \Spaces:2 \BigSlash \Spaces:2 \iflefthandpage \subjectTitle \else \if\TestCounter:point >0 \LastPlaced:pointTitle \else \subjectTitle \fi \fi} Design: put \subjectTitle in the left head, and \pointTitle in the right head, (\point \approx \section) except when a chapter has no sections (for instance the index). This uses the mark mechanism to retrieve the \pointCounter and = \pointTitle; the \subjectTitle/Counter exist in a more global manner, so marks weren't necessary there. - The macro \LastPlaced does a stringtest to see which of the markitems is needed. \def\LastPlaced:#1 {\xp\get@placed\xp{\botmark}{#1}} \def\get@placed#1#2{\get@@placed{#2}#1{SM}{}$}% SM: StopMarker \def\get@@placed#1#2#3{\if\ifEqualStringX{#2}{SM}\xp\take@to@dollar \else\if\ifEqualStringX{#1}{#2}% \maybe@uppercase{#3}\xp\xp\xp\take@to@dollar \else\xp\xp\xp\get@@placed\fi \fi{#1}} And that's it. The style designer has only one command: \LastPlaced (or \FirstPlaced) to place whatever in a running head. The rest is automatic. Any comments? Questions? Class dismissed. Ite missa est. (which the Dutch translate by 'Go, it is wrong' :-) 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.4A89D68C Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable marks

The other day I had to solve another cute problem (and = this one
cost me a full day, because all problems of unwanted = expansion
were coming back full blast), concerning marks. I = think this is
relevant for the development of LaTeX.

The user macro \section is defined in terms of = \@sect,
which executes for a section the command = \sectionmark.
However, that command has no generality: it has a = different
definition for every \ps@...
Furthermore, it explicitly determines what = information to set
in the mark. If there are many people who can = potentially
set marks, this is dangerous.

If the next LaTeX is going to be serious about it's = meta-ness
(so the basic format doesn't know that there will be = a \section
macro, just that there will be headings), then a more = general
approach is necessary.

Here's what I did.

- There is a list \mark@items of everything that can = wind up
 in a mark.

- The macro \DefineHeading executes statements = (\xp=3D=3D\expandafter)
 \xp\add@mark@item\xp{\naam Counter}
 \xp\add@mark@item\xp{\naam Title}
 where \naam expands to the name of whatever is = being defined
 at the moment.

- Adding a mark item is
    = \csarg\newtoks{mark@toks@#1}%
    = \mark@items\xp{\the\mark@items{#1}}\fi}
 which allocates a private token list = \mark@toks@sectionTitle for instance.

- A \section command then executes = (\nxp=3D=3D\noexpand)
          &nbs= p; \edef\cs@e{\nxp\refresh@mark@item
          &nbs= p;            = ;  {\naam Title}{\the\title@toks}}%
          &nbs= p; \cs@e
 where
 \def\refresh@mark@item#1#2{\csarg\global{mark@toks@#1}{#2}= }
 which refreshes the token list corresponding to = a \mark'able item.

- Furthermore it calls \place@mark, where
 \def\place@mark{\mark{\xp\get@mark@items\the\mark@items{SM= }}}
 \def\get@mark@items#1{\if\ifEqualStringX{#1}{SM}%
    = \else{#1}{\csarg\the{mark@toks@#1}}\xp\get@mark@items
    \fi}
 Note that because I stored everything in a = token list this means
 that I won't get any unwanted expansion.
 !!!!! Also note (and this is a big one!) that = because this occurs in \mark
 everything, including the string test (!!) has = to be done by expansion !!!!

- You access a mark by requesting (for instance for = the \botmark)
 \LastPlaced:sectionTitle
 Example: here is the running head for my = book:
    \subjectCounter
        = \if\TestCounter:point >0
          &nbs= p; \ifrighthandpage .\LastPlaced:pointCounter \fi
        \fi
         = \Spaces:2 \BigSlash \Spaces:2
    \iflefthandpage = \subjectTitle
    = \else           = \if\TestCounter:point >0 \LastPlaced:pointTitle
          &nbs= p;         \else \subjectTitle = \fi
    \fi}
 Design: put \subjectTitle in the left head, and = \pointTitle in the
 right head, (\point \approx \section)
 except when a chapter has no sections (for = instance the index).

 This uses the mark mechanism to retrieve the = \pointCounter and \pointTitle;
 the \subjectTitle/Counter exist in a = more
 global manner, so marks weren't necessary = there.

- The macro \LastPlaced does a stringtest to see which = of the markitems
 is needed.
 \def\LastPlaced:#1 = {\xp\get@placed\xp{\botmark}{#1}}
 \def\get@placed#1#2{\get@@placed{#2}#1{SM}{}$}% = SM: StopMarker
 \def\get@@placed#1#2#3{\if\ifEqualStringX{#2}{SM}\xp\take@= to@dollar
    = \else\if\ifEqualStringX{#1}{#2}%
          &nbs= p;   \maybe@uppercase{#3}\xp\xp\xp\take@to@dollar
         = \else\xp\xp\xp\get@@placed\fi
    \fi{#1}}

And that's it. The style designer has only one = command: \LastPlaced
(or \FirstPlaced) to place whatever in a running = head.
The rest is automatic.

Any comments? Questions? Class dismissed. Ite missa = est.
(which the Dutch translate by 'Go, it is wrong' = :-)

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.4A89D68C--