# Tag Info

54

The main reason why people may consider ifthen obsolete (last version is of 2001/05/26 with about one page of user manual plus four pages of code documentation) is that it is superseded by e.g. etoolbox, which uses the advanced possibilities of eTeX. Using these allows faster processing. You still can use ifthen for your existing and new documents if you ...

43

You can inhibit page breaks in the middle of paragraphs by saying in you preamble \widowpenalties 1 10000 \raggedbottom Without \raggedbottom (that the article class does automatically) the pages would be awful. The primitive \widowpenalties is an extension to the original TeX program, present in e-TeX based engines (pdftex, xetex and luatex). It ...

38

TeX, as designed by Knuth, has various registers addressable with an eight bit number (that is, from 0 to 255). Registers are of type \count \dimen \skip \muskip \toks \insert \box Let's consider the \dimen registers, for the others the allocation mechanism is similar. Each register is addressable by its number, for instance \dimen34=42pt \kern\dimen34 ...

27

From my experience in various forums and newsgroups, ifthen often seems to do more harm than good, especially when used by newbies. The main \ifthenelse command is fragile, so something like \section{\ifthenelse{\equal{a}{a}}{b}{c}} doesn't work. The comparison is not expandable, so that the command "possibly has only limited usefulness for macro code ...

25

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

23

A lot of server-based set ups are very conservative. For example, I write achemso to support submissions to the American Chemical Society. On the servers they have to take author .tex files and produce .pdf files, the e-TeX extensions are not available. (I am told an upgrade is planned for later this year.) These systems are often based on custom additions ...

22

\marks is an etex primitive command. It extends the \mark command of the original tex. You can use it to store text on the current page which you want to use at shipout in the headers. \documentclass{article} \usepackage{etex} \newmarks\mymark \usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{} \lhead{\topmarks\mymark, \botmarks\mymark, \firstmarks\mymark} ...

20

The \scantokens primitive is described in the e-TeX manual as working in a similar manner to the following code: \toks0={...}% '...' is the rescanned material \immediate\openout0=file \immediate\write0{\the\toks0} \immediate\closeout0 \input file but without the use of files and in an expandable manner. However, it does use the some of the same internals ...

19

The "original TeX" solution: \interlinepenalty 10000.

19

TeX's scanner (eyes) convert characters in a file to tokens. That only happens once, macro replacement text and all expansion processing processes tokens (which are [character-code,catcode] pairs. the catcode table affects the conversion of characters to character tokens. So your definition locally makes the catcode of _ 13 so if a _ character is encounted ...

18

classic TeX has 256 registers (eg count and dimen registers as allocated by \newcounter and \newlength in LaTeX. For some years LaTeX formats have used the extended etex (or pdf(e)tex engines rather than classic TeX, so actually there are 32768 registers available. However for compatibility reasons (or stubbornness, or apathy, depending on your point of ...

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 \newcount\mycount \mycount\numexpr 1 + 2 * 3\relax \showthe\mycount will give 7. Now, you can do something similar with the calc ...

17

Loading the etex package should be safe in almost every case. It's main aim is to alter the allocation scheme to use the extra space made available by the e-TeX, and it does this in such a way as to avoid as far as possible any conflict. (Note that the team plan to enable use of the extended registers in a format release but this will use a subtly different ...

16

There may be a generalisable mechanism: Using e-TeX and its \clubpenalties command. In the following example, patching \@afterheading seems to do the trick. \documentclass{article} \usepackage{etex} \usepackage{etoolbox} \makeatletter \patchcmd{\@afterheading}% {\clubpenalty \@M}{\clubpenalties 3 \@M \@M 0}{}{} \patchcmd{\@afterheading}% ...

15

To add to what Hendrik says, I think the overall point was that \numexpr, \dimexpr, etc. can be used in a full expansion context without leaving a stray \relax or space: \edef\example{\the\dimexpr 10 pt + 20 pt \relax} gives \example defined as 30pt with no unexpected tokens. That is in many ways much 'neater' than the alternative of leaving the \relax in ...

15

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

15

if a bug is reported in tex, knuth will accept only a minimal example processed with the latest unmodified version of tex. (of course, a bug elsewhere would never be considered for submission to knuth.)

14

In short, yes. Try \edef\foo{\scantokens{Test\noexpand}} or \everyeof={\noexpand} \edef\foo{\scantokens{text}} in which the \noexpand ‘hides’ the EOF marker by turning it into \relax. You might like to take a look at the definition of expl3's \tl_rescan:nn and \tl_set_rescan:Nnn, both wrappers for \scantokens based on the ideas in Heiko Oberdiek's ...

14

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

12

It means that the format is set up to use the etex primitives such as \dimexpr All formats do this by default these days except tex which is set up to not use the extensions and use dvi output so that it is classic plain TeX. LaTeX always uses this mode (whether or not shell escape is used) see $pdflatex \\relax This is pdfTeX, Version ... 12 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 ... 11 Current ConTeXt code uses \dimexpr and \numexpr from e-TeX a lot, because most of ConTeXt predates luatex. If you want to do a quick calculation in lua, you can just do something trivial like this: \def\evaluate#1{\directlua{tex.sprint(tostring(#1))}} then you can write: \evaluate{10.2+1e6} \evaluate{10.2/0} et cetera. Best wishes, Taco 11 The \scantokens command is not “dangerous” by itself, but it can have surprising effects. How does it work? Its argument is scanned like for a \write operation, but all symbolic tokens are considered unexpandable, based on the current category codes; the result is placed in a “pseudofile” that is read in exactly as if \input was used. This has various ... 10 Run texdoc etex and you'll get the documentation of eTeX. Two of the nice new features are \dimexpr and \numexpr. Instead of 256 available counters, dimensions, etc. there are now 2^{15}. ε-TEX increases the number of TEX’s count, dimen, skip, muskip, box, and token registers from 256 to 32768. eTeX is the default engine for all programs except of ... 10 I would say this makes it easy to delimit a \dimexpr in a fully expandable way. Putting a \relax is a usual way to delimit TeX dimensions, which I learned the hard way: It's always a good idea to put a \relax after something like \hskip1pt. Now it seems that eTeX just made a principle out of this. (An alternative is to put a space to delimit a TeX ... 10 I'm now fairly certain this this is a bug in the current implementation of linebreak_filter. What seems to happen is the following: when TeX builds a list (in this case a vertical list) it keeps track of it through a pointer to the head and to the tail of that list. Now when a paragraph is broken into lines those lines get appended to the current vertical ... 10 This is the relevant part from etex.ch: 5247 @ The function |quotient(n,d)| computes the rounded quotient 5248$q=\lfloor n/d+{1\over2}\rfloor$, when$n$and$d\$ are positive. 5249 5250 @<Declare subprocedures for |scan_expr|@>= 5251 function quotient(@!n,@!d:integer):integer; 5252 var negative:boolean; {should the answer be ...

10

These packages serve different purposes. fixltx2e corrects some design errors of LaTeX2e; if these errors bother you, you should use it. They rarely bothered me - I think I encountered them no more than two or three times in my work. On the other hand etex helps to use the additional features of etex engine; as a user you probably do not need them anyway ...

9

Without the e-TeX extensions, you need to use a toks to have control of expansion inside an \edef. Usually, this is done using \toks@, and so to avoid any issues with other code a group is normally employed \begingroup \toks@\expandafter{\@freelist\@elt}% \edef\@freelist{\the\toks@\expandafter\noexpand\ExtraFloatCommand}% \expandafter\endgroup ...

9

I solved this with the needspace and titlesec packages, as in: \usepackage{titlesec} \usepackage{needspace} ... \titleformat{\section} {\needspace{1in}\Large\bfseries}{\thesection}{1em}{} Hardcoding 1in is crude -- should probably be a multiple of line height. At any rate, this works great in my documents without the need for hand tuning each section.

Only top voted, non community-wiki answers of a minimum length are eligible