# Japanese and Russian Characters in the same Document

I'm writing a document in English. However, I need to use a few words of both Japanese and Russian. In principle, it seems to work, but as soon as I used Japanese characters, I cannot use Russian characters afterwards. Please note that it is crucial for me that the document compiles using pdflatex.

Here are two minimal examples to illustrate my problem.

This one works:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage{CJK}

\begin{document}
{\fontencoding{T2A}\selectfont ф}
\begin{CJK}{UTF8}{min}
ル
\end{CJK}
\end{document}


But this doesn't:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage{CJK}

\begin{document}
{\fontencoding{T2A}\selectfont ф}
\begin{CJK}{UTF8}{min}
ル
\end{CJK}
{\fontencoding{T2A}\selectfont ф}
\end{document}


I cannot figure out why. In the second case, I get this error message:

! Undefined control sequence.
\CJK@XX ...r #1\endcsname {#2}\CJK@ignorespaces
\fi
l.12   {\fontencoding{T2A}\selectfont ф
}


I cannot find any explanation and I would really appreciate any help.

-
I suggest XeLaTeX (with xeCJK) or LuaLaTeX (with luatexja-fontspec). –  Leo Liu Jun 13 '13 at 1:30

Hmm seems like CJK package is making some definitions global when perhaps it shouldn't. You can reset the inputenc settings like so:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage{CJK}

\begin{document}
{\fontencoding{T2A}\selectfont ф}
\begin{CJK}{UTF8}{min}
ル
\end{CJK}%
\sbox0{\input{utf8.def}}%
{\fontencoding{T2A}\selectfont ф}
\end{document}

-
Thank you very much, that works perfectly. :-) –  Pete Jun 11 '13 at 18:15
@Pete Welcome to tex.sx! If David’s answer solved your problem, you can accept it by clicking on the check below the vote count. –  doncherry Jun 11 '13 at 22:38

David Carlisle's solution works, but it is not as good as it could be.

In fact, there's a CJKutf8 package which solves the problem that inputenc and CJK packages may conflict.

Here's an example:

\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{min}

ру́сский: абвгдеАБВГДЕ

English: abcdefABCDEF

\clearpage\end{CJK}
\end{document}


## NOTES:

1. Please always use CJK environment globally, unless you know what you are doing.
The extra \clearpage is used to solve an old sutle bug of CJK described in the package document.

2. T2A font encoding is sufficient if you only use basic Latin letters used by English. However, if you need more accented letters, you can mix T1 and T2A font encodings manually.

3. For multilingual documents, I think it is always preferrable to use XeLaTeX or LuaLaTeX. For XeLaTeX, use our xeCJK package to support automatical font selection and other features. For LuaLaTeX, use luatexja bundle to support similar features.

-