10

I found the post How does one type Chinese in LaTeX? about how to typeset Chinese in Latex. I just encountered the same problem, and my questions are:

1.To type Chinese or Japanese, I have to have some particular packages (such as CJK/XeCJK) installed, don't I?

2.I'm confused by the first solution in that post, it looks like this:

% UTF-8 encoding
% Compile with latex+dvipdfmx, pdflatex or xelatex
% XeLaTeX is recommanded
% Some Chinese fonts should be installed in your system (SimSun, SimHei, FangSong, KaiTi)
\documentclass[UTF8]{ctexart}
\begin{document}
文章内容。
\end{document}

The above solution just uses a class ctexart without any particular packages, and I tried to replace ctexart with article, it failed. So I wonder what is special about ctexart which can display Chinese without any add-on packages?

avocado
  • 203

2 Answers2

6
  1. The following works pretty well in both LuaLaTeX and XeTeX without any special packages. fontspec (which I don't count among special packages) simply uses the SimSun font from Windows's font directory (as suggested in the code you're providing).

    \documentclass{article}
    \usepackage{fontspec}
    \setmainfont{SimSun}
    \begin{document}
    文章内容。
    \end{document}
    

    enter image description here

  2. ctexart simply loads the packages it needs, see LianTze Lim's comment.

Nils L
  • 9,716
  • Thanks, your fontspec solution works, but let me get it straight, why fontspec works? This package tell the tex engine how to handle the Chinese character? – avocado Mar 26 '13 at 07:53
  • [tag:fontspec] is a package that basically provides a connection between XeTeX or LuaTeX and the fonts installed on your system, particularly .otf and .ttf files. When using Xe or Lua, fontspec is almost a must-load, even for people typesetting texts in plain English. If I wanted to use Times New Roman, I'd simply use that same code I gave you, but say \setmainfont{Times New Roman} instead. Note that in traditional pdfTeX, fontspec is neither required, nor does it work, as fonts are handled differently there. See also here. – Nils L Mar 26 '13 at 07:58
  • So, I have to compile the .tex using LuaTex or XeTex if I use fontspec, right? – avocado Mar 26 '13 at 08:06
  • that is correct. – Nils L Mar 26 '13 at 08:08
  • BTW, if I don't use \setmainfont{SimSun}, nothing shows in pdf, why? Without setmainfont, tex doesn't know how to do with the CJK characters? Furthermore, why use \setCJKmainfont when using package CJK? Can't I use setmainfont? – avocado Mar 26 '13 at 09:07
  • I can't say much about CJK-related issues. You might add that question to your original one. All I can say is: if you don't use \setmainfont at all, the »Latin Modern« fonts will be loaded, and these don't have CJK characters (as the name suggests). – Nils L Mar 26 '13 at 11:43
  • This method doesn't work if I want the English text to be san serif font (\sffamily), any remedy? – Yan King Yin Mar 10 '15 at 13:41
  • can you specify »doesn't work«? Are you using \setmainfont and \setsansfont correctly? – Nils L Mar 10 '15 at 18:24
1

ctexart, ctexbook and ctexrep are the equivalent to "article", "book" and "report" of the standard classes. You should definitely use those if you have Chinese text.

Ingmar
  • 6,690
  • 5
  • 26
  • 47