[Tex/LaTex] Change Kanji display with CJKutf8

cjkjapanese

I've been using CJKuftf8 to include Japanese in a book containing mostly Latin script. It works fine most of the time, but I'm having problems displaying a particular kanji, 直. When compiled, this kanji always appears different to the one intended.

Left is kanji as typed, right is the kanji as it appears in the compiled document

Kanji

I believe the kanji being displayed is an equivalent in simplified Chinese, but of course, is not understood in Japan.

Furthermore, if I open the document in a pdf reader on a Japanese computer, and copy the kanji, it copies as the character I intended (the one on the left). If I open the document in a pdf reader on a computer which isn't in Japanese, it copies as the wrong kanji. It seems to be an issue with an overlap in utf8. Is it possible to edit the way that the kanji is displayed in the compiled document?

MWE:

\documentclass{article}

\usepackage{CJKutf8}
\begin{document}
\Huge
\begin{CJK}{UTF8}{min}直\end{CJK}
\end{document}

Since the kanji in the code may appear differently on other computers, to be sure, here's a picture of the code.

enter image description here

Update: It seems to be entirely a font issue. Writing the Kanji in Word/Libre office, the kanji is displayed differently depending on the font chosen. In particular, it is displayed as intended when using a Japanese font (e.g. TakaoExMincho), and incorrectly otherwise. As far as I know, the font can't be changed when using \usepackage{CJKutf8}. Is there a fix for this?

Best Answer

Let me post this as an answer rather than as a comment because this is too long for a comment.

As you say,

I think I'm happy to use any of the options, if there's a way to solve the problem.

I'll propose a XeLaTeX-based method. There is the fontspec, and it provides \newfontfamily, which defines a new font-switching command. Here is a simple examaple (I'm not sure that fonts in use are shipped with MiKTeX but both are available on CTAN).

% XeLaTeX document
\documentclass{article}
\usepackage{fontspec}
\newfontfamily{\jafamily}{ipam.ttf}  % Japanese typeface, which is what you want
\newfontfamily{\cnfamily}{FandolSong-Regular.otf}  % Simplified Chinese typeface
\begin{document}
{\jafamily 直} and {\cnfamily 直}
\end{document}

The output is

xelatex

On the other hand, LaTeX with 8-bit engine should also be able to use Japanese glyphs if the font family (the second argument of CJK environment) is properly set.

% (pdf)LaTeX document
\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{ipxm}直\end{CJK} and \begin{CJK}{UTF8}{gbsn}直\end{CJK}
\end{document}

will produce

pdflatex

If this example results in a different look, Japanese fonts seems to be not installed in your MiKTeX (and maybe fall back to Chinese font?).

Related Question