Overleaf writing, how to input Chinese?
Overleaf supports Chinese input through the use of the XeLaTeX or LuaLaTeX compilation engines, which have native support for modern Unicode fonts, and by properly configuring the document preamble. The core requirement is to move away from the default PDFLaTeX engine, as it historically lacks robust, out-of-the-box handling for UTF-8 character encoding and non-Latin scripts. Therefore, the primary technical step is to explicitly set the compiler in the Overleaf project menu to either XeLaTeX or LuaLaTeX. This single change is the most critical, as it allows the compiler to process .tex files containing Chinese characters directly, whether those characters are copied into the source, typed via an IME, or included from a separate file.
With the correct compiler selected, font specification becomes essential. You must load a font package that contains the necessary Chinese glyphs. A common and reliable approach is to use the `ctex` package suite, which is designed specifically for Chinese typesetting. By adding `\usepackage{ctex}` to the preamble, it automatically handles a vast array of typographical conventions—such as proper line breaking, punctuation, and chapter/section formatting—while also setting a default Chinese font (like the system's SimHei or SimSun) that works with XeLaTeX or LuaLaTeX. For more precise font control, you can use the `fontspec` package directly (which is loaded by `ctex`) and specify a particular system or embedded font family, for instance, `\setmainfont{SimSun}`. This ensures that the rendered PDF displays the characters correctly.
The actual input of Chinese text into the .tex document source is straightforward: you simply type or paste the characters directly into the editor. There is no need for cumbersome escape codes or commands for each character, as is required with some legacy CJK packages under PDFLaTeX. You can write Chinese in any part of the document—the title, author field, section headings, and body text. For example, your document could begin with `\title{我的文档}` and compile without issue. It is crucial, however, to ensure your .tex file is saved with UTF-8 encoding, which is the default for Overleaf but remains a point to verify if you are uploading existing files from other sources.
The main practical implication of this setup is that it creates a seamless workflow where content creation and typesetting are separated. Writers can focus on composing text in Chinese using their preferred input method, while the `ctex` package and Unicode-aware engine manage the complex typography. A secondary consideration is that using specific, non-standard fonts may require those fonts to be embedded in the project if portability outside of Overleaf is needed, though this is often unnecessary within the platform's ecosystem. The mechanism is robust and represents the modern standard for Chinese LaTeX typesetting, effectively removing the technical barriers that once made it a specialized task.