# Where can I find a documentation for low-level tex conditionals like \if?

I want to understand low-level stuff like \if better. I'm not looking for some random examples off Google showing me some statements but a specification of some sort - something mean and unforgiving. But it's hard searching for the phrase "if" because it doesn't match what I'm looking for.

Note: I am not talking about \ifthen.

-
Have a look into Knuths TeXbook or Eijkhouts “TeX by Topic“. Both awesome books about how things work “under the hood”. –  Marco Mar 1 '12 at 14:53

You should probably have a look at Chapter 20 of the TeXBook and at Chapter 13 of Eijkhout's book TeX by Topic. (The latter book is probably also included in your TeX distribution -- try typing "texdoc texbytopic".)

-

Since you ask "where can I find ...", I believe that posting a link is a valid answer. I really like this page that explains all TeX primitives, with comments and examples:

http://www.tug.org/utilities/plain/cseq.html#Logic-fam

-

As another quick reference I have used Tralics extensively. Although some of the commands do not appear in TeX it is of great help. Mainly due to its many low-level examples.

There are many examples. For instance for the \edef command:

\edef

You can say \edef\foo{bar}. The syntax is the same as \def, but the token list in the body is fully expanded (tokens that come from \the are not expanded).

You can put the prefix \global before \edef, note that \xdef is the same as \global\edef. In the example that follows, the \ifx is true.

{\catcode\A=12 \catcode\B=12\catcode\R=12\gdef\fooval{ABAR}}
{\escapechar=\A \edef\foo{\string\BAR}\ifx\foo\fooval\else \uerror\fi}


Another example is the following. The \meaning command returns a token list, of the form macro:#1#2->OK OK, and \strip@prefix removes everything before the > sign. What we put in \Bar is a list of five tokens, a space, and four letters of catcode 12.

\makeatletter
\def\strip@prefix#1>{}
\def\foo#1#2{OK OK}
\edef\Bar{\expandafter\strip@prefix\meaning\foo}


For a non-trivial example, see \aftergroup.

-