Thoughts behind the problem: I am trying to understand where I can find documentation for \ifdefined and \ifx. Even google does not seem to know where to find it.

Then I tried using texdef:

$texdef -t latex -F ifx
\ifx is defined by (La)TeX.


That doesn't help me much.

Where can I find the documentation?

  • Some constructs are primitives, i.e. are not defined by other macros, they are given by the internals of the TeX binary, and can't be decomposed further. – user31729 Sep 10 '16 at 12:45
  • I see, but are they explained anywhere? – Xiphias Sep 10 '16 at 12:45
  • 2
    texdoc tex ;-), or The TeXBook by D. E. Knuth or TeX by Topic by V. Eijkhout – user31729 Sep 10 '16 at 12:46
  • Now that's nice. \ifx is in there, but not \ifdefined. Sorry for nitpicking :) Isn't that a TeX primitive then? I know the TeXBook, but those are not in there. – Xiphias Sep 10 '16 at 12:48
  • 1
    \ifdefined is an e-TeX extension (just checked!) --it's a new primitive . See texdoc etex, whereas \@ifundefined is purely LaTeX, see texdoc source2e. The given source above is about Tex82, which does not have such extensions. The 'problem' is the feature that it is possible to extend TeX and each extension introduces its own features ;-) – user31729 Sep 10 '16 at 12:50

Some commands can't be decomposed further in (La)TeX -- they are TeX primitives, basically the elementary particles of TeX, from which other macros can be constructed to simplify the usage of (La)TeX.

In the end it is a compiler or interpreter that must be instructed to operate if has read \ifx or \def or \openin. The situation is similar to, say, a C - source file: A C compiler must know what the basic commands for or return mean -- they are keywords and can't be reduced further.

That's why texdef \ifx will 'fail' in the sense that it can just report that \ifx is 'defined' as \ifx.

Looking up such constructs needs some experience and the knowledge that

  • texdoc tex will report much of Knuth's TeX
  • texdoc etex will give more insight of the 'new' e-TeX inventions introduced in the late 1990s
  • texdoc source2e provides information about the LaTeX core.
  • texdoc texbytopic will give a concise introduction how D.E. Knuth's version TeX works
  • texdoc pdftex is nice to read about the PDF extensions.

In a similar manner, luatex, xelatex and source3 are available for insights about LuaTeX, XeTeX and the expl3 extensions.

For example, \ifdefined is a new primitive introduced by e-TeX, it has no further definition other than what is written in the binary.

Please note that pdfTeX introduces some more primitives such as \pdfminorversion etc.

Unfortunately, compiling the The TeXBook source is not possible still nowadays.

| improve this answer | |
  • Since you mentioned pdfTeX, it might be worth explicitly adding texdoc pdftex. – Nicola Talbot Sep 10 '16 at 13:22
  • @NicolaTalbot: Fair point, I included the pdftex documentation reference as well – user31729 Sep 10 '16 at 13:27
  • re texbytopic, should be specific that it's knuth tex, not any extended version. – barbara beeton Sep 10 '16 at 13:44
  • 1
    texbook.tex is certainly available, not compilable, and rather hard to read without a printed copy to compare. (a wonderful source when you see something and wonder how it was coded, but not a good place to look for explanations.) tex.web, or better, "TeX: the program", is the canonical source for how, and usually why, something is done, but again, better in print. – barbara beeton Sep 10 '16 at 14:41
  • 2
    +1; but what about, texdoc luatex? – jon Sep 10 '16 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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