7

I've searched for this extensively but couldn't find anything that could help me, but if you know of some previous question that might help, feel free to point me to it.

I have a document with Japanese characters and Latin characters. I'd like to make it clear that it used to work fine, I was able to see both set of glyphs. I left it alone for some time and when I re-took the document and typeset it, the Japanese glyphs disappeared. It worked everything except for the Japanese characters that were not printed. So I tried other packages but nothing worked.

Finally I tried setting two fonts, one for the Japanese part and one for the Latin characters. The reason behind this is that I need some words to be in italic and some to be Small Caps (for the Latin characters) since I failed to find a single font that supported Japanese and these two things as well.

However if I try to write:

\setmainfont{CMU Serif}
\setCJKmainfont{Hiragino Mincho Pro}

I get this:

LaTeX Warning: Command \selectfont has changed.
Latex Error: ...tex:37 LaTeX Error: Environment CJK undefined.
Latex Error: ...tex:175 LaTeX Error: \begin{document} ended by \end{CJK}.

So my question is: Is there a font that might support all of that? Alternatively, what packages are required for me so that I can set two fonts and so that Latex automatically recognizes when to use each? I'd prefer a minimal approach over huge preamble codes to set this up.

Here is the MWE:

\documentclass{article}
\usepackage[a4paper, margin=1cm, landscape]{geometry}
\usepackage[document]{ragged2e}
\usepackage{fontspec} % I was experimenting
\usepackage{setspace}
\usepackage{lineno}
\usepackage[english]{babel}
\usepackage{CJKutf8}
\usepackage[table]{xcolor}    % loads also »colortbl«
\usepackage{tabu}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{array}
\usepackage{arydshln}

\pagestyle{empty}

%\setmainfont{CMU Serif}
%\setCJKmainfont{Hiragino Mincho Pro}

\begin{document}

 Regular, \emph{italic} text, but also in \textsc{small caps}. And now for some 日本語 $\leftarrow$ Japanese.

\end{document}

Output:

enter image description here

7
  • Could you provide a MWE? It seems that your code is wrong. xeCJK package does not provide CJK environment.
    – Leo Liu
    Jan 7 '14 at 13:07
  • And this question might help: How to write Japanese with LaTeX?
    – Leo Liu
    Jan 7 '14 at 13:10
  • BTW, Hiragino Mincho Pro is just fine for Japanese. It is a high quality font.
    – Leo Liu
    Jan 7 '14 at 13:19
  • @LeoLiu I used both xeCJK and CJKutf8. I added a MWE since my real code is too big. I'll leave all of the packages I'm using so that if some conflict with each other you can tell me (I don't know that). :D
    – Alenanno
    Jan 7 '14 at 13:38
  • @LeoLiu By the way, I asked that very question you linked to. But that doesn't help me anymore. I guess something changed in the packages? I don't know. :|
    – Alenanno
    Jan 7 '14 at 13:39
6

This should work. Do not use CJK or CJKutf8 package. XeLaTeX is required.

\documentclass{article}
\usepackage[a4paper, margin=1cm, landscape]{geometry}
\usepackage[document]{ragged2e}
\usepackage{setspace}
\usepackage{lineno}
\usepackage[table]{xcolor}    % loads also »colortbl«
\usepackage{tabu}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{array}
\usepackage{arydshln}

\pagestyle{empty}

\usepackage{xeCJK}
\setmainfont{CMU Serif}
\setCJKmainfont{Hiragino Mincho Pro}

\begin{document}

Regular, \emph{italic} text, but also in \textsc{small caps}.
And now for some 日本語 $\leftarrow$ Japanese.

\end{document}

enter image description here

1
  • Probably it wasn't actually using Xelatex... Thanks for the help!
    – Alenanno
    Jan 7 '14 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.