8

There are a lot of topics about how to use Japanese font, but, often the answer is: use XeLaTeX (or some other), or worse, it's just doesn't work at all.

So, knowing that I'm working with PDFLaTeX (latest version), in Texmaker (idem), with MiKTeX (idem), on Windows XP, how can I type Japanese characters? If possible.

The best way would to put it with command such as \euro{} is used to input the € symbol.

About the 1st proposed solution, here, you can find the error message I've got : The error from the log

After suppressing the 19th line, in the 1st solution, that works perfectly. Anyone knows why ? The problem seems to be due to the "maru" option. Thanks for you effort.

1
  • 2
    For pdflatex there is the CJK package.
    – egreg
    Commented Jan 17, 2013 at 22:16

1 Answer 1

10

I hope this is a useful example of how to use CJK package to typeset both furigana and Pīnyīn:

\documentclass[letter,12pt]{article}

% PACKAGES

\usepackage[utf8]{inputenc} % Allows TeX to understand input like ü and 患
\usepackage{CJKutf8,pinyin} % Enables TeX to generate (a) East Asian glyphs and (b) their pronunciations.
\usepackage[overlap,CJK]{ruby} % Simple method for generating sub- and super-textual pronunciation keys (Pīnyīn, kana, etc.)

% OPEN DOCUMENT

\begin{document}

% BODY

\begin{center}
\Large
\begin{CJK*}{UTF8}{gbsn}\renewcommand\rubysep{-1.6em}\ruby{内}{\nei4}\ruby{忧}{\you1}\ruby{外}{\wai3}\ruby{患}{\huan4}\end{CJK*}\quad$\leftarrow$\quad
\begin{CJK*}{UTF8}{bkai}內憂外患\end{CJK*}\quad$\rightarrow$\quad
\begin{CJK*}{UTF8}{maru}\renewcommand\rubysep{0em}\ruby{内}{ない}\ruby{憂}{ゆう}\ruby{外}{がい}\ruby{患}{かん}\end{CJK*}
\end{center}

% END

\end{document}

Play with it!

Here is the same effect achieved with XeLaTeX, which you may wish to try, as it allows you use fonts from your system. Simply replace the font names I used with your own, and scale them appropriately so that they match in your output. (I would invite others to please edit this code to include the minimal use of polyglossia, which has been identified as best practice when switching languages in TeX.)

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article}

% PACKAGES

\usepackage{fontspec}
\usepackage{ruby}

% OPEN DOCUMENT

\begin{document}

% SPECIFY ASIAN FONTS

\newfontfamily{\J}[Scale=0.85]{Hiragino Kaku Gothic Pro}
\newfontfamily{\C}{STKaiti}

% BODY

\begin{center}
\Large
{\C\renewcommand\rubysep{-1.6em}\ruby{内}{nèi}\ruby{忧}{yōu}\ruby{外}{wǎi}\ruby{患}{huàn}\quad$\leftarrow$\quad}
{\C 內憂外患\quad$\rightarrow$\quad}
{\J\renewcommand\rubysep{0em}\ruby{内}{ない}\ruby{憂}{ゆう}\ruby{外}{がい}\ruby{患}{かん}}
\end{center}

% END

\end{document}
7
  • Hi, sorry for the delay. I've tried (quickly) your solution. It didn't work ; since I'm not at home, it's quite hard to try to figure out where's the problem. I'll change my post in few days. Thanks for your try.
    – Julien
    Commented Jan 19, 2013 at 10:06
  • 1
    @Julien, I just edited the example to make it even more minimal. Try it again, maybe. For example, the earlier version included the libertine package, which you might not have installed. Without seeing the error messages, my guess would be missing packages, e.g. pinyin, CJKutf8, or ruby, which your TeX installation probably has a simple method for downloading to the right place.
    – commonhare
    Commented Jan 19, 2013 at 23:20
  • Hi, I was self asking why the "maru", doesn't work with the "ruby" command, but goes fine if with only kana/kanji (but the pdf file doesn't open, and his corrupt), and allow normal work if without any kanji/kana in it. Got any idea ?
    – Julien
    Commented Jan 25, 2013 at 0:38
  • 1
    I'm not sure how the maru option operates in the CJK package, but there is a chance it requires local installation of a font that your system may not have. Will have to defer to others, but this is why so many people will recommend XeLaTeX to you for these efforts: it allows you to specify system fonts that you KNOW you have.
    – commonhare
    Commented Jan 25, 2013 at 20:03
  • Thanks ! To solve the problem, since I only need to "show" kana and kanji, I use the 2 first line, one for kana, the other for kanji. But, do you know a way to put them in the name of a glossary entry ? I've asked the question here : tex.stackexchange.com/q/95272/13993.
    – Julien
    Commented Jan 29, 2013 at 20:48

You must log in to answer this question.

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