3

In ConTeXt one can change the catcodes such that (almost) all the special characters print themselves in text mode, while some of them keep their original meaning in math mode (e.g. _ and ^). The corresponding command is \asciimode.

\asciimode
\starttext

#$%&^_|~  %% these are disabled

\ { }     %% these remain enabled

\stoptext

My question is, what would be the side effects in standard LaTeX if there was such a thing, or more specifically, are there macros in standard LaTeX which assume a certain catcode regime?


This question is partly inspired by Aditya's nice blog post Some thoughts on lowering the learning curve for using TeX.

  • Note that the catcode being used here is not 'letter' but 'other'. Also, do you want to limit the question to LuaTeX or are other engines also involved? – Joseph Wright Dec 19 '16 at 17:52
  • if you just do that for the body of a document then mostly things should work as you expect and it often makes sense to do that, for example if you have text with a lot of percentage values and no tex comments making % a normal character often makes sense. – David Carlisle Dec 19 '16 at 18:31
  • @JosephWright I am not sure to what extent the formats differ but I am targeting more towards a user perspective, i.e. would catcode changing commands like \verb still work as they are expected to? – Henri Menke Dec 19 '16 at 18:31
  • 2
    @HenriMenke yes the issues are mostly around external files, for example if % is not special you can go \label{ab%c} which means that you need % to be not special when the .aux file is read, which means that you need to make sure no package writes tex comments to the aux file.... – David Carlisle Dec 19 '16 at 18:34
  • 1
    @egreg In ConTeXt's ASCII mode %% is a comment: needs LuaTeX magic. That's why I asked about the target engine ... – Joseph Wright Dec 19 '16 at 20:11
4

You can of course vary the details of exactly what is redefined, and when but

enter image description here

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\let\tablesep&

\makeatletter
\AtBeginDocument{%
\@makeother\#%
\@makeother\$%
\@makeother\&%
\@makeother\%%
\@makeother\^%
\@makeother\_%
\@makeother\~%
}
\makeatother

\newcommand\mycmd[2]{aaa(#1)(#2)}

\begin{document}

one # $ & ^ _ ~ two

\(x\sp{2}\)  

\begin{tabular}{|c|c|}
aaa \tablesep bbb \\
1 \tablesep 2
\end{tabular}

\verb| \{^} |

\mycmd{$$$}{%%%}



\end{document}
  • IIRC, ConTeXt changes the catcodes in math mode (using everymath, I believe). So, ^ and _ work in math mode. – Aditya Dec 21 '16 at 1:03
  • @Aditya well that's easy enough to do as well of course (I wouldn't change catcodes though it wouldn't work inside macros, but simply make ^ be active and let to a ^ in text and \sp in math – David Carlisle Dec 21 '16 at 1:16
  • ConTeXt goes out of the way to avoid active characters. I don't understand the TeX internals well enough, but I remember that lot of the "bugs" reported in the context mailing list in pdftex days (related to utf encoding) were due to active characters. – Aditya Dec 21 '16 at 23:33

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.