Introduction
LaTeX is invented by foreigners, so it is not supported in Chinese by default. So how to use latex to write Chinese documents. Then use CJK. CJK was developed by Werner Lemberg, and we can display Chinese in latex files as long as we use the CJK macro package. About CJK Configuration do not need to do our own, Ctex have been configured, we just introduce a macro package.
Introduction to CJK use
1 2 3 4 5 6 7 8 9 10 |
\documentclass[12pt,a4paper]{article} \USEPACKAGE{CJK} \begin{document} \begin{cjk*}{gbk}{song} \CJKtilde \ Cjkindent Hello everyone, I am ~\latex{}. \clearpage \end{cjk*} \end{document} |
Line 1th: Ordinary article type, the default font size is 12pt, the article is a single column display, paper for A4 paper. Line 2nd: Import CJK Macro Package, CJK Macro Package provides two environments: CJK Environment and CJK* Environment, the difference between the two environments: for Chinese characters behind the space, the former does not ignore, the latter ignore, we recommend the use of cjk* environment. Line 3rd: Start the document environment. Line 4th: Start the cjk* environment, the default encoding is GBK, the default font is Arial. Line 5th: Redefine the "~" symbol so that "~" is set to a reasonable interval.
Line 6th: Indent in the first line. Line 7th: ~ Represents a space, the general Chinese and English are to be left blank, \latex{} for the name of LaTeX display. Line 8th: Usually when we use CJK environment, we need to add this sentence, because it can lead to some unexpected errors, which are mentioned later in this article. Line 9th: End the cjk* environment. Line 10th: End document Environment.
Small details
\cjkspace command: Switch from the cjk* environment to the CJK environment. \cjknospace command: Switch from CJK to cjk* environment.
Common errors
Error: Argument of \cjk@xx have an extra}
The number of words over a certain limit will be reported this error, the solution is as follows:
1.\begin{cjk*}{gbk}{kai} must be placed behind \begin{document} (not necessarily next to each other). 2.\end{cjk*} to add a \clearpage