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?

4
  • 4
    The ctexart document class itself loads CJK (if using pdflatex) or the xeCJK (if using xelatex) package, hence it works!
    – imnothere
    Commented Mar 26, 2013 at 7:46
  • @LianTzeLim, so if I want to type CJK characters, I have to get those packages (CJK or XeCJK) ready anyway, right?
    – avocado
    Commented Mar 26, 2013 at 7:49
  • 2
    That's right. You can install these packages pretty easily via the package management tools that come with TeXlive or MikTeX.
    – imnothere
    Commented Mar 26, 2013 at 8:02
  • @Mico, well, :-|
    – avocado
    Commented Mar 26, 2013 at 13:31

2 Answers 2

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.

8
  • 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
    Commented Mar 26, 2013 at 7:53
  • 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
    Commented Mar 26, 2013 at 7:58
  • So, I have to compile the .tex using LuaTex or XeTex if I use fontspec, right?
    – avocado
    Commented Mar 26, 2013 at 8:06
  • that is correct.
    – Nils L
    Commented Mar 26, 2013 at 8: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
    Commented Mar 26, 2013 at 9:07
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .