Hej!
Is there a macro to change all the "st, nd, rd, th" (that follow a number) to superscript in an entire document?
Grazie,
Chnage all "st" "nd" etc. to superscript
Re: Chnage all "st" "nd" etc. to superscript
Does this work for you?
This one requires NWP 2.0.
EDIT: Removed a redundant command.
EDIT: Fixed a typo in the find expression.
Code: Select all
Require Pro Version 2.0
define Command SuperscriptOn
$sp = ':Format:Baseline:Superscript'
$check = Menu State $sp
while $check != 1
Menu $sp
$check = Menu State $sp
end
end
$numFound = Find All '(?<=[0-9])(?:st|nd|rd|th)\b', 'E-i'
if ! $numFound
exit 'Nothing found, exiting…'
else
SuperscriptOn
end
EDIT: Removed a redundant command.
EDIT: Fixed a typo in the find expression.
Last edited by Kino on 2011-05-26 09:09:58, edited 2 times in total.
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Chnage all "st" "nd" etc. to superscript
Kino's macro is great if you have an existing document that you need to format nicely, but I just wanted to mention that QuickFix can do this for you automatically as you are typing up new documents. Open up NWP's QuickFix preferences and turn on the option "superscript ordinals" for the desired languages.
Re: Chnage all "st" "nd" etc. to superscript
Hello, Kino.
There’s a tiny flaw in line 12. Unless you plan to have rd always followed by a comma, this…
$numFound = Find All '(?<=[0-9])(?:st|nd|rd,|th)\b', 'E-i’
should be substituted by this…
$numFound = Find All '(?<=[0-9])(?:st|nd|rd|th)\b', 'E-i’
Greetings, Henry.
There’s a tiny flaw in line 12. Unless you plan to have rd always followed by a comma, this…
$numFound = Find All '(?<=[0-9])(?:st|nd|rd,|th)\b', 'E-i’
should be substituted by this…
$numFound = Find All '(?<=[0-9])(?:st|nd|rd|th)\b', 'E-i’
Greetings, Henry.
Re: Chnage all "st" "nd" etc. to superscript
Ah, that's a typo. Thank you for pointing it out.Groucho wrote:There’s a tiny flaw in line 12.