1

I'm modifying a .sty file that's used with documents that includes Latin, Arabic and Japanese text intermingled without specific markup. I am using xeCJK to identify the Japanese text and ucharclasses to identify the Arabic. I'm not bound to these, but I need something that switches fonts without markup in the document.

However I've noticed that the ucharclasses package causes additional spaces around Japanese text in certain (fairly obscure) circumstances. Here's a MWE:

\documentclass{article}

\usepackage[no-math]{fontspec}
\setmainfont{Noto Serif}
\usepackage{xeCJK}
\setCJKmainfont{Noto Sans CJK JP}

%\usepackage[Latin,Arabic]{ucharclasses}

\begin{document}
``\texttt{めいじ}''
\end{document}

With the ucharclasses line commented out I get the first line of the image below, which is what I expect; with it enabled, I get the second line, which has too much space around the hiragana characters:

enter image description here

The spacing is possibly consistent with xelatex trying to use a double-width monospaced quotation mark, despite it being outwith the \texttt block, but that may be a red herring. However the problem doesn't exhibit without a \texttt block. Obviously in the MWE I can simply drop the \texttt as it does nothing; but in the actual documents its part of a more complex macro that I cannot readily drop.

The problem is not specific to the Noto fonts. If I use Computer Modern as the main font and Takao Mincho as the CJK main font, it still happens.

Is my usage wrong? I thought adding a CJK option to the ucharclasses package might fix it, but it seems to break Japanese rendering via xeCJK entirely.

1

I'm not sure I'd use English quotes here, but it works if you load ucharclasses before xeCJK.

\documentclass{article}
\usepackage[no-math]{fontspec}
\setmainfont{Noto Serif}
\usepackage[Latin,Arabic]{ucharclasses}
\usepackage{xeCJK}
\setCJKmainfont{Noto Sans CJK JP}
\begin{document}
``\texttt{めいじ}''
\end{document}

enter image description here

  • Marvellous. For what it's worth, the reason for the Western quotation marks (and also the \texttt) is that it's actually a code fragment embedded in and English technical document discussing internationalisation in the code. – richard Apr 12 '16 at 0:49
  • @richard Ah, that makes sense in that context. (I was wondering about the \texttt.) – erik Apr 12 '16 at 1:51
  • Unfortunately, while this does fix the Japanese spacing, it breaks the Arabic. Possibly related to this question. I'll wait to see if that question gets an answer before updating this one. – richard Apr 12 '16 at 18:18

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.