[Tex/LaTex] How to input kana with PDFLaTeX

cjkfontspdftex

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.

Best Answer

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}