Reply to topic  [ 2 posts ] 
scientific macro 
Author Message

Joined: 2004-09-13 05:41:49
Posts: 3
I'm a chemistry teacher and one of the things I've always wanted to do with NW Express (and now with NW Pro) is duplicate a macro that I created for NW Classic that would take care of subscripting numbers in chemical formulas, superscripting powers of 10, and superscripting charges on chemical ions. The following macro seems to do this with a great deal of accuracy. I offer it to anyone who has need for it.

Powers of 10 should be entered as 6.2 X 106 or 6.2 X 10-6
Chemical formulas should be entered as Fe2(CrO4)3 or Fe4[Fe(CN)6]3
Ions as Fe(CN)64-

When you are done, highlight the entire block of text (or document if there are a lot of them) and select your macro from the "Macro" menu.

To create the macro copy the text below and follow the directions given in the documentation of either NW Express or NW Pro.


#Nisus Macro Block
#source front selection
#destination front selection
#Send Text as RTF
#End Nisus Macro Block

foreach $s (@myfile){
$s=~s/([A-Z][a-z]?[0-9]*)([0-9][+-])/$1\{\\super $2\}/g;
$s=~s/([A-Z][a-z]?)([0-9]*[+-])/$1\{\\super $2\}/g;
$s=~s/\)([+-])/\)\{\\super $1\}/g;
$s=~s/\)([0-9]+)([0-9][+-])/\)\{\\sub $1\}{\\super $2\}/g;
$s=~s/([A-Z][a-z]?)([0-9]+)/$1\{\\sub $2\}/g;
$s=~s/\)([0-9]+)/\)\{\\sub $1\}/g;
$s=~s/\]([0-9]+)/\]\{\\sub $1\}/g;
$s=~s/(\sX\s10|\sx\s10)([+-]?[0-9]*)/$1\{\\super $2\}/g;
print $s;

# end of script[code][/code]

2007-05-30 07:05:25
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Thanks for sharing. I don't work with scientific formulas, but there's always been a special place in my heart for properly sized and baselined numbers :)

2007-05-30 16:02:36
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software