[Tex/LaTex] Japanese and Russian Characters in the same Document

cjkcyrilliclanguages

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.

Best Answer

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

enter image description here

\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}
Related Question