The etex package provides an interface to e-TeX features. What advantages does it offer to LaTeX users?
Are there any possible disadvantages like incompatibility to any other package or can I just use it without worries?
The etex package provides an interface to e-TeX features. What advantages does it offer to LaTeX users?
Are there any possible disadvantages like incompatibility to any other package or can I just use it without worries?
e-TeX provides lots of additional features for package writers such as an increased number of registers. The thing I find most useful is its extended tracing ability which I usually access through the trace package. In particular, tracing commands and tracing assignments are extremely helpful when trying to diagnose a problem.
e-TeX also provides a \middle delimiter that works like \left and \right which can be helpful.
\[\left\{\sum_{i=0}^n a_i\ \middle|\ a_0<a_1<\dotsb<a_n\right\}\]
Edit: While writing an answer to another question, I just remembered two pretty useful extensions in e-TeX. The first is \unless which lets you negate the arms of an \if. It's especially useful in loops where you want to loop unless some condition is true. Reading files was my example.
\loop\unless\ifeof\file
\readline\file to\foo
% Do something with \foo
\repeat
This also shows the second of the two extensions: \readline. It acts exactly like \read except that all of the characters are given category code other or space. It's very handy for reading in text that contains characters like $, %, ^, &, _, or \. For example, here's a cheater's quine.
\newread\file
\openin\file\jobname
\endlinechar-1
\tt
\loop\unless\ifeof\file
\readline\file to\foo
\noindent\foo\endgraf
\repeat
\bye
There are other category changing commands like \scantokens and \detokenize, but I've never used either.
\middle comes from e-Tex. Good to know, I've seen people writing it would come from amsmath. I checked it, there's no such definition in the ams files. Just tried \middle: it works in a minimal document without any package, not even \usepackage{etex} is necessary.
– Stefan Kottwitz
Aug 19 '10 at 16:27
texdoc etex.
– Stefan Kottwitz
Aug 19 '10 at 18:26
biblatex.
– Joseph Wright
Aug 19 '10 at 18:54
etex.sty package.
– Lev Bishop
Aug 20 '10 at 01:39
etex.sty, it seems like access to more registers are when using \newX come from it. In addition, etex redefines \tracingall if you care to use that interface. I prefer using the trace package.
– TH.
Aug 20 '10 at 04:23
etex package to be able to use them from LaTeX. Loading etex as the very first package is often a good choice in large documents, since it prevents LaTeX from running out of registers when lots of packages are loaded.
– Philipp
Aug 21 '10 at 12:18
\detokenize! It's probably my second-favourite e-TeX primitive [I'd say \unexpanded is my favourite :-)].
– Joseph Wright
Aug 26 '10 at 21:05
\unexpanded differ from sticking the tokens in a token register and then using \the on it?
– TH.
Aug 26 '10 at 21:29
Looking at the e-TeX extensions in general, I'd highlight two points that have not been mentioned by others. First, e-TeX provides primitives for carrying out calculations when assigning integers, dimensions, etc. For example,
\newcount\mycount
\mycount\numexpr 1 + 2 * 3\relax
\showthe\mycount
will give 7. Now, you can do something similar with the calc package, but only for LaTeX-managed variables. I find the e-TeX primitives particularly handy with Tikz, as it uses TeX registers directly and so does not work with the calc package. e-TeX means that things like
\tikzset{ key-name = \dimexpr 3 * \SomeDimension\relax }
work nicely.
Secondly, and more 'conceptually', LaTeX users get the benefit from packages that use e-TeX primitives for the code; one I'd point to is biblatex. As a programmer, the e-TeX extensions make many things much easier, and also allow programming ideas that simply don't work with TeX82 (i.e. TeX written by Knuth). The direct influence of e-TeX may not show up to users, but the availability of packages certainly does.
c@. Why rename them to ints now?
– TH.
Aug 23 '10 at 23:29
It should be pointed out that already a number years ago the LaTeX Project officially announced that LaTeX is expected to be run on an e-TeX-based enabled engines. In other words: all functionality available in e-TeX is supposed to be available for the LaTeX kernel and any add-on packages.
So far, the LaTeX Project Team hasn't made changes to the "kernel" that would not run without e-TeX, but there are packages including some maintained by the team that do require this functionality. This is in particular true for all work on LaTeX3, e.g., the expl3 based packages.
The etex.sty package is the core package for LaTeX2e enabling those e-TeX extensions that are not automatically available when using the right formatter. It is based on Peter Breitenlohner's package etex.src.
Now I found the etoolbox package. It's a toolbox of programming facilities providing LaTeX frontends to some new e-TeX primitives and further features.
It supports
Definition of "robust" commands: \newrobustcmd, \renewrobustcmd etc.
Patching existing commands to be robust: \robustify
Protecting entire chunks of code by \protecting
Defining counters and lengths with arithmetic expressions (\defcounter, \deflength)
Using hooks similar to \AtBeginDocument but in different variants: \AfterPreamble, \AtEndPreamble, \AfterEndPreamble and \AfterEndDocument
Many shorthands for macro definitions (corresponding to \def, \gdef, \edef, \let etc. but with control sequences as first argument and robust)
Undefining macros
Arithmetic definitions (similar to \def, \edef etc. but with integer expressions)
Expansion control (useful in \edef and the like) by \expandonce
Hook management: appending and prepending to hooks
Patching of existing commands: extracts the text of a command, does search&replace in the code, and reassembles it - nice for workarounds
Appending and prepending to commands
Control sequence tests (if defined, if empty, equality)
String tests (equality, empty or blank)
Artihmetic tests
Two different interfaces to boolean switches
List processing
If some of the features seem to be interesting for you, there's documentation available: texdoc etoolbox at the command prompt or the package documentation on CTAN, a reference manual with 30 pages.
The package etextools bases on etoolbox and provides many further macros. You can access its documentation also by texdoc and on CTAN.
expl3 (although the two approaches have arrived that way independently).
– Joseph Wright
Aug 23 '10 at 16:18
etoolbox is things that don't depend on e-TeX but simply things that should be in LaTeX that are not
– Joseph Wright
Aug 23 '10 at 18:03
etex.sty seems aim to be to LaTeX as etex.src is to plain TeX. It seems to be useful for giving nice names to e-TeX (the engine)'s magic constants, so you can write \hboxgrouptype for 2, \ligaturenode for 7, and so on. It is loaded internally by quite a lot of packages.
Another feature it provides is transparently making the extended register pool available if the normal pool gets exhausted. It is recommended for the user to load it to help with 'no room for a new thing' errors, as in this FAQ answer
etex package is loaded by a number of other LaTeX packages which require e-TeX, for example biblatex and expl3. (I guess you could say that the availability of e-TeX depended package is a benefit to LaTeX users, as by using e-TeX the package authors have provided things which are hard to do otherwise.)
– Joseph Wright
Aug 19 '10 at 18:53
grep commandline, so I fixed my answer.
– Lev Bishop
Aug 19 '10 at 20:12
If one wants to implement some sort of multiline widow/orphan control (e.g. "For the first paragraph following a sectional heading, page breaks are allowed only after the third and following lines"), standard (La)TeX only offers approximate solutions (mostly involving the needspace package). With e-TeX, exact solutions are possible using the \widowpenalties and \clubpenalties macros. See this answer for an example.
Joseph Wright has already mentioned biblatex as a "user-relevant" package which uses e-TeX primitives; another one is marginnote which (contrary to standard LaTeX's \marginpar command) allows margin notes for floats and footnotes.
etex' (the LaTeX package). I'm a bit confused: do you mean the extensions or just the package. – Joseph Wright Aug 19 '10 at 20:16