Skip to content

CJK-Latin-spacing not working with inline equation #2703

Open

Description

@jiaojiaodubai

Description

Minimum working example:

汉字$A$汉字

汉字 $A$ 汉字

I used to use LaTex and am currently learning Typst. I found that there is no automatic addition of spaces between the inline equation and CJK text. If the feature implemented in pull2334 is consistent, it should include the case of inline equation.

Reproduction URL

No response

Operating system

Windows

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Nov 17, 2023
  2. jiaojiaodubai commented on Nov 17, 2023

    @jiaojiaodubai
    Author

    As @Enter-tainer said, this issue is similar to the previous one (#2702), but the issues may need to be tracked and resolved one by one, so I create a separate issue.

  3. changed the title [-]The space between CJK and Latin does not work at inline equation[/-] [+]Whitespace between CJK & Latin not working with inline equation[/+] on Nov 17, 2023
  4. added
    text
    on Nov 18, 2023
  5. changed the title [-]Whitespace between CJK & Latin not working with inline equation[/-] [+]CJK-Latin-spacing not working with inline equation[/+] on Nov 18, 2023
  6. peng1999 commented on Nov 25, 2023

    @peng1999
    Contributor

    This is a workaround.

    #show math.equation: it => h(0.25em, weak: true) + it + h(0.25em, weak: true)
    汉字$A$汉字
  7. Enter-tainer commented on Nov 27, 2023

    @Enter-tainer
    Contributor

    This is a workaround.

    #show math.equation: it => h(0.25em, weak: true) + it + h(0.25em, weak: true)
    汉字$A$汉字

    cool! do we still need to embed this feature inside typst engine? i think this one is good enough.

  8. Enter-tainer commented on Jan 14, 2024

    @Enter-tainer
    Contributor

    Per discussion in Chinese typst user qq group. The weak space may not work well when it presents in line end. There will be extra space in line end.

    #set page(width: 8em, margin: (left: 0em, right: 0em))
    #set text(lang: "zh", region: "cn", font: "Source Han Sans SC")
    汉字$A$汉字 字$A$汉字
    
    #show math.equation: it => h(0.25em, weak: true) + it + h(0.25em, weak: true)
    汉字$A$汉字 0字$A$汉字
    
    
    image
  9. laurmaedje commented on Jul 22, 2024

    @laurmaedje
    Member

    Relevant update: Weak space at line ends is now trimmed.

  10. added
    cjk
    on Feb 10, 2025
  11. okumuralab commented on Jun 22, 2025

    @okumuralab

    Hacks like it => h(0.25em) + it + h(0.25em) are inappropriate when inline math is adjacent to punctuation or quotation marks, in which case space shouldn't be inserted. There's a very long discussion here: https://qiita.com/zr_tex8r/items/a9d82669881d8442b574 (in Japanese, sorry).

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

    bugcjktext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions