The e-TeX extensions were intended to address some of the shortcomings of Knuth's original TeX, and since they are required by LaTeX2e for a while now, most package authors can rely on their presence. Now while there are some resources available for learning pure TeX macro idioms, including this discussion on this site, and also on the benefits of e-TeX in general, I would like to see some concrete examples of how e-TeX extensions can make the life of a macro writer easier.
In particular, some practical advice/tricks on the use of the expansion and parsing related commands \protected
, \unexpanded
, \detokenize
and \scantokens
would be much appreciated. They look useful to me, yet I never realize when I could use them to simplify things (the e-TeX manual is also very terse on them).
The scope of the question is fairly broad, but I would be most interested in the extensions listed above. Following are some further thoughts on other extensions that I would also be happy to discuss.
For some of the extensions, their usefulness is immediately evident to me, including
- not having to worry about allocating new registers due to the increased number of 32767 slots per type
- the convenient
\numexpr
,\dimexpr
etc. expression commands facilitating arithmetic operations \unless
as a negated\if
, especially in conjunction with\loop
s where otherwise new conditionals would have to have been defined if a loop was to be executed as long as a conditions was false- various new tracing commands and options, helping with diagnostics
But then, some features make me wonder whether they are actually used by packages out there or if they have come to be replaced by more "modern" approaches, such as
- mixed direction typesetting with
\beginL
,\beginR
etc. - status enquiries like
\currentgrouptype
,\currentiftype
,\lastnodetype
etc. - the possibility of saving discarded items from the top of pages being built in
\pagediscards
- line specific penalties with
\interlinepenalties
and the like
\protected
in particular allows some new and interesting constructs. I could probably write something covering the 'big ticket' items, plus point to use of various informational data, but it would necessarily be a personal view.\protected
is also a good one, I forgot about that. I will try to make that more visible/reduce the question. Also I don't expect an objective or comprehensive answer, just some inspirations ...\unexpanded
. It has also found its way in the LaTeX kernel as well as\protected
.