Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
Your question title says 'e-TeX' (the extended engine), but the body says '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
Mainly the difference I can achieve by using the etex package - but additional e-TeX infos are very welcome. –  Stefan Kottwitz Aug 19 '10 at 20:59

6 Answers 6

up vote 25 down vote accepted

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.

    \readline\file to\foo
    % Do something with \foo

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.

\readline\file to\foo

There are other category changing commands like \scantokens and \detokenize, but I've never used either.

share|improve this answer
So, \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
One thing about eTeX is there seems no good manual for it. Am I right? –  Leo Liu Aug 19 '10 at 17:54
@Leo: The e-tex manual is at tug.org/texmf-dist/doc/etex/base/etex_man.pdf –  Lev Bishop Aug 19 '10 at 17:59
@Leo: With TL 2009 I got the manual (20 pages) by texdoc etex. –  Stefan Kottwitz Aug 19 '10 at 18:26
@Lev Bishop: The registers are from the engine, but you need to load the 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

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 assignin integers, dimensions, etc. For example

\mycount\numexpr 1 + 2 * 3\relax

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 of 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.

share|improve this answer
Write: This is sort of tangential, but why rename the registers yet again? LaTeX already changes some names, for example skips are called lengths, counts were changed to counter—but with the bizarre addition of c@. Why rename them to ints now? –  TH. Aug 23 '10 at 23:29
They used to be called "cnt" in latex3 but it was long ago decided that name was a little awkward and perhaps rude. Besides, what other language doesn't call them "int"? –  Will Robertson Aug 24 '10 at 3:59

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.

share|improve this answer

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.

share|improve this answer
Rather more on the 'programmers' side than the 'users' side :-) I'd point out that there is quite a bit of overlap with ideas in expl3 (although the two approaches have arrived that way independently). –  Joseph Wright Aug 23 '10 at 16:18
I should also note that a bit of 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
True, the manual says it further contains 'some generic tools which are not related to e-TeX but match the profile of this package'. –  Stefan Kottwitz Aug 23 '10 at 18:41

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

share|improve this answer
Yes, we've got such an error here: tex.stackexchange.com/questions/1680/table-notes-in-memoir. –  Stefan Kottwitz Aug 19 '10 at 18:27
The 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
@Joseph: you are right. I had a bug in my grep commandline, so I fixed my answer. –  Lev Bishop Aug 19 '10 at 20:12
I was going on the rather more basic 'I know this as I've read/written the code'! –  Joseph Wright Aug 19 '10 at 20:15
@Joseph: On the other hand, packages requiring e-TeX cannot be used with distributions which do not support e-TeX. :-( –  Stephen Aug 26 '11 at 14:38

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.