I am looking for wisdom i.e. potential side-effects that I may not have considered.. Underscores are quite common and irritating for inexperienced LaTeX users to escape. Let's assume that I have no interest in subscript of math mode. Is it safe to set underscore to a non-active character?
By default _ is for subscript and you need to convert it to a literal character by prefixing it with a catcode 0 \
.
Is there any danger of making life easier by putting this in my document?
Category 12 Other Character
\catcode`\_=12 %
\catcode`_=12 %
\catcode"005F=12 % unicode decimal syntax
\catcode'137=12 % octal syntax
\catcode95=12 % decimal syntax
or
Category 11 Alphabetic Character
\catcode`\_=11 %
\catcode`_=11 %
\catcode"005F=11 % unicode decimal syntax
\catcode'137=11 % octal syntax
\catcode95=11 % decimal syntax
My thought is that it would not be if done at the right time (after loading all packages).
Notes
- I am using
xelatex
withfontspec
, therefore I ensure that all of my documents are UTF-8 encoded. etoc
adds stuff to the\contentsline
which means that the catcode of underscore must be changed prior to definition time of these macros, otherwise when the .toc is read after\begin{document}
on the following run, an underscore will be read as catcode 8 within the\contentsline
macro even if you set it later, because the group protects any postdefinition changes.
T1
encoding. Otherwisea_b
would producea ̇b
, rendering the_
as a raised dot. – egreg Mar 22 '17 at 12:24fontspec
. – Jonathan Komar Mar 22 '17 at 12:25\catcode`\<char>=12
is equivalent to\catcode`<char>=12
(unless<char>
has category code 0, 5, 9 or 15). – egreg Mar 22 '17 at 12:27\begin{document}
macro. It is not enough to just set the catcode after\begin{document}
. – Jonathan Komar Mar 22 '17 at 12:51