I've seen samples of TeX using
\char`\\
to produce a literal backslash. Where can I find documentation on what the \char
command does? Is it a generic construct to safely produce reserved literals?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI cite the TeX By Topic book by Viktor Eijkhout.
Here is a an excerpt
\char
is basically just for conversion of numbers to a character representation, using the underlying encoding.
'82
uses octal numbers, "82
means hexadecimal numbers.
The last sentence in this excerpt says all: typeset character number so-and-so
\char
produces the character for later usage in a token list, but this is false. With XeTeX and LuaTeX one can use \Uchar
for that.
\char number
outputs the letter/symbol according to the encoding:\char 65
would print 'A' (Ascii code),\def\foo{66}
and\char\foo
would print 'B' then\symbol{`\\}
\char`\\
does not typeset a\
it typesets whatever is in slot 92 in the current font which is a double quote in classic TeX (OT1) encoding.\char number
... it prints the character from the slotnumber
of the current font. That is whole documentation. Second:number
can be written in more TeX primitive formats. One of them isbacktie some
wheresome
isbackslash character
or directlycharacter
(like\b
orb
). Thebackslash character
format is more compact when you are using special characters. Third: you need to have the right character in the given slot of actual font. This is not always true in classical Knuth's fonts as mentioned by David.