Using double backticks to escape backticks in inline code, from https://tex.stackexchange.com/a/543571/134574
\textbackslash
is just for typesetting. As the name says, it's a text command, so it just prints the character \
from the current font, and isn't of any use for anything other than that.
You are looking for:
\catcode`\\=12
The syntax for the \catcode
primitive is \catcode<number>=<catcode>
, and it sets the catcode of the character whose ASCII code is <number>
to <catcode>
. This means that you could also use:
\catcode 92=12
However it's a mouthful to remember all the ASCII codes, and your code becomes quite a lot less readable. To improve on that TeX allows you to specify a number using an “alphabetic constant”. To do that, the <number>
should start with a `
, followed by the character token you want to make a number of. Valid alphabetic constants are `a
, `*
, etc.
The only problem is that a catcode-0 character (here the backslash) doesn't produce a token, so neither:
\catcode`\=12
\catcode`\ =12
do what you want (the first one changes the catcode of =
, and the second the catcode of
). To specify these characters, TeX allows you to escape the character with a backslash, so to specify the alphabeitc constant `\
you prefix it with another backslash: `\\
, so:
\catcode`\\=12
Bonus, from https://tex.stackexchange.com/a/516660/134574, using three backticks to escape double backticks
As Mico noted, when two `
are used (like in ``should''
) you usually don't want to apply the special formatting. To detect this case you can check that the argument of active-`
is empty and then use the original `
character instead.
Or more generally, using n+1 backticks to escape n backticks:
`````````````````````````