> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/languages/06-chinese.md).

# Chinese

## Introduction

This article explains how to typeset Chinese documents on Overleaf. The recommended approach is to use the XeLaTeX or LuaLaTeX compilers because they directly support UTF-8 encoded text and work with TrueType and OpenType fonts. See [this article](/latex/knowledge-base/026-changing-compiler.md) to learn how to change the compiler in Overleaf.

Let’s start with an example which uses XeLaTeX and the `ctexart` document class:

```latex
\documentclass{ctexart}
\begin{document}
\tableofcontents

\begin{abstract}
这是简介及摘要。
\end{abstract}

\section{前言}

\section{关于数学部分}
数学、中英文皆可以混排。You can intersperse math, Chinese and English (Latin script) without adding extra environments.

這是繁體中文。
\end{document}
```

[Open this `XeLaTeX` example in Overleaf](https://www.overleaf.com/docs?engine=xelatex\&snip_name=Basic+example+of+the+ctexart+class\&snip=%5Cdocumentclass%7Bctexart%7D%0A%5Cbegin%7Bdocument%7D%0A%5Ctableofcontents%0A%0A%5Cbegin%7Babstract%7D%0A%E8%BF%99%E6%98%AF%E7%AE%80%E4%BB%8B%E5%8F%8A%E6%91%98%E8%A6%81%E3%80%82%0A%5Cend%7Babstract%7D%0A%0A%5Csection%7B%E5%89%8D%E8%A8%80%7D%0A%0A%5Csection%7B%E5%85%B3%E4%BA%8E%E6%95%B0%E5%AD%A6%E9%83%A8%E5%88%86%7D%0A%E6%95%B0%E5%AD%A6%E3%80%81%E4%B8%AD%E8%8B%B1%E6%96%87%E7%9A%86%E5%8F%AF%E4%BB%A5%E6%B7%B7%E6%8E%92%E3%80%82You+can+intersperse+math%2C+Chinese+and+English+%28Latin+script%29+without+adding+extra+environments.%0A%0A%E9%80%99%E6%98%AF%E7%B9%81%E9%AB%94%E4%B8%AD%E6%96%87%E3%80%82%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![OL2Chinese1.png](/files/eMROmOWXVERmlHzG442h)

The `ctexart` document class part of the [`ctex` package bundle](https://ctan.org/pkg/ctex?lang=en) which implements common Chinese typesetting practices. We discuss further details about the `ctex` classes below.

## The ctex classes

In order to handle characters for Simplified Chinese typesetting you can use the `ctex` document classes: `ctexart`, `ctexrep`, `ctexbook` and `ctexbeamer`. For example, to use the `ctexart` class include the following line in your document preamble:

```latex
\documentclass{ctexart}
```

The `ctexart` class (and other `ctex` classes) provides Chinese localisation, much like `babel`. You will not only be able to typeset Chinese characters, but also define elements such as “Abstract” and “Table of Contents” that will be translated as 摘要 and 目录.

You can import external fonts to your document, either uploading them to the same directory of your LaTeX file, or using system-wide fonts. For instance, if the `BabelStone Han` font is already installed on your system, you can use it in your document with

```latex
\setCJKmainfont{BabelStone Han}
```

Additional fonts for some parts of the document can be configured. To set a specific font for elements that use a sans serif font style use `\setCJKsansfont{}` and for elements that are displayed in a monospace font, such as verbatim environments, use the command `\setCJKmonofont{}`. You can refer to the list of Chinese fonts available on Overleaf [here](/latex/questions-and-answers/85-which-otf-or-ttf-fonts-are-supported-via-fontspec.md#chinese).

Notice that the last line in the example at the [introduction](#introduction) is actually using Traditional Chinese characters. This is accomplished by the Fandol font (the default) because this font includes them. So, with the right font, you can actually typeset your document in both Simplified and Traditional Chinese. If you use a traditional- or simplified-only font, though, then characters whose glyphs are not available would not show up in the output PDF.

If you need to use document class such as `memoir` or perhaps a thesis `.cls` provided by your university, but would still like to use the `ctex` bundle, you can load the `ctex` package, like this:

```latex
\documentclass{UniThesis}
\usepackage{ctex}
```

## xeCJK with XeLaTeX

If the complete `ctex` localisation classes and package feels like an overkill, and you just want to typeset some Chinese characters, you can use the [`xeCJK` package](https://ctan.org/pkg/xecjk?lang=en)—which only works when compiled with XeLaTeX.

```latex
\documentclass{article}
\usepackage{xeCJK}
\begin{document}
\section{前言}
这是一些文字。

\section{关于数学部分}
数学、中英文皆可以混排。You can intersperse math, Chinese and English (Latin script) without adding extra environments.

這是繁體中文。
\end{document}
```

[Open this `xeCJK` (XeLaTeX) example in Overleaf](https://www.overleaf.com/docs?engine=xelatex\&snip_name=Basic+example+of+the+xeCJK+package\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7BxeCJK%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csection%7B%E5%89%8D%E8%A8%80%7D%0A%E8%BF%99%E6%98%AF%E4%B8%80%E4%BA%9B%E6%96%87%E5%AD%97%E3%80%82%0A%0A%5Csection%7B%E5%85%B3%E4%BA%8E%E6%95%B0%E5%AD%A6%E9%83%A8%E5%88%86%7D%0A%E6%95%B0%E5%AD%A6%E3%80%81%E4%B8%AD%E8%8B%B1%E6%96%87%E7%9A%86%E5%8F%AF%E4%BB%A5%E6%B7%B7%E6%8E%92%E3%80%82You+can+intersperse+math%2C+Chinese+and+English+%28Latin+script%29+without+adding+extra+environments.%0A%0A%E9%80%99%E6%98%AF%E7%B9%81%E9%AB%94%E4%B8%AD%E6%96%87%E3%80%82%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![OL2Chinese2.png](/files/0CUtJMorkd4djZ3aHyok)

## Using CJKutf8 with pdfLaTeX

The `CJKutf8` package can be used to typeset CJK languages with pdfLaTeX. Chinese (and Japanese/Korean) text must be placed inside a `CJK` environment, so this is usually convenient for primarily Latin-based documents (e.g., English) which contain fragments of Chinese text (or vice-versa).

```latex
\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK*}{UTF8}{gbsn}

\section{前言}

\section{关于数学部分}
数学、中英文皆可以混排。You can intersperse math, Chinese and English (Latin script) without adding extra environments.

\end{CJK*}

\bigskip  %% Just some white space

You can also insert Latin text in your document

\bigskip  %% Just some white space

\begin{CJK*}{UTF8}{bsmi}
這是繁體中文。
\end{CJK*}
\end{document}
```

[Open this `CJKutf8` package example (using pdfLaTeX) in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+of+the+CJKutf8+package\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7BCJKutf8%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7BCJK%2A%7D%7BUTF8%7D%7Bgbsn%7D%0A%0A%5Csection%7B%E5%89%8D%E8%A8%80%7D%0A%0A%5Csection%7B%E5%85%B3%E4%BA%8E%E6%95%B0%E5%AD%A6%E9%83%A8%E5%88%86%7D%0A%E6%95%B0%E5%AD%A6%E3%80%81%E4%B8%AD%E8%8B%B1%E6%96%87%E7%9A%86%E5%8F%AF%E4%BB%A5%E6%B7%B7%E6%8E%92%E3%80%82You+can+intersperse+math%2C+Chinese+and+English+%28Latin+script%29+without+adding+extra+environments.%0A%0A%5Cend%7BCJK%2A%7D%0A%0A%5Cbigskip++%25%25+Just+some+white+space%0A%0AYou+can+also+insert+Latin+text+in+your+document%0A%0A%5Cbigskip++%25%25+Just+some+white+space%0A%0A%5Cbegin%7BCJK%2A%7D%7BUTF8%7D%7Bbsmi%7D%0A%E9%80%99%E6%98%AF%E7%B9%81%E9%AB%94%E4%B8%AD%E6%96%87%E3%80%82%0A%5Cend%7BCJK%2A%7D%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![OL2Chinese3.png](/files/SbwBvU2I7ywRWRShPqqx)

The line `\usepackage{CJKutf8}` imports the `CJKutf8` package which enables UTF-8 encoding for use with Chinese, Japanese and Korean fonts. Every block of Chinese text must be typed inside a `\begin{CJK*}{UTF8}{gbsn}` environment. In this environment `UTF8` is the encoding and `gbsn` is the font to be used. You can use `gbsn` or `gkai` fonts for Simplified characters, and `bsmi` or `bkai` for Traditional characters.

## Further reading

For more information see

* [Supporting modern fonts with XƎLaTeX](/latex/fonts/03-xelatex.md)
* [Chinese fonts available on Overleaf](/latex/questions-and-answers/85-which-otf-or-ttf-fonts-are-supported-via-fontspec.md#chinese)
* [Example: Using the CTeX packages on Overleaf](https://www.overleaf.com/read/gndvpvsmjcqx)
* [Example: How to write multilingual text with different scripts in LaTeX](https://www.overleaf.com/read/wfdxqhcyyjxz)
* [Typesetting quotations and quotation marks](/latex/languages/04-typesetting-quotations.md)
* [International language support](/latex/languages/03-international-language-support.md)
* [Arabic](/latex/languages/05-arabic.md)
* [French](/latex/languages/07-french.md)
* [German](/latex/languages/08-german.md)
* [Greek](/latex/languages/09-greek.md)
* [Italian](/latex/languages/10-italian.md)
* [Japanese](/latex/languages/11-japanese.md)
* [Korean](/latex/languages/12-korean.md)
* [Portuguese](/latex/languages/13-portuguese.md)
* [Russian](/latex/languages/14-russian.md)
* [Spanish](/latex/languages/15-spanish.md)
* [Ctex packages documentation](http://www.texdoc.net/pkg/ctex)
* [xeCJK package documentation](http://www.texdoc.net/pkg/xeCJK)
* [The not so short introduction to LaTeX2ε](http://www.ctan.org/tex-archive/info/lshort/)
* [LaTeX/Internationalization on WikiBooks](http://en.wikibooks.org/wiki/LaTeX/Internationalization)
* [LaTeX/Special\_Characters on WikiBooks](http://en.wikibooks.org/wiki/LaTeX/Special_Characters)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/languages/06-chinese.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
