Help with Macro sentence spacing

Get help using and writing Nisus Writer Pro macros.
Post Reply
Louch1970
Posts: 1
Joined: 2022-11-10 19:05:17

Help with Macro sentence spacing

Post by Louch1970 »

Hi Everyone

I am in the process of formatting the final copy of my PhD thesis. My examiner has advised me to reduce my spacing after full stops (periods) to single spacing (I usually use double spacing after periods). I found a very helpful macro for NWP in this forum and applied it but I now have a new issue. I now have a single space between periods and footnote numbers (over 1200 of them!) Just in case this doesn't make sense, this is what it now looks like:

Figure 99: Boy training dog. 1 (where the 1 is superscript. There is a single space between the . and the 1)

but I need it to look like this:

Figure 99: Boy training dog.1 (where there is no single space between the period and superscript 1).

Can anyone offer me some help with a macro? I totally don't understand macros. I have read the user manual but it doesn't really help me.

Much appreciated!
Julie
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Help with Macro sentence spacing

Post by martin »

Hi Julie!

The good news is that this shouldn't be too hard. I'm attaching a macro that takes a stab at doing what you want. It should eliminate all space characters in front of footnote references in the main body text, no matter how many spaces occur. The macro uses the term "footnotes" but it also processes all endnotes.

Please let us know if you have any questions or troubles.
Attachments
Footnotes, Eliminate Spaces Before References.nwm.zip
(2.6 KiB) Downloaded 144 times
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Help with Macro sentence spacing

Post by adryan »

G'day, Julie et al

Double spacing after concluding sentence punctuation was common practice in the days of typewriters because they used monospaced fonts. Although there are some computer fonts that are monospaced (eg, Courier), most are proportional and with them it's best to use single spacing and leave the rest to the font software. Double spacing is particularly problematic if you fully justify the text.

A couple of motivational points:–

(1) The extra energy expended over a lifetime of double spacing is likely to be associated with a not insignificant contribution to global warming and increased risk of RSI.
(2) Your examiner is always right.

Good luck with your thesis.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
User avatar
xiamenese
Posts: 543
Joined: 2006-12-08 00:46:44
Location: London or Exeter, UK

Re: Help with Macro sentence spacing

Post by xiamenese »

In the spirit of stable door shutting… I didn't know about that macro, but my solution would simply have been to use Find & Replace. You set it to find all double spaces and replace them with single spaces. Not only would it replace those you typed deliberately after full stops, but it would also replace any accidentally inserted between words. I have someone who sends me texts full of unwanted double spaces, even triple spaces, so that is the first thing I do before I've even read the text!

:D

Mark
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Help with Macro sentence spacing

Post by adryan »

G'day, Mark et al

Just so. I usually have Show Invisibles activated all the time, and it is quite irritating to see all the extraneous junk people have in their text. Leading and trailing paragraph spaces are very common.

One has to be a little bit careful about replacing each string of spaces with a single space because many people violate the Third Law of Text Formatting which is: "Never use spaces to force text alignment." That is, they should be using ruler indents and tabs instead. Any string of more than three spaces (say) should probably be replaced by a tab in the first instance, just in case.

The interesting question is: How did Julie end up with the situation she found herself in? I suspect that she typed a sentence, concluded it with a period, followed that with a couple of spaces, and only then used the Insert Footnote command. But she should instead have invoked the Insert Footnote command immediately after the period. She would still have needed to replace the redundant spaces everywhere, to please the Gods of Textual Aesthetics (and her examiner), but the note references wouldn't have been separated from the text they're attached to.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
User avatar
xiamenese
Posts: 543
Joined: 2006-12-08 00:46:44
Location: London or Exeter, UK

Re: Help with Macro sentence spacing

Post by xiamenese »

The interesting question is: How did Julie end up with the situation she found herself in? I suspect that she typed a sentence, concluded it with a period, followed that with a couple of spaces, and only then used the Insert Footnote command.
I think we'd need to see the macro Julie found. The way I read her post, I understood that it was the macro that put a space between the full-stop and the footnote marker where there hadn't been any before.

:D

Mark
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Help with Macro sentence spacing

Post by phspaelti »

Indeed. In all likelihood it was a "clean up" macro that tried to enforce one and only one space after periods, perhaps excluding periods followed by quotation marks.

Which brings up the question how one might write such a macro that avoided doing that. My first reaction to this problem was that one could use Find to find footnote markers. But this doesn't seem to be possible. If you convert a footnote marker to a its Unicode points, it just gives you the Unicode points of the number that's being shown (\x0031 for a "1", \x0032 for "2", etc.) But searching for a "1" does not find footnote marker "1".
This explains why Martin's macro has to cycle through the Note objects to find the footnote markers.
philip
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Help with Macro sentence spacing

Post by adryan »

G'day, Philip et al

Mark is quite right when he says we really need to see the Macro that Julie used.

Pending such enlightenment, and perhaps more out of pursuit of the intellectual exercise than anything, I still think it likely that she failed to insert the footnote reference immediately after the period. She may only have put one space, but I presumed her automatic reflex caused her to put two.

The Macro may have reduced the number of spaces to one, but I would be very surprised if it actually inserted a space where previously there was none. This is because it would be unlikely to recognize a period followed immediately by a note reference as a period denoting the end of a sentence. After all, not all periods function as sentence terminators. Decimal points, section numbering and figure designation are three other uses that come to mind. If the Macro failed to insert unwelcome spaces in these situations, it would be unlikely to do so in the case of note referencing.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Help with Macro sentence spacing

Post by martin »

phspaelti wrote: 2022-11-16 22:25:46 Which brings up the question how one might write such a macro that avoided doing that. My first reaction to this problem was that one could use Find to find footnote markers. But this doesn't seem to be possible. If you convert a footnote marker to a its Unicode points, it just gives you the Unicode points of the number that's being shown (\x0031 for a "1", \x0032 for "2", etc.) But searching for a "1" does not find footnote marker "1".
This explains why Martin's macro has to cycle through the Note objects to find the footnote markers.
That's correct, there are no special character codes used to represent footnote references. They are indistinguishable from other content when considering the document as a plain text stream of characters.

Nisus Writer's normal find/replace does indeed skip footnote/endnote references. It's unlikely a user actually wants to replace such text during normal find/replace operations. It's not really possible in the usual way because the text is automatically governed and atomic, e.g. you can't replace a single digit in a footnote reference with multiple digits (replace just "1" in "123"). Such a reference would be automatically reverted.

However you can override this by using the "n" option in macros like so:

Code: Select all

Replace All "1", "x", "n"
That would replace the digit "1" even inside a footnote reference, which basically destroys the footnote. The footnote reference is replaced with a normal "x" character and its footnote is removed.

It would be nice if there were some special Nisus-specific regex pattern to match special objects like whole footnote references, e.g. inside positive/negative lookahead. But this is not possible. A macro must scan using Note objects.
Post Reply