Friday, August 14, 2015

Write japanese in LaTeX

Trick source

Install these packages:

$ sudo apt-get install latex-cjk-common
$ sudo apt-get install latex-cjk-japanese

A minimum document:

\documentclass{memoir}
 
\usepackage{CJKutf8}
 
\begin{document}
 
\begin{CJK}{UTF8}{min}未練なく散も桜はさくら哉\end{CJK} \\
\begin{CJK}{UTF8}{maru}未練なく散も桜はさくら哉\end{CJK} \\
\begin{CJK}{UTF8}{goth}未練なく散も桜はさくら哉\end{CJK} \\
without regret \\
they fall and scatter\ldots \\
cherry blossoms
 
\end{document}

The min, maru, and goth selects the font. In order to write furigana (for children and begginers as me ;) ) use the ruby package:

\documentclass{memoir}
 
\usepackage{CJKutf8}
\usepackage[overlap,CJK]{ruby}
 
\begin{document}
 
%% I find the default \rubysep (-0.5ex) too tight, so
%% let's enlarge it a little.
\renewcommand\rubysep{-0.2ex}
 
\begin{CJK}{UTF8}{min}
イスキエルド\ruby{先生}{せんせい}は\ruby{私}{わたし}を\ruby{愛}{あい}して
\end{CJK}
 
\end{document}

Alternatively, xelatex can be used instead.

No comments: