# Wiki: TeX

Your best resource for TeX is the TeXBook, particularly chapter 20 ("Definitions (also called Macros)") and Appendix D ("Dirty Tricks"). Appendix B provides a list of almost all macros defined at startup.

The reference for plain TeX at tug.org is also a good resource.

## Basics

### Differences from Plain TeX

The TeX language on the site is very similar to Knuth's plain TeX, with a few small modifications:

• output is through text rather than DVI or PDF, using dvi-to-text.
• none of the default fonts support characters with code greater than 127, so use \octet to switch to a font with a full code page
• hole arguments are pre-filled by a \argv[#1] macro

### Looping over a string

The following code loops over all tokens until \relax, replacing all - tokens with (DASH)

\def\f#1{\ifx#1\relax%
\let\n\relax%
\else%
\let\n\f%
\ifx#1- (DASH)%
\else #1%
\fi%
\fi\n}

\f 0-185186-70-\relax


## Golfing

### One-byte macro ending

If a macro you define takes an argument longer than one token, you might be tempted to use curly braces. However, \def can allow for a single end character, saving one byte per usage.

\def\f#1{something #1 something}
\f{123}\f{456}
% compare
\def\f#1;{something #1 something}
\f123;\f456;


### \let

Commonly-used macros can be aliased with \let

Compare:

\newcount\a\newcount\b\newcount\c
% compare
\let\N\newcount\N\a\N\b\N\c