'How to use Latex to write Chinese documents in ArchLinux system?

I installed the following packages according to what ArchLinux officially said:

Archlinux TexLive

$ sudo pacman -S texlive-most  texlive-langchinese

I compile it like this:

\documentclass[UTF8]{ctexart}
\begin{document}
中文文档类测试。
\end{document}
$ pdflatex demo.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021/Arch Linux) (preloaded format=pdftex)
 restricted \write18 enabled.
entering extended mode
(./demo.tex
! Undefined control sequence.
l.1 \documentclass
                  {ctexart}
? 
! Undefined control sequence.
l.2 \begin
          {document}
? 
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] )</usr/share/texmf-dist/
fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on demo.pdf (1 page, 12721 bytes).
Transcript written on demo.log.

However, the result obtained is this:

enter image description here

Is this because I didn't add Chinese fonts? Or some other reason?



Solution 1:[1]

This problem is caused by my lack of understanding of the tex typesetting system.I used pdflatex directly which doesn't support Unicode character set, which is very stupid.Documents should be compiled with xelatex for the Unicode character set.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 aszswaz