I've seen samples of TeX using


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?

  • 1
    In the TeXBook by D. E. Knuth perhaps? It's a primitive, anyway – user31729 Jul 17 '15 at 7:10
  • 1
    \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 – user31729 Jul 17 '15 at 7:22
  • note that if you are using latex the supported syntax is \symbol{`\\} – David Carlisle Jul 17 '15 at 8:14
  • 1
    \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. – David Carlisle Jul 17 '15 at 8:28
  • 2
    There are three independent problems. First: knowledge about \char number ... it prints the character from the slot number of the current font. That is whole documentation. Second: number can be written in more TeX primitive formats. One of them is backtie some where some is backslash character or directly character (like \b or b). The backslash 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. – wipet Jul 18 '15 at 5:20

I cite the TeX By Topic book by Viktor Eijkhout.

Here is a an excerpt

enter image description here

\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

  • 5
    texdoc texbytopic to get a PDF of the book. – Torbjørn T. Jul 17 '15 at 7:31
  • @TorbjørnT: I've done that, but perhaps not everybody has the full TL installed, that's why I provided the link – user31729 Jul 17 '15 at 7:32
  • I started writing my comment (which I also edited to include a link) before you added the link. – Torbjørn T. Jul 17 '15 at 7:35
  • 1
    @retorquere That's no different from if you type in the character yourself. There's no certainly that the font used for output will look like the input: probably the most obvious example of this is using a pifont. – Joseph Wright Jul 17 '15 at 8:10
  • 1
    +1 I'd just emphasize more the word typeset: it's a rather common misunderstanding that \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. – egreg Jul 17 '15 at 8:18

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.