Tip: how to keep adjacent text together on the same line

Everything related to our flagship word processor.
Post Reply
martin
Official Nisus Person
Posts: 4693
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Tip: how to keep adjacent text together on the same line

Post by martin »

Here's a quick tip from our recent blog post on how to keep text together using a zero-width joiner character. You can insert the joiner between two characters to ensure those neighboring characters appear on the same line. This is useful in situations like this:

Image

In the above screenshot you can see that the words "when/if" have been split between two lines. If you place the insertion point (aka caret) after the slash and use the menu Insert > Special Character > Spaces > Zero Width Joiner the joiner will ensure the slash and "i" are kept together. The line wrapping point will be adjusted like so:

Image

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

Re: Tip: how to keep adjacent text together on the same line

Post by adryan »

G’day, Martin et al

Yeah, but….

It’s not actually zero width, as Align Justify will (usually) demonstrate.

As Martin says, you can position the insertion point immediately after the slash, but this has to be done directly with the cursor in that position. You can’t position the cursor immediately before the “if” and then use the back arrow because that will position the insertion point before the slash. However, you can position the cursor immediately before the “if” and then insert the joiner right there.

You also need to be aware that Find/Replace may give unexpected results.

Cheers,
Adrian
MacBook Pro (mid-2014)
macOS Mojave 10.14.6
Nisus Writer user since 1996

martin
Official Nisus Person
Posts: 4693
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Tip: how to keep adjacent text together on the same line

Post by martin »

adryan wrote:
2020-05-04 23:12:08
It’s not actually zero width, as Align Justify will (usually) demonstrate.
In a quick test it seems to me that the zero-width joiner does not affect how full justification spaces the line:

justify.png
justify.png (18.48 KiB) Viewed 656 times

In the above screenshot the zero-width joiner is again after the slash and before the "i" in "if", but you can see the letters remain equally spaced. There is no additional space allocated for the zero-width joiner. Or did you mean something else?
You can’t position the cursor immediately before the “if” and then use the back arrow because that will position the insertion point before the slash.
There's nothing unexpected about that! That's exactly how the insertion point should behave. The arrow keys must allow you to move the caret around and skip adjacent characters.
However, you can position the cursor immediately before the “if” and then insert the joiner right there.
Exactly so. But again, there's nothing unusual about that. This is all normal insertion point behavior. You can get the insertion point where it needs to go however you like before inserting the joiner.
You also need to be aware that Find/Replace may give unexpected results.
That is however true and is a real drawback. The joiner will disrupt find operations that try to match text around the joiner. You won't have any trouble finding "when" or "if" in the example, but you would fail to match the whole "when/if" compound term, or even just "/if".

This deficiency in the joiner points to the need to add a "keep together" formatting command. That way text can be marked for the same line without editing the underlying characters.

Thanks for your thoughts and reply Adrian!

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

Re: Tip: how to keep adjacent text together on the same line

Post by adryan »

G’day, Martin et al

Yes, such a special-purpose command would be better.

The attached file shows the joiner with a clearly non-zero width. In fact, by inserting or deleting characters in a subsequent word in that line, you can see the joiner width expanding or contracting before your very eyes!

%22Zero%22 Width Joiner.rtf
(20.2 KiB) Downloaded 11 times

My other comments were more just in the nature of a “heads-up” for anyone using this method.

Cheers,
Adrian
MacBook Pro (mid-2014)
macOS Mojave 10.14.6
Nisus Writer user since 1996

martin
Official Nisus Person
Posts: 4693
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Tip: how to keep adjacent text together on the same line

Post by martin »

adryan wrote:
2020-05-05 13:59:36
The attached file shows the joiner with a clearly non-zero width. In fact, by inserting or deleting characters in a subsequent word in that line, you can see the joiner width expanding or contracting before your very eyes!
That's interesting Adrian. Thank you for the example file that showcases the unwanted spacing.

It looks like the extra spacing occurs in your file because the chosen font (Palatino) cannot display the zero-width joiner. That may seem like an odd statement, but technically the font validates each and every character in the text, including whitespace and zero-width characters. If the font doesn't specifically include the character in its display repertoire then Nisus Writer must calculate a fallback font. The mismatched fonts cause the unwanted spacing.

Try some other fonts and you should see that the zero-width joiner usually doesn't affect spacing. For example, the joiner behaves properly with Times New Roman, Arial, Lucida Grande, Tahoma, etc. But this behavior is not universal, even when the font is uniform. For example: "Courier New" behaves properly, but "Courier" undesirably reserves space for the joiner.

Ultimately the font gets to control the spacing. This is intentional. For example: the thin space character can be a different width in different fonts.

Post Reply