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. Commented Jul 12, 2017 at 16:08
  • @Azor-Ahai I use them heavily, but the lessons of markup and Markdown cannot be ignored... Commented Jul 16, 2017 at 11:43

2 Answers 2

\AtBeginDocument{\catcode`_=12 \mathcode`_="8000 }
  • 3
    This lets you use < and > normally, e.g., \[ x_<high>>A_<op><B_<op> \].
    – Manuel
    Commented Jul 12, 2017 at 13:39
  • If you want to be able to nest the _<<symbols>> then we can use xparse.
    – Manuel
    Commented Jul 13, 2017 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$ > \]. Commented Jul 13, 2017 at 2:25
  • 1
    Or simply brace the index: \[ x + y = z < where $x_{<high>} = 0$> \]. Commented Jul 13, 2017 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... Commented Aug 21, 2017 at 1:40
  • 1
    I've updated the answer mitigating somewhat the interference issue. Commented Aug 21, 2017 at 5:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .