Skip to main content
Participant
February 26, 2021
Answered

Organizing subscripts/superscrits in a Chemistry book

  • February 26, 2021
  • 4 replies
  • 1039 views

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, H2SOor 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 🙂

This topic has been closed for replies.
Correct answer pixxxelschubser

Unfortunately, you cannot solve this with GREP in all cases.

This is possible, for example:

 

 

 

But there is no general GREP that can differentiate between these cases, for example!

NH4+

Ca2+

 

Sorry.

 

Finally:

Maybe it is possible if you can rewrite your chemical compounds.

  • From NH4+ you make NH41+

Then you set the "1" without fill color with font size 0.1pt and you can identify and edit these cases.

4 replies

pixxxelschubser
Community Expert
Community Expert
March 1, 2021

😄

The goal is formatting using Grep. Then the chemist should also think a bit as a grepper in order to achieve his goal.

pixxxelschubser
Community Expert
Community Expert
March 1, 2021

Some things are possible and some are not.

 

But it does not matter. I will first wait and see if the TO will answer.

FRIdNGE
March 1, 2021

A chemist knows how to write NH4+ or CA2+!

 

(^/)

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
February 27, 2021

Unfortunately, you cannot solve this with GREP in all cases.

This is possible, for example:

 

 

 

But there is no general GREP that can differentiate between these cases, for example!

NH4+

Ca2+

 

Sorry.

 

Finally:

Maybe it is possible if you can rewrite your chemical compounds.

  • From NH4+ you make NH41+

Then you set the "1" without fill color with font size 0.1pt and you can identify and edit these cases.

FRIdNGE
March 1, 2021

Of course, you can play your game with Grep styles! …

 

But here you will have to think first as a chemist and surely not as a grepper!  😉

 

(^/)  The Jedi

Participant
February 26, 2021

Sorry, the link might not work. Here's a complete list with a proper format: