etex
Provides essential engine-level extensions and enhancements to the core TeX system, enabling advanced programming capabilities and improved functionality.
Overview
Represents a significant evolution of the original TeX engine, offering expanded programming features and improved functionality while maintaining full backward compatibility. The extensions have become fundamental to modern LaTeX usage.
- Serves as the standard base engine for LaTeX2e, making its features available to all LaTeX programmers
- Includes enhanced programming capabilities like expanded register capacity, additional conditional commands, and improved control over expansion
- Integrated into popular TeX engines like pdfTeX, making these extensions widely available across different TeX distributions
- Essential for package developers and advanced LaTeX users who need access to extended programming features
- Maintains complete compatibility with original TeX documents while providing modern enhancements
Getting Started
The etex
package is a library that provides extended TeX functionality. It is not a LaTeX package that you include directly with \usepackage, but rather an engine component that extends standard TeX.
Modern LaTeX distributions automatically use e-TeX extensions by default. If you need to explicitly use the e-TeX engine:
- Create your LaTeX document as normal
- Compile with the etex command:
etex document.tex
However, most users should use pdfLaTeX, XeLaTeX, or LuaLaTeX instead, as these engines already incorporate all e-TeX extensions.
Examples
Using e-TeX's extended register capabilities to create more counters than plain TeX allows.
\documentclass{article}
\begin{document}
% Plain TeX only allows up to 256 counters/registers
% e-TeX extends this significantly
\newcount\mycounterone
\newcount\mycountertwo
\newcount\mycounterthree
\mycounterone=100
\mycountertwo=200
\mycounterthree=300
The values of my counters are: \the\mycounterone, \the\mycountertwo, and \the\mycounterthree.
% Using e-TeX's \numexpr for inline arithmetic
The sum of the first two counters is: \the\numexpr\mycounterone+\mycountertwo\relax.
\end{document}
Demonstrating e-TeX's \unless conditional and string testing capabilities.
\documentclass{article}
\begin{document}
% Demonstrate e-TeX's \unless conditional
\def\teststring{hello}
\noindent Testing string comparison:\par
\ifx\teststring\undefined
The string is undefined.
\else
The string is defined as: \teststring\par
\fi
% Using \unless (an e-TeX extension)
\unless\ifx\teststring\undefined
Using \texttt{\string\unless}: The string is defined as: \teststring\par
\fi
% Using e-TeX's \detokenize for safe string display
\noindent Raw tokens: \detokenize{\textbf{bold} \& \textit{italic}}
\end{document}
Using e-TeX's \middle delimiter in mathematical expressions.
\documentclass{article}
\usepackage{amssymb}
\begin{document}
% Standard TeX only has \left and \right delimiters
% e-TeX adds \middle for more flexible math typesetting
\noindent Standard delimiter sizing:\par
\[
\left( \frac{a}{b} \right) \quad \left\{ \frac{x}{y} \right\}
\]
\noindent Using e-TeX's \texttt{\string\middle} for complex expressions:\par
\[
\left\{ x \in \mathbb{R} \middle| x^2 > 2 \right\}
\]
\[
\left( \frac{a}{b} \middle/ \frac{c}{d} \right)
\]
\end{document}