1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
\documentclass{article}
\title{Testing equality vs. catcodes}
\begin{document}
\section{Begin 1}
{
Pretest (not): \ifx{& equals\else not\fi
Mangle...
\catcode`\&=1\relax
BRACE: \the\catcode`\{; \meaning{.
AMP: \the\catcode`\&; \meaning&.
Test (not): \ifx{& equals\else not\fi
}
\section{Math 3}
{
Pretest (not): \ifx$& equals\else not\fi
Mangle...
\catcode`\&=3\relax
DOLLAR: \the\catcode`\$; \meaning$.
AMP: \the\catcode`\&; \meaning&.
Test (not): \ifx$& equals\else not\fi
\let\foo$
Test (equals): \ifx$\foo equals\else not\fi
\let\bar&
Test (not): \ifx$\bar equals\else not\fi
Test (equals): \ifx&\bar equals\else not\fi
But still acts like math:&a&.
}
\section{Math 3 w/let}
{
Pretest (not): \ifx$& equals\else not\fi
Mangle...
\catcode`\&=\active\let&$
DOLLAR: \the\catcode`\$; \meaning$.
AMP: \the\catcode`\&; \meaning&.
Test (equals): \ifx$& equals\else not\fi
But still acts like math:&a&.
}
\section{Math 3 w/let, uncatcode}
{
Pretest (not): \ifx$& equals\else not\fi
Mangle...
\catcode`\&=\active\let&$
\catcode`\&=4\relax
DOLLAR: \the\catcode`\$; \meaning$.
AMP: \the\catcode`\&; \meaning&.
Test (not): \ifx$& equals\else not\fi
But does NOT act like math.
}
\section{Param 6}
{
Pretest (not): \ifx#& equals\else not\fi
Mangle...
\catcode`\&=6\relax
HASH: \the\catcode`\#; \meaning#.
AMP: \the\catcode`\&; \meaning&.
Test (not): \ifx#& equals\else not\fi
}
\section{MathActive}
{
Pretest (not): \ifx'& equals\else not\fi
Mangle...
\makeatletter
\mathcode`\&="8000
{\catcode`\&=\active \global\let&\active@math@prime}
\makeatother
PRIME: \the\catcode`\'; \meaning'.
AMP: \the\catcode`\&; \meaning&.
Test (not): \ifx#& equals\else not\fi
But works as prime?
NO %%% $ a&& $
}
\section{Control Sequences}
% But "defn" is the same
Compare 2 undefined control sequences:
\ifx\stinky\poo equals \else not\fi
Let one to relax:
\let\poo\relax
\ifx\stinky\poo equals \else not\fi
Let both to relax:
\let\poo\relax
\let\stinky\relax
\ifx\stinky\poo equals \else not\fi
\def\foo{FOO}
\let\bar\foo
Test (equals): \ifx\bar\foo equals\else not\fi
\makeatletter
\let\baz\active@math@prime
\makeatother
Test (not): \ifx'\baz equals \else not \fi
Test (not in math): $\ifx'\baz equals \else not \fi$
\end{document}
|