# [Tex/LaTex] Chinese in ShareLaTeX

languagessharelatex

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.

\documentclass{article}
\usepackage{CJK}
\usepackage[utf8]{inputenc}

\begin{document}

\title{Title}
\author{Author}
\date{February 2015}

\begin{CJK}{UTF8}{gbsn}

Something\\

\end{CJK}

\end{document}


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

\documentclass{ctexart}

\setCJKmainfont{simsun.ttf}
\setCJKsansfont{simhei.ttf}
\setCJKmonofont{simfang.ttf}

\begin{document}

\tableofcontents

\begin{abstract}

\end{abstract}

\section{ 前言 }

\section{关于数学部分}

\end{document}


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