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 to learn how to change the compiler in Overleaf.
Let’s start with an example which uses XeLaTeX and the ctexart
document class:
\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
This example produces the following output:
The ctexart
document class part of the ctex
package bundle 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:
\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
\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.
Notice that the last line in the example at the 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:
\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—which only works when compiled with XeLaTeX.
\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
This example produces the following output:
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).
\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
This example produces the following output:
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
- Chinese fonts available on Overleaf
- Example: Using the CTeX packages on Overleaf
- Example: How to write multilingual text with different scripts in LaTeX
- Typesetting quotations and quotation marks
- International language support
- Arabic
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
- Ctex packages documentation
- xeCJK package documentation
- The not so short introduction to LaTeX2ε
- LaTeX/Internationalization on WikiBooks
- LaTeX/Special_Characters on WikiBooks
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class