nisus.com
https://www.nisus.com/forum/

Macro to make digits superscript and add non-breaking space
https://www.nisus.com/forum/viewtopic.php?f=17&t=5269
Page 1 of 1

Author:  NisusUser [ 2013-03-01 00:59:46 ]
Post subject:  Macro to make digits superscript and add non-breaking space

I would like to make a macro that will render in superscript sequences of digits (from 1 to 3 digits). These sequences of digits always occur with a space before and after them. I want the space after them to be changed to a non-breaking space.

The attached screenshot shows what I came up with. It changes the space following to a NBS, but I can't figure out how to include superscript in the "Change to" portion.

BTW, I found it strange that in the "Special Characters" pallette there was "Space", but none of the unusual spaces. Nonetheless, Cmd-NBS worked to insert it.

Thanks for your help!

Oops, I forgot to mention that I only want this to be done to text in a certain style. How do I do that? Thanks.

Attachments:
Attempt to superscript digits and add NBS.png
Attempt to superscript digits and add NBS.png [ 45.3 KiB | Viewed 6625 times ]

Author:  phspaelti [ 2013-03-01 02:29:58 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

NisusUser wrote:
It changes the space following to a NBS, but I can't figure out how to include superscript in the "Change to" portion.


Just apply the formatting in the usual way :)

Author:  phspaelti [ 2013-03-01 02:31:05 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

NisusUser wrote:
Oops, I forgot to mention that I only want this to be done to text in a certain style. How do I do that? Thanks.


Just apply the style in the usual way :) :)

Author:  phspaelti [ 2013-03-01 02:43:17 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

PS: In case my comments aren't clear: The Find and Replace window allows formatting just like any other window. If may feel a little strange to apply formatting to wildcards, but it works just the same.
And about the special space: If Nisus wanted to add all the possible special characters possible in that menu it would get very crowded. But you can just type them in to the Find or Replace box. Or you can use Unicode notation, if you prefer the "code" look.

Author:  NisusUser [ 2013-03-01 06:07:27 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

phspaelti wrote:
Just apply the formatting in the usual way :)


Well, I admit I felt silly for not thinking of that, especially since I was able to figure out the Cmd-NBS part. However, I'm afraid I'm going to have to admit to a more severe case of inability here: I tried to format the target text. As soon as I click on the superscript button in the Character pallette, the Find box goes away. Well, OK, I thought, it probably "took" the attributes, but just lost focus. However, I tried the Find/Replace routine, and it does not work, i.e. the paragraph style I tried to apply to the Find and Replace boxes doesn't seem to have stuck, either (can only character styles be applied?). And the superscript didn't stick.

What am I doing wrong?

Author:  phspaelti [ 2013-03-01 06:47:21 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

NisusUser wrote:
phspaelti wrote:
Just apply the formatting in the usual way :)


Well, I admit I felt silly for not thinking of that, especially since I was able to figure out the Cmd-NBS part. However, I'm afraid I'm going to have to admit to a more severe case of inability here: I tried to format the target text. As soon as I click on the superscript button in the Character pallette, the Find box goes away. Well, OK, I thought, it probably "took" the attributes, but just lost focus.

Ok, so maybe not that "usual way". The palette belongs to the document window. You will have to apply the superscript using the menu (or a key combination).

NisusUser wrote:
However, I tried the Find/Replace routine, and it does not work, i.e. the paragraph style I tried to apply to the Find and Replace boxes doesn't seem to have stuck, either (can only character styles be applied?). And the superscript didn't stick.

What am I doing wrong?

No, any styles can be applied, but generally you will have to apply them from the regular menus. Also make sure that you don't apply any style that you do not want. Make sure the text is completely free of styles before you start. If necessary select all text in the Find box and use "Remove Attributes and Styles" from the menu, if necessary. Then apply only the styles you want.

Author:  NisusUser [ 2013-03-01 06:58:03 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

Thanks, Philip. That helps.

But why do I only have "Remove Attributes Except Styles" in the Format menu (see screenshot attached)?

Attachments:
Format menu 2.0.4.png
Format menu 2.0.4.png [ 70.73 KiB | Viewed 6607 times ]

Author:  phspaelti [ 2013-03-01 07:06:44 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

You're right in the Find box that menu command changes to "Any attributes" which is better. And since it's checked in your case you have "any attributes", so no stray attributes there.

Author:  NisusUser [ 2013-03-01 07:22:42 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

I think I'm getting somewhere now, but I've never seen (nor do I now see) a "Superscript" menu item in the Format menu. I've always used the Character pallette. I don't really want to create a character style and have to deal with that, too. Am I just missing the "Superscript" command somewhere?

Ei, yai, yai! Found it! Format > Baseline. :)

Author:  NisusUser [ 2013-03-01 07:39:22 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

Strangely enough, the find-replace regex is working fine (see screenshot). However, I macroized it, and the macro doesn't find anything to change. Also, it seems to me the macro doesn't have the attributes included.

More sage advice? :) By the way, thanks, Philip, for all your help!

Attachments:
Working Find-Replace for digits to superscript + NBS.png
Working Find-Replace for digits to superscript + NBS.png [ 45.89 KiB | Viewed 6603 times ]
Non-working Macroized F-R for digits to superscript + NBS.png
Non-working Macroized F-R for digits to superscript + NBS.png [ 17.64 KiB | Viewed 6603 times ]

Author:  phspaelti [ 2013-03-01 07:54:24 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

Your screen shot indicates that the superscript attribute did get transferred to the macro. However this is a known difficulty. You should be able to fix this by editing the macro. Open the macro select the line with the find expression and check the style. Here you will have to use "Remove Attributes and Styles" if necessary, and apply the ones you want.

Author:  NisusUser [ 2013-03-01 08:04:03 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

I think what you were saying is that the Paragraph Style didn't transfer. That's maybe probably because it opened a new file that did not yet have that style in it. I opened the macro file, added the Paragraph Style, applied it. It works! I think the case is closed! :) Thanks so much for your patience, Philip.

Author:  phspaelti [ 2013-03-01 08:10:25 ]
Post subject:  Re: Macro to make digits superscript and add non-breaking sp

Good. I'm glad you got it working.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/