Skip to content

Strict grid for CJK, hopefully via glue #4404

Open

Description

@neruthes

Description

The xeCJK package affords CJKglue and CJKecglue to allow precise control of inter-token spacing. I hope to be able to do similar in Typst. Specifically, what I intend to resemble is strict grid layout with CJK text.

In this example, the first line is bad because the 4 inter-character spacings between Hanzi/Kanji/Hanja are not zero.

image

\documentclass[12pt]{standalone}
\usepackage{fontspec,xeCJK}
\xeCJKsetup{PunctStyle=plain,RubberPunctSkip=false}

\begin{document}
    \begin{minipage}{25em}
        \leavevmode
        \vskip 2em
        \center
        \begin{minipage}{13em}
            这样是坏的This way is BAD这样是坏的

            \xeCJKsetup{PunctStyle=plain,RubberPunctSkip=false,CJKglue=\hskip 0pt,CJKecglue=\hskip 4pt plus 100cm minus 0.1pt}            
            
            这样是好的This way is good这样是好的
        \end{minipage}

        \vspace{2em}
    \end{minipage}
\end{document}

Use Case

Strict grid breaks into a few simple rules:

  • All Hanzi/Kanji/Hanja, Hiragana, Katakana, and full-width punctuation marks share exactly the same width. I have no idea about Hangeul; hopefully it does not require the same.
  • Any inter-character space between 2 of these characters is exactly 0pt wide.
  • In a justified line, the duty for stretching (when needed) is equally divided to CJK-nonCJK glues.
  • CJK-nonCJK spacing is ok to be arbitrarily large.

Activity

  1. added
    feature request
    on Jun 15, 2024
  2. added
    layout
    text
    on Jun 21, 2024
  3. added
    cjk
    on Feb 10, 2025
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

    cjkfeature requestlayouttext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions