Latex Installation:
sudo apt install texlive-full
Chinese font installation:
the sudo apt-get install Latex-cjk-all font Pack contains BSMI,BKAI,GKAI,GBSN four Chinese fonts. Bsmi and Bkai are BIG5 encoded in the Arial and italics, and the latter two Gkai and GBSN respectively deal with Simplified Chinese italics and italicized word. This is the CJK and CJKutf8 in Method 1 below .
Three ways to encode Chinese utf-8 in latex
We know that Latex generally supports Chinese editing with CJK and Ctex macros, the default encoding for CJK and Ctex is GBK, and silent encoding in Windows is GBK, so CJK and Ctex do not need special configuration to support Chinese latex compilation directly. You only need to save the file with GBK encoding. But what if we change the character encoding of a file into a more general utf-8? There are two ways to use it here. 1, CJKutf8, compile Tex files with Pdflatex
CJK has two basic macro packages: CJK and CJKutf8, which are intended for utf-8 encoding and are generally used as follows:
\usepackage{cjkutf8}\begin{document}\begin{cjk}{utf8}{<font>,} ... \end{cjk}\end{document}
Font for Simplified Chinese fonts, CJK comes with Utf-8 simplified characters of GBSN (Arial) and Gkai (italics), examples:
\DOCUMENTCLASS{ARTICLE}\USEPACKAGE{CJKUTF8}\BEGIN{DOCUMENT}\BEGIN{CJK}{UTF8}{GBSN} This is an example of CJKutf8, and the font used is GBSN. \end{cjk}\end{document}
Cons: There are only two types of fonts.
2. Ctex UTF8 option, compile with Xelatex
The above CJKutf8 only provide two fonts, the choice is too small, we can directly use the UTF8 option to enable Ctex support Utf-8 encoding, using Ctex rich fonts and Chinese settings can better edit the latex Chinese text, the syntax format is:
\documentclass[utf8]{article}\usepackage{ctex}\begin{document}...\end{document}
Alternatively, use Ctexart directly
\documentclass[utf8]{ctexart}\begin{document}...\end{document}
Example:
\documentclass{article}
\usepackage{ctex}
\begin{document}
This is an example of a Ctex utf-8 encoding, {\kaishu Here is the italic display},{\songti here is the Arial display},{\heiti here is the bold display},{\fangsong here is The Imitation Show}.
\end{document}
The following warnings are indicated during the compilation process and are not affected.
* Fontspec Warning: "Script-not-exist"
*
* Font ' fandolfang-regular ' does not contain script ' CJK '.
Latex Chinese support Ubuntu