[texhax] A Comprehensive list of TeX primitives and Plain TeX macros

Heiko Oberdiek heiko.oberdiek at googlemail.com
Fri Oct 12 02:38:33 CEST 2012

On Thu, Oct 11, 2012 at 10:23:24AM +0100, Philip TAYLOR wrote:

> Heiko Oberdiek wrote:
> >The following Perl script generates a list of command names that are
> >used in plain.tex. The list does not include active characters and
> >primitives that are not used in plain.tex explicitly.
> A brilliant solution, Heiko, and one which I am sure will
> help Paul greatly.  In view of your closing caveat above,
> I wonder if you might be able to write an analous Perl
> script to extract the definitive list from TeX.pool :
> 	http://www.saildart.org/TEX.POO%5BPAS,DEK%5D

tex.pool contains strings. Some of them are command tokens, but
other are not and unhappily these strings are mixed up.

I have added the summary chapters of texbook.tex and
etex_man.tex to get new tokens.

> and then the two lists could be merged ?


%%% plaincmds.pl %%%
#!/usr/bin/env perl
use strict;

my %cmd;

chomp(my $file_plain = `kpsewhich plain.tex`);
my $file_texbook = 'texbook.tex';
my $file_etex = 'etex_man.tex';

sub addcmd ($) {
    my $cmd = shift;
    $cmd{$cmd} = 1;
    return $cmd;

open(IN, '<', $file_plain) or die "!!! Error: Cannot open `$file_plain'!\n";
while (<IN>) {
    # s/(^|[^\\])%.*/$1/;

open(IN, '<', $file_texbook) or die "!!! Error: Cannot open
while (<IN>) {
    last if /beginchapter Chapter 24\./;
while (<IN>) {
    last if /beginchapter Chapter 27\./;
close (IN);

open(IN, '<', $file_etex) or die "!!! Error: Cannot open `$file_etex'!\n";
while (<IN>) {
    last if /\\subsection{Expandable Commands}/;
while (<IN>) {
    last if /\\begin{thebibliography}/;


map { print "$_\n"; } (sort keys %cmd);

%%% plaincmds.pl %%%

%%% plaincmds.txt %%%
\c at ncel
\ch at ck
\dimen at i
\dimen at ii
\displ at y
\dt at pfalse
\dt at ptrue
\f at t
\finph at nt
\finsm at sh
\fo at t
\getf at ctor
\h at false
\h at true
\if at cr
\if at mid
\ifdt at p
\ifp at ge
\ifr at ggedbottom
\insc at unt
\m at g
\m at ketabbox
\m at ne
\m at th
\makeph at nt
\makesm at sh
\mathph at nt
\mathsm at sh
\n at space
\o at lign
\p at gefalse
\p at getrue
\p at renwd
\ph at nt
\pr at m@s
\prim at s
\r at ggedbottomfalse
\r at ggedbottomtrue
\s at tcols
\s at tt@b
\sett at b
\sh at ft
\sp at n
\t at bb@x
\t at bbox
\us at false
\us at true
\v at false
\v at true
\voidb at x
\z at skip
%%% plaincmds.txt %%%

Yours sincerely
  Heiko Oberdiek

More information about the texhax mailing list