Changing the numbering scheme for footnotes

Get help using and writing Nisus Writer Pro macros.
Post Reply
vwnisus
Posts: 58
Joined: 2016-04-24 00:13:31

Changing the numbering scheme for footnotes

Post by vwnisus »

For some files I receive from another, the numbering scheme for footnotes is a, b, c, etc rather than 1, 2, 3.

A brief look at the Nisus manual indicates that it is necessary to change this in the Footnote style, which is easy to do manually.

But is it possible to change a the Footnote style with a macro?
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Changing the numbering scheme for footnotes

Post by phspaelti »

Hello vw,
I don't see any way to change the list style directly with a macro, but what you could do is just replace it with a list style with the same name and your desired formatting. So this problem will look a bit like the one you were asking about before.

Here's one way to do that.

Code: Select all

$styledBit = '
1.	bit with list style applied' # This line should have the desired list style applied

# Get the list style from the text above
$attr = $styledBit.attributesAtIndex 2
$listStyle = $attr.listStyle

# Replace the list style in the target doc with the one from the macro
$doc = Document.active
$doc.addStyles $listStyle, 'replace'
I do have one caveat. When I tried the above macro, it worked, but the effect was not immediately obvious. The list style definition was changed to that of the replacing style, but the text in the document did not reflect the change. This seems to be a bug. Saving and reopening the document showed the replacing list style.
philip
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Changing the numbering scheme for footnotes

Post by martin »

Philip's suggestion to replace the style is a good one, but I don't think replacing any list styles will accomplish the original goal. To update the footnote reference numbering format (1,2,3 vs a,b,c) you want to instead replace the document's Note style. A macro like this should do the trick:

Code: Select all

$macroDoc = Document.macroSource
$noteStyle = $macroDoc.styleWithName("Footnote")

$doc = Document.active
$doc.addStyles($noteStyle, "replace")
You can see the macro obtains the Footnote style defined in the macro document itself, and adds it to the target document. Any customizations you've made to the Note style in the macro file will take effect in the target document.
Attachments
Footnote Style Changer.nwm.zip
(2.55 KiB) Downloaded 791 times
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Changing the numbering scheme for footnotes

Post by phspaelti »

Martin’s right. I seem to have misread the problem and tried to solve the wrong thing.
philip
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Changing the numbering scheme for footnotes

Post by martin »

phspaelti wrote: 2018-11-02 08:33:54 Martin’s right. I seem to have misread the problem and tried to solve the wrong thing.
All the same your macro code did turn up a bug. The list style really is very stubborn. It doesn't update or even show correctly in the Style View until you close and reopen the file. I'll file a bug, thank you!
Post Reply