10

What is the reason to insert the code below at the beginning of a style file? For example, the code below can be found on lipsum.sty.

%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%

What is it for?

0

1 Answer 1

9

The character table is a remainder of the olden times when sending files or email through gateways was a risky business: every network had its own rules and mangled output was very common. I was on a BitNET node, but actually it used Vax/VMS networking, through some gateway in some place; others were on JANET or ARPAnet, others used a remailer called munnari.oz (for Australia).

Every gateway could corrupt the input in various ways, usually different from each other and also different from themselves from time to time.

So the LaTeX team devised this way for checking file integrity. In a .dtx file, the percent signs were stripped off, so what you reported is equivalent to

\CharacterTable{
  Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
  Digits        \0\1\2\3\4\5\6\7\8\9
  Exclamation   \!     Double quote  \"     Hash (number) \#
  Dollar        \$     Percent       \%     Ampersand     \&
  Acute accent  \'     Left paren    \(     Right paren   \)
  Asterisk      \*     Plus          \+     Comma         \,
  Minus         \-     Point         \.     Solidus       \/
  Colon         \:     Semicolon     \;     Less than     \<
  Equals        \=     Greater than  \>     Question mark \?
  Commercial at \@     Left bracket  \[     Backslash     \\
  Right bracket \]     Circumflex    \^     Underscore    \_
  Grave accent  \`     Left brace    \{     Vertical bar  \|
  Right brace   \}     Tilde         \~}

The macro \CharacterTable is defined by

\def\CharacterTable#1{%
  \begingroup
  \def\usedtable{#1}%
  \ifx\usedtable\defaulttable
    \typeout {***************************}%
    \typeout {* Character table correct *}%
    \typeout {***************************}%
  \else
    \PackageError{doc}{Character table corrupted}{\the\wrong@table}%
    \show\defaulttable
    \show\usedtable
  \fi
\endgroup}

(as usual, not really so, but this is the idea). The macro \defaulttable contains the right character table. Since \ifx compares two macros by looking at their first level expansion and returns true only if the two expansion coincide token by token (without interpreting them) we can see that if the file is corrupt, for instance changing ~ into something else (yes, this was common), the test would return false.

Adding a backslash in front of every character neutralizes the special nature they can have. Again, \ifx doesn't mind if \0 is not defined; if it is at the same place in \usertable and \defaulttable it goes on.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .