[Tex/LaTex] Chinese in ShareLaTeX


2nd post on Stack Exchange, not 100% sure this is the correct place to post, but I'll move it if it needs to be moved.

I've been trying to learn how to type up my Chinese documents in LaTeX (I use ShareLaTeX), but almost nothing seems to work. Although I have all of the proper Chinese fonts installed on the computer, it continues giving me errors, even when I tried to run the document that ShareLateX itself used for an example.

Below are some documents and the errors/problems they cause.



\date{February 2015}





This gives out a document that is the closest I've had to success, but it doesn't print out in proper formatting (namely, the Title, Author and Date are all absent) and it doesn't have the usual margins.

The next one was also stolen from an example






\section{ 前言 }




It returns the following error messages and fails to compile. All issues are in main.tex unless otherwise stated

Compile Error
Undefined Control Sequence (line 3)
LaTeX Error: Missing \begin[document} (line 3)
Undefined Control Sequence (line 5)
Improper Alphabetic Constant (output.toc, line 1)
Missing = inserted for \ifnum (output.toc, line 1)
Missing number, treated as 0 (out..., line 1)
Bad character code (-30). (out..., line 1)
Undefined control sequence (line 12)
Package CJK Error: Invalid Character Code (line 12)
Undefined Control Sequence (line 15)
Undefined Control Sequence (line 15)
Undefined Control Sequence (line 16)
Undefined Control Sequence (line 16)
Undefined Control Sequence (line 19)
Undefined Control Sequence (line 21)
dfTeX error: pdflatex (file simsun.ttc): cannot open TrueType font file for reading

Optimally, I'd like to use the KaiTi font, but for now I'll just settle for being able to created a document in the first place. 🙂

LaTeX, ShareLaTeX, Chinese

Best Answer

Compile it using XeLaTeX (default is pdfLaTeX). Took me waaay too long to figure this out.

To do this, go to the menu (top left corner), scroll down to Settings, change compiler from "pdfLaTeX" to "XeLaTeX". The instructions from ShareLaTeX's documentation should now work fine.

Related Question