Skip to content

- and -- behave differently with no-break space than all other characters when inside zero-width box #6400

Open

Description

@Andrew15-5

Description

From forum.

#set box(width: 0pt) // Toggle
#set block(spacing: 0pt)
#set line(length: 1cm, stroke: 0.5pt + gray)
#for c in ("A", sym.dash.en, "-", "+", sym.dash.em, sym.hash) {
  line()
  block[#c#h(5pt)#box[#c~]]
  line()
}

Image

I also want to know how exactly stuff supposed to behave inside such box. And it's definitely should be documented. Maybe you should avoid using it? I don't know how it supposed to behave, so I assume it's like UB, so don't use it.

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Jun 6, 2025
  2. added
    layout
    on Jun 6, 2025
  3. MDLC01 commented on Jun 6, 2025

    @MDLC01
    Collaborator

    I assume a box with null width forces its content to break as much as possible. I don't think there is any special case to document here. What seems to happen here is that HYPEN MINUS and EN DASH allow a line break after them, even when followed by a non-breaking space, hence the additional line.

  4. th1j5 commented on Jul 17, 2025

    @th1j5

    Well, this is unexpected behaviour for me...

    Dit onderwerp is natuurlijk niet de hoofdzaak van deze @MPP, maar vind ik persoonlijk
    belangrijk genoeg
    --#{sym.space.nobreak}ook met het oog op *de educatie van wetenschappers in spe* --,
    dat ik dit als een secundaire doelstelling heb behandeld.

    Results in:
    Image

    Remark that in dutch, the en dash is used for thoughts, not the em dash (https://taaladvies.net/gedachtestreepje/).
    In this image, it should obviously be on the next line, certainly since I'm trying to force it with a non-breaking space.

    Edit: Remark that ... belangrijk genoeg #box[-- ook] met het ... fixes this, but I still think it is unexpected behaviour.

  5. MDLC01 commented on Nov 26, 2025

    @MDLC01
    Collaborator

    Related: In the example below, I would expect "test – test" to appear on a single line.

    #set page(width: 3cm, height: auto)
    Test test~--~test
    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglayout

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions