Almost every subscript I write has to be in \text{..}, so to de-clutter, it would be nice to be able to write e.g. x_<high> instead of x_\text{high}.

(Shortening it to \t{..} is not quite as pretty.)

There was a similar question about using §...§ notation for this purpose, so the \def from the accepted answer there gives a half-way solution here. But the trouble is that I'll need \lt and \gt to map to < and > that would not be expanded in turn. I'm not sure what machinery to use here.

  • 1
    You could use a keyboard shortcut mapper instead. – Azor Ahai Jul 12 '17 at 16:08
  • @Azor-Ahai I use them heavily, but the lessons of markup and Markdown cannot be ignored... – Evgeni Sergeev Jul 16 '17 at 11:43
\AtBeginDocument{\catcode`_=12 \mathcode`_="8000 }
  • 3
    This lets you use < and > normally, e.g., \[ x_<high>>A_<op><B_<op> \]. – Manuel Jul 12 '17 at 13:39
  • If you want to be able to nest the _<<symbols>> then we can use xparse. – Manuel Jul 13 '17 at 2:40

It's pretty simple, actually. When you define some macro (or use \let to assign it) the current catcodes for the left hand side of the definition or assignment become fixed, so you can do the following:




A_<op>\lt B_<op>

The \AtBeginDocument part delays the actual catcode switching which can help with some packages that need the old category (for example for comparing numbers using \ifnum).

  • Neat! I guessed correctly that it doesn't allow nesting, but for some reason, if the nesting is through a macro, it works fine. For example, the following works: \newcommand{\xhigh}{x_<high>} \[ x + y = z <where $\xhigh = 0$ > \]. – Evgeni Sergeev Jul 13 '17 at 2:25
  • 1
    Or simply brace the index: \[ x + y = z < where $x_{<high>} = 0$> \]. – Sergei Golovan Jul 13 '17 at 5:40
  • I've been using this heavily the last couple of months. It caused much less side-effect trouble than may be presumed. Such a simple fix, makes a lot of difference. One strange thing I noticed is that if we \usepackage{mathtools}, it stops working, unless we also \usepackage[pdftex]{graphicx}. An interesting case of package-package interference... – Evgeni Sergeev Aug 21 '17 at 1:40
  • 1
    I've updated the answer mitigating somewhat the interference issue. – Sergei Golovan Aug 21 '17 at 5:14

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.