How to input and display LaTeX Chinese: troubleshooting methods in the online editor
When LaTeX Chinese is not displayed, is displayed as a box, or a compilation error is reported, it is most likely that the compiler, Chinese document class, or font is not configured properly. This article explains how to input and display Chinese, and gives step-by-step inspection steps in the online editor.
Key points of this article
- If Chinese is not displayed, check the compiler first: for Chinese documents, you should choose XeLaTeX or LuaLaTeX, do not use the default pdfLaTeX.
- Use Chinese document classes such as ctexart to automatically handle Chinese fonts, punctuation and line breaks, eliminating most manual configuration.
- If the compiler and font are correct and it is still a block, check whether the used Chinese font is installed on the editor server.
- Input method typing has nothing to do with the compilation results. Saving the source file as UTF-8 encoding can avoid most garbled code problems.
- Before writing a Chinese paper, first use a test file containing only a few lines of Chinese to confirm that it can be compiled, and then write the main text after passing it.
If you search for "latex online editor Chinese" on the Internet, you have probably encountered this situation: Chinese characters are typed in the text, and the compiled PDF is blank, square, or directly reports an error. Some people also find that Chinese can be input and compiled, but the characters in the PDF look weak. Most of these problems are not "LaTeX does not support Chinese", but that the compiler, Chinese document class and font are not matched.
This article is written for those who want to use LaTeX to write Chinese papers, reports or handouts, especially readers who have just started using online editors and have not yet figured out why Chinese cannot be produced. After reading, you should be able to tell which category the problem belongs to, and check the compiler, Chinese support, fonts and encoding in order.
The method here is applicable to most online LaTeX editors and does not rely on the interface of a certain website. The LaTeX-related capabilities that OmniDoc currently publicly describes are LaTeX and Word conversion in the UniDoc web editor. It does not replace your compiler and font settings. The following check items still need to be checked one by one.
How to input and display LaTeX Chinese in the online editor? One sentence conclusion
LaTeX Chinese can be displayed normally, provided that a compiler that supports Unicode (XeLaTeX or LuaLaTeX) is used, ctex Chinese support is added to the document, and all Chinese fonts are installed on the editor server. There is usually no problem with Chinese input itself. The failure to display is basically because one of the three items is not matched.
| your situation | Recommended practices | reason |
|---|---|---|
| Write a Chinese paper or report without a school template | Use ctexart or ctexbook document class, choose XeLaTeX as compiler | ctex will automatically set Chinese fonts, punctuation and line breaks, eliminating the need for manual configuration. |
| Existing LaTeX template for school or journal | Use the template directly and don’t change the document class at will. | Templates are usually already equipped with compilers and fonts, and changes can easily introduce new problems. |
| The main part is in English, with only a few Chinese annotations. | Compile uniformly with XeLaTeX, and use Chinese font settings for Chinese. | When using pdfLaTeX in English, it is easy to report errors when encountering Chinese. Unifying the compiler will save trouble. |
| Chinese characters are displayed as squares or blanks | Confirm the compiler first, then check the server font | The compiler does not support Unicode or the font is missing, which will prevent Chinese from being displayed. |
| Chinese can be displayed but PDF is blurry | Check whether the font is embedded as a vector and zoom in to see it again | Bitmap fonts or preview scaling can make text look unclear |
First determine what kind of problem it is
Look at the symptoms first and then deal with the causes, which can save you a lot of detours.
| symptoms | Common reasons | How to confirm |
|---|---|---|
| The compiler reports an error directly, indicating that the character is not recognized. | Compile the source file including Chinese with pdfLaTeX | Check the compiler settings to make sure it is still pdfLaTeX |
| Chinese becomes square or blank in PDF | The Chinese font is missing, or the document does not specify a Chinese font | View font-related warnings in the log, check document classes and font settings |
| There are a lot of Missing character in the log. | The current font does not contain these characters | Write down the characters prompted by the log to confirm whether they are rare words or special symbols. |
| It can be displayed in Chinese, but the position of punctuation is strange and the line breaking is strange. | Chinese document class is not used, Chinese typesetting rules do not take effect | Confirm whether the introduction area uses Chinese document classes such as ctexart |
| It can be displayed in Chinese, but the text is empty when enlarged. | The font is not embedded as a vector, or a bitmap font is used | Zoom in to a larger scale to view the edges of the text and check the exported PDF font information |
# item-by-item troubleshooting and repair
The following order is in order from easy to difficult. Recompile each step to see if the problem has disappeared.
- Confirm the compiler. In the editor's compilation settings, change the compiler to XeLaTeX or LuaLaTeX, and then recompile. PdfLaTeX cannot deal with Chinese characters directly by default, and this step often solves the problem.
two. Confirm the document class. The introduction section uses\ documentclass {ctexart} (ctexbook is available for writing manuscripts or longer papers, and the school template shall prevail if required by the school) instead of article. Ctex automatically sets Chinese fonts, punctuation compression, and spacing between Chinese and English.
- Confirm the font settings. Using the default font of ctex is usually sufficient. If you need to specify a font, you can use\ setCJKmainfont to write a font name that does exist on the server in the introduction area. If the font name is misspelled, or the font is not available on the server, the Chinese character will be missing or displayed as a square.
- View the compilation log. When a Missing character appears, the log lists the missing characters. If Chinese characters are commonly used, it is mostly a font problem, just change to a font that contains that character; if it is a rare character or a special symbol, you can change the font, or use other writing methods instead.
- Check the source file encoding. The source file should be saved as UTF-8 encoding. If you copy content from a Word or web page, it may include invisible characters or other encodings, resulting in a compilation exception. Delete the content, paste it in plain text and recompile it.
- Isolate the problem with the test file. Create a new test file that contains only a document class, a few lines of Chinese, and a mathematical formula. After compiling, add the text back paragraph by paragraph. In this way, you can quickly find out which paragraph is causing the problem.
If you have done all six steps and still fail, you can write down the first error message in the log and check it against the editor's help documentation or template instructions.
# how to avoid the next occurrence
-when writing Chinese documents, start directly from the ctexart or school template, not from the blank article. -always use a compiler. Chinese and English mixed documents also use XeLaTeX or LuaLaTeX, do not switch back and forth between projects. -the font setting is written only once and is placed in the introduction area. Keep a test file at the same time, which can be quickly verified later when changing environments or editors. -before copying text from other software, paste it into plain text and then put it into the source file to reduce hidden formats and abnormal characters. -before submitting or sending, carefully check the punctuation, page numbers and formulas after exporting the PDF. Don't just look at the compilation results of the source files.
# frequently asked questions (FAQ)
1. Can LaTeX write Chinese papers?
Sure. With XeLaTeX or LuaLaTeX plus ctex Chinese support, you can write Chinese papers, reports and handouts, and many schools and periodicals also provide Chinese templates. Whether or not to adopt LaTeX should be confirmed in accordance with the requirements of the tutor or journal.
2. The editor interface is the Chinese version, can you write Chinese directly?
Not necessarily. The interface language only affects menus and prompt text, and whether the document can be displayed in Chinese depends on the compiler, document class, and font. The interface is in Chinese, and the document may still need to be configured separately according to the steps above.
3. Do you need to change the setting to enter Chinese in an English environment?
The input method has nothing to do with the compilation process, and you can enter Chinese no matter which interface you use. What you really need to pay attention to is whether the compiler supports Chinese. If you use XeLaTeX or LuaLaTeX together, you can avoid most of the problems.
4. What if the handwriting becomes false after the Chinese PDF is printed?
Common reasons are that fonts are not embedded in vector mode, or that the resolution setting is low when printing. First enlarge to check the edge of the text, if there is a font problem, change the font to recompile and then print.
# Summary
Most of the problems with LaTeX Chinese display are due to the lack of matching among compiler, Chinese document class and font. Check item by item in the order of compiler, document class, font, log, encoding, and test file, and you can usually find the reason quickly. Before writing a Chinese paper, use the test file to confirm that the environment is available, which will save a lot of rework.
Open OmniDoc to edit, convert or translate your LaTeX document


