I would like to sometimes write subscripts using different syntax, instead of $u_{xx} blahblah$ write something like

  1. $u⎵xx blah blah$, or even
  2. $u⎵xx+blah blah$

where either space following the x in 1. or the plus sign in 2. kicks its out of the subscript.

Is this possible to do using something clever in TeX?

-I am using XeLatex

  • 1
    Is that intentionally Unicode Character 'BOTTOM SQUARE BRACKET' (U+23B5)? – Qrrbrbirlbel Jan 30 '13 at 19:32
  • 1
    Also I want Windows to work properly. But some things are just meant to be :) – percusse Jan 30 '13 at 19:36
  • the unicode character triggers this new syntax (I want to do something similar to my question tex.stackexchange.com/questions/94957/…), the difference here is that a character such as space or + is enough to exit (rather than a bracket) – georg Jan 30 '13 at 19:36
  • @percuße I believe TeX is flexible enough to do this – georg Jan 30 '13 at 19:37
  • It is possible but I don't think it's worth it considering all the exceptions. – percusse Jan 30 '13 at 19:49

It's really not a good idea to this in a document but as a TeX exercise, this has pdftex and xetex versions:

enter image description here


% E2 8E B5
\def\xcollectsub{\afterassignment\collectsub\global\let\tmp= }
\ifcat a\tmp

    $u⎵xx blah blah$, or even
    $u⎵xx+blah blah$

  • Why not recommend these answers? Which is least likely to break? – georg Jan 30 '13 at 20:12
  • 7
    The two answers are similar (I think the other one is assuming xetex/luatex but that could easily be extended to pdftex as in this one) Changing syntax is usually a bad idea. LaTeX isn't just an typesetting implementation, it should be thought of as a language, and if you make constructs that do not match the language syntax, they will confuse editors or convertors other than tex which and they usually will not mix and nest well with other latex constructs. Neither version is robust so will fail in captions and moving arguments (that's fixable) neither really works for nested subscripts.... – David Carlisle Jan 30 '13 at 20:29
  • I'm marking this one as the accepted answer because it works for an arbitrary number of subscripts. – georg Jan 30 '13 at 20:35
  • Also, can this be made to work with numeric characters ie u_01 ? – georg Feb 6 '13 at 4:31
  • @georgraba TeX is quite powerful enough to write parsers for any kind of syntax (I wrote a more or less complete xml+namespaces parser for example) but it's just a really bad idea to do that in the middle of a latex document. – David Carlisle Feb 6 '13 at 11:04

Not reccommended!

The ```⎵'' hallobit only shows that⎵` is not active within text mode.


\gdef ⎵{\qrr@subscript{}{}}
    \ltx@ifnextchar@nospace{ }{_{#1#2}}{%
\gdef\qrr@subscript@#1#2{% groups the second argument
``⎵'' hallo                       \par
$u ⎵xx f⎵rz $                     \par
$u ⎵xx+ x⎵rz- f⎵x\mathrm{text}x $ \par
$ f⎵x{ab \over cd}y $


enter image description here

  • strongly agree that this isn't recommended, but one might ask, since you've made it happen, why you can't fix things so that the braces around \mathrm{text} aren't needed either. (you've really asked for that request to be made.) – barbara beeton Jan 30 '13 at 21:04
  • @barbarabeeton I guess I did ask for it. I haven’t thought about that much to be honest. Of course, {text} lost its grouping by becoming #2 of the main macro. I could fix things, though, so that the braces aren’t needed. The auxiliary macro \qrr@subscript@ groups its second argument before handing it back over to the main macro \qrr@subscript. – Qrrbrbirlbel Jan 30 '13 at 21:38

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.