Chinese
LaTeX supports many worldwide languages by means of some special packages. This article explains how to typeset Chinese documents on Overleaf.
Introduction
The recommended approach is to use the XƎLaTeX or LuaLaTeX compilers, as they support UTF-8 directly and allows more flexibility to work with true type and opentype fonts. See this article to learn how to change the compiler in Overleaf.
\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}
The ctexart
document class here is provided by the ctex
bundle, which implements common Chinese typesetting practices. We discuss further details about the ctex
classes below.
The ctex Bundle Classes
Modern computer systems allow you to input letters of national alphabets directly from the keyboard. In order to handle characters for Simplified Chinese typesetting you can use the ctex document classes: ctexart
, ctexrep
, ctexbook
and ctexbeamer
.
\documentclass{ctexart}
Thectexart
(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 the "Table of Contents" that will be properly 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 established. To set a specific font for elements that use sans font style use \setCJKsansfont{}
and for elements that are displayed in 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.
You may sometimes be using a different document class e.g. memoir
or a thesis .cls
provided by your university, but would still like like to use the ctex
bundle. You can load the ctex
package in this case:
\documentclass{UniThesis}
\usepackage{ctex}
xeCJK with XeLaTeX
If the complete localisation ctex
classes and package feels like an overkill and you just want to typeset some Chinese characters, you can use the xeCJK
package.
\documentclass{article}
\usepackage{xeCJK}
\begin{document}
\section{前言}
\section{关于数学部分}
数学、中英文皆可以混排。You can intersperse math, Chinese and English (Latin script) without adding extra environments.
這是繁體中文。
\end{document}
The xeCJK package only works when compiled with XƎLaTeX.
CJKutf8 with pdfLaTeX
The CJKutf8
package can also be used to generate a document with pdfLaTeX. Chinese (and Japanese/Korean) text must be placed inside a CJK
environment, so this is usually only convenient for documents in English with bits 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}
The line \usepackage{CJKutf8}
imports CJKutf8 which enables utf8 encoding for Chinese, Japanese and Korean fonts.
In this case 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
- 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
- Debugging Compilation timeout errors
- How-to guides
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
- 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
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 in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia 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 and equations
- 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
- Typing 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
- Tips