typst

How can I prevent the extra space introduced by line break in Typst?


In Typst,

This is a long-
distance travel.

will produce

This is a long- distance travel.

There is an additional space following long-. How can I get rid of it while keeping the manual line break?

I tried to add a backslash before the line break:

This is a long-\
distance travel.

But it won't work as it causes a real line break:

This is a long-
distance travel.

PS: Version and environment: v0.40 at https://typst.app


Solution

  • This behavior seems quite consistent: A single line break in the source is converted to a space in the rendered output.

    You can possibly avoid this with (hacky) workarounds such as adding #h(0pt, weak: true) after the - (or on the next line) or adding a #show "- ": "-" rule. However, these workarounds add additional complexity to your document and may have undesired side effects.

    The easiest solution is really to not wrap lines after - in the source:

    This is a long-distance
    travel.
    

    You could also try raising this as feature request in the Typst repository. In that case please cross-link with your Stack Overflow question here so others find the feature request in the future.