5

Please take this question for a moot point:

I'd like to know about edge cases where different tokens which TeX might encounter during expansion without delivering error-messages have the same meaning and the same \string-representation.

By "have the same meaning" I mean that

\ifx⟨token 1⟩⟨token 2⟩\expandafter\firstoftwo\else\expandafter\secondoftwo\fi
yields \firstoftwo.

By "same \string-representation" I mean that \string⟨token 1⟩ yields the same set of tokens as \string⟨token 2⟩.

Edge cases I came up with so far:

  • frozen-\relax and \relax-primitive.
  • the nameless control-sequence (producible via \csname\endcsname or via an escape-character (backslash) at the end of a line of .tex-input while \endlinechar has a negative value) and the control-sequence whose name is csname⟨escapechar⟩endcsname (producible via \csname csname\string\endcsname\endcsname) while those control-sequences have the same meaning.
  • active-character-token let equal to a non-active pendant.
  • one-letter-control-sequence let equal to an explicit character token where the character-code corresponds to the character which forms the name of the control-sequence while \escapechar has a negative value.

Are there more edge cases?

E.g., what about things like \inaccessible or tokens that TeX might insert while processing an alignment? You can define \inaccessible. Can you let it equal to TeX's \inaccessible?

2
  • by "same meaning" do you mean "same string produced by \meaning" ? Dec 28, 2021 at 20:21
  • @DavidCarlisle By "same meaning" I mean that \ifx-comparison of the tokens yields the "true"-branch. I edited the question. Dec 28, 2021 at 21:35

1 Answer 1

4

Another such case are frozen font control sequences obtained by applying \the to a font command and the original font command itself. They fulfill all your criteria:

\documentclass{article}
\begin{document}
\makeatletter
% Let's assume that we loaded a font at some point:
\font\cmr cmr10
% Then we can get a second token for accessing the font using \the
\edef\tokens{\the\cmr\cmr}
% Compare their \string representations:
\edef\helpI{\expandafter\expandafter\expandafter\string\expandafter\@firstoftwo\tokens}
\edef\helpII{\expandafter\expandafter\expandafter\string\expandafter\@secondoftwo\tokens}
\ifx\helpI\helpII
  They have the same \texttt{\string\string} representation.
\else
  They have different \texttt{\string\string} representation.
\fi

\expandafter\ifx\tokens
  They have the same meaning.
\else
  They have different meaning.
\fi

% Now in case some people question that they are actually different, let's change the meaning of one of them and compare again.
\let\cmr\relax
\expandafter\ifx\tokens
  They are identical.
\else
  They are different tokens.
\fi
\makeatother
\end{document}

enter image description here

2
  • Typo in \ifx\helpI\helpII? The true text is the same as the false text.
    – egreg
    Dec 28, 2021 at 22:41
  • @egreg You're of course right. Thanks! Dec 29, 2021 at 12:50

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.