# Why can't I use Chinese in MiKTeX [duplicate]

This is my source code of a LaTeX file, I use the package CJK in the editor WinEdt, and MiKTeX, but the display result is bad, it cannot display Chinese characters.

\documentclass[12pt]{article}
\usepackage{CJK}
\title{Test}
\author{zhulongsheng(11291065@bjtu.edu.cn)}
\date{2014/01/28}
\begin{document}
\maketitle
\begin{CJK*}{GBK}{song}
\today
\section{第一}

\CJKfamily{hei}
\section{第二}

\subsection{Goal}

\LaTeX
\end{CJK*}
\end{document}


## marked as duplicate by Leo Liu, Svend Tveskæg, Speravir, Sean Allred, ChrisSFeb 20 '14 at 6:06

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Martin Schröder Feb 12 '14 at 7:34
• This might well be a problem of file encoding. Why aren't you using UTF-8? – egreg Feb 12 '14 at 9:31
• @egreg Since cp936, very similar to GBK, is being used for Windows OS (Chinese Simp.), many old books and articles that are available on the Internet introduced the CJK package with GBK as the default solution. Consequently, it's very common that a beginner of LaTeX from China takes CJK with GBK as his/her solution. – Ch'en Meng Feb 12 '14 at 12:46
• @egreg: No, it isn't an encoding problem. It is a font problem. CJK fonts for LaTeX CJK package need some extra configurations. These configurations are done by some local TeX distributions. For MiKTeX and TeX Live, we can use some more modern solutions (e.g. zhmetrics's dynamic font mapping for pdfTeX/dvipdfmx; xeCJK for XeTeX). – Leo Liu Feb 20 '14 at 3:32
• A link in Chinese for simple Chinese typesetting: 如何在 LaTeX 中处理中文？请举一个例子。 – Leo Liu Feb 20 '14 at 3:36

The CJK package is old and not recommended. Here is a Unicode solution, using the xeCJK package and the XeTeX engine.

\documentclass[12pt]{article}
\usepackage{xeCJK}
% I supposed that you do have these fonts mentioned below.
\setCJKmainfont[BoldFont={SimHei},ItalicFont={[SIMKAI.TTF]}]
{SimSun}
\setCJKsansfont{SimHei}
\setCJKmonofont{[SIMFANG.TTF]}
\setCJKfamilyfont{zhsong}{SimSun}
\setCJKfamilyfont{zhhei}{SimHei}
\setCJKfamilyfont{zhkai}{[SIMKAI.TTF]}
\setCJKfamilyfont{zhfs}{[SIMFANG.TTF]}
\newcommand*{\songti}{\CJKfamily{zhsong}} % 宋体
\newcommand*{\heiti}{\CJKfamily{zhhei}}   % 黑体
\newcommand*{\kaishu}{\CJKfamily{zhkai}}  % 楷书
\newcommand*{\fangsong}{\CJKfamily{zhfs}} % 仿宋
\title{Test}
\author{zhulongsheng(11291065@bjtu.edu.cn)}
\date{2014/01/28}
\begin{document}
\maketitle
\today
\section{第一}

\heiti
\section{第二}

\subsection{Goal}

\LaTeX
\end{document}


Save it as encoding UTF8 and compile it with XeLaTeX.

Furthermore, if your operating system is Windows (Chinese Simp.), you would be glad to know the ctexart class, since it provides you an easy way to produce LaTeX document that contains Chinese chars.

A simple example (UTF8 and XeLaTeX, also):

\documentclass[UTF8, cs4size]{ctexart}
\title{Test}
\author{zhulongsheng(11291065@bjtu.edu.cn)}
\date{2014/01/28}
\begin{document}
\maketitle
\today
\section{第一}

\heiti
\section{第二}

\subsection{Goal}

\LaTeX
\end{document}


Unicode fontspec solution without package CJK:

\documentclass[12pt]{article}

\usepackage{fontspec}
\setmainfont{STFangsong} % Mac OS X system font
\setsansfont{STHeiti}    % Mac OS X system font
\newfontfamily\song{STFangsong}
\newfontfamily\hei{STHeiti}

\title{Test}
\author{zhulongsheng(11291065@bjtu.edu.cn)}
\date{2014/01/28}
\begin{document}
\maketitle
\today

\song

\section{第一}

\hei%\sffamily%\CJKfamily{hei}

\section{第二}

\subsection{Goal}

\LaTeX
\end{document}


## Why fails?

MiKTeX (and TeX Live) does not set proper font mapping for those fonts for CJK package. It is unportable and difficult to maintain such font mapping for so different platforms.

In some local TeX distributions (e.g. CTeX套装), extra font mapping is set up for Chinese version of Windows platform. Your code will work fine if you install these TeX distributions.

## Quick (and dirty) fix

% Put it in the preamble
\AtBeginDvi{\input{zhwinfonts}}


## Better solution

• XeLaTeX is preferred. pdfLaTeX or dvipdfmx is also fine. (LuaLaTeX is not yet fully supported.)

• UTF-8 encoding is prefered (especially for XeLaTeX).

• ctex package (ctexart, ctexrep, ctexbook classes) is prefered.

See How does one type Chinese in LaTeX? for my suggestion.