Organizing subscripts/superscrits in a Chemistry book
Hi everyone,
I'm designing a Chemistry coursebook, and dealing with a lot of chemical compounds, anions, cations etc. All of them use subscripts and superscrips - for an amount of elements - O2, Na2, Ca(OH)2, H2SO4 - or cations/anions - ClO4-,Ca+2, Li+.
So far, I've been using GREPs to put all digits as subscripts:
(?<=\l|\u)(\d{1,3}), (?<=\))(\d{1,3}) and (?<=\l|\u)(+|2+|3+|4+|-|2-|3-).
But that's not enough when I insert an advanced anions, eg. NH4+, AsO43-, PO43-, SO42-. In these examples, digits become subscripts and minuses and pluses stay on a standard level:

I'd like to prepare one, or few, GREP styles to automate the process. There's a list of most popular anions and cations: http://myweb.astate.edu/mdraganj/cationanion.html, is it better to make a one specific GREP, list all of them as 'exceptions' to the rules? Or is there another way to do it?
Thank you for your time and for a help 🙂


