2

I want to make several middle-aligned paragraphs, this is the code:

\usemodule[zhfonts] % zhfonts is a third-party module which created by Liyanrui, for selecting Chinese fonts,font size, etc. 
% https://github.com/liyanrui/zhfonts

\starttext
    \startalignment[middle]
        天地玄黄

        宇宙洪荒
    \stopalignment

    \midaligned{天地玄黄}

    \midaligned{宇宙洪荒}

    \startalignment[middle]
        \hbox{天地玄黄}

        \hbox{宇宙洪荒}
    \stopalignment
\stoptext

The code above doesn't produce the desired effect, for it doesn't deal with the distance between characters. (Compare it with the \midaligned command.)

When put the characters in a hbox, the two paragraphs become left justified!

How to modify \start ... \stopalignment environment to get the effect produced by \midaligned command?

enter image description here

6
  • request to put the code for MWE starting with \documentclass and terminating with \end{document}
    – js bibra
    Dec 9, 2019 at 13:33
  • 2
    ConTeXt, not LaTeX.
    – gannaiju
    Dec 9, 2019 at 15:15
  • 2
    Use \startalignment[middle,broad] to get rid of the space between the characters. Dec 9, 2019 at 17:44
  • \hbox doesn't start a paragraph. You have to do \dontleavehmode\hbox. Dec 9, 2019 at 20:19
  • @WolfgangSchuster Thanks! It really helps, just the effect I desire.
    – gannaiju
    Dec 10, 2019 at 17:57

1 Answer 1

1

When you enable line breaking for chinese text with the \setscript command ConTeXt add a small veriable space between all chinese letters. This space is needed to fill the available space on each line and to compensate for gaps from punctuation and quotation marks.

When try to center text in a alignment environment the filler material at the left and right of the text isn't stron enough the cancel out the stretchable text between each letter. You can use the broad keyword for the alignment to get a stronger filler material which prevent the space between the letters to used to fill the line.

Another way to prevent the space between the letters is to put them in a \hbox but in this case you have to add \dontleavehmode in front of each box to ensure it is centered on the line.

\definefontfamily [mincho] [rm] [MS Mincho]
\definefontfamily [mincho] [ss] [MS Gothic]
\definefontfamily [mincho] [mm] [Latin Modern Math]

\setupbodyfont [mincho]

\setscript [hanzi]

\starttext

\startalignment[middle]
  天地玄黄\par
  宇宙洪荒
\stopalignment

\blank

\startalignment[middle,broad]
  天地玄黄\par
  宇宙洪荒
\stopalignment

\blank

\startalignment[middle]
  \dontleavehmode\hbox{天地玄黄}\par
  \dontleavehmode\hbox{宇宙洪荒}
\stopalignment

\stoptext

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .