3

When I compile the following code containing partial Korean Hangeul characters with XeTeX, the characters are not displayed properly. When compiling with LuaTeX they are set overlapping each other, as they should.

What is the reason for the different output? I would prefer to use XeTeX, but can I enable it to work with these characters as well?

\documentclass{scrarticle}
\usepackage{ifxetex,ifluatex}

\ifxetex
    \usepackage{fontspec}
    \usepackage{xeCJK}
    \setCJKmainfont{Batang}
\else\ifluatex
    \usepackage{fontspec}
    \usepackage{luatexko}
\fi\fi

\usepackage{xcolor}
\newcommand{\noV}{{\color{black!20}ᅟᅳ}}

\begin{document}
    
    Only works in Lua\TeX: \noV ᆯ 
    
    Only works in Lua\TeX: \noV ᆼ 
    
    Full characters always work: 한글
    
\end{document}

XeTeX Output:
enter image description here

LuaTeX Output:
enter image description here


Edit:

\color does not seem to be the culprit

...
\begin{document}
    
    Still only works in Lua\TeX: ᅟᅳᆯ
    
    Still only works in Lua\TeX: ᅟᅳᆼ
    % Stack.EX can compose them too :o
    
    Full characters always work: 한글
    
\end{document}

XeTeX Output:
![enter image description here

LuaTeX Output:
enter image description here


Since this editor already displays the partial chars in combination, for clarity, I'll list the characters separately:
the filler "ᅟ" (U+115F)
followed by the vowel "ᅳ" (U+1173)
followed by "ᆯ" resp. "ᆼ" (U+11AF and U+110B)

4
  • 1
    The color command is the problem. \color insert whatsits between the chars and so disable ligatures and similar. xetex has no tools to handle this. So either don't use a color, or use lualatex. – Ulrike Fischer Mar 23 at 7:22
  • @UlrikeFischer The problem remains without \color as well. I've updated my question to include more detail. Instead of overlapping the composite symbols, XeTeX prints the same result as if I had used single symbols like ㄹ (U+3139) instead. – Nawit Mar 23 at 9:38
  • 2
    I don't have your font but I tried with \setCJKmainfont{UnBatang.ttf} and it looks ok. I have a current texlive 2021 on windows. – Ulrike Fischer Mar 23 at 9:43
  • Stupid me, blaming poor XeTeX... Yes, the font was the issue, thanks! – Nawit Mar 23 at 9:56
3

Turns out the font was the issue and simple Batang doesn't contain the composite characters. After reading Ulrike's comment I simply put

\setCJKmainfont{UnBatang}

instead and everything worked fine, with and without color.

1
  • I was just about to comment that but refreshed to see the updates—I could see in the two samples that the Korean in the two samples was set in different fonts and wondered if that might be the problem. – Don Hosek Mar 24 at 2:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.