[Latex] how to write Chinese?

Source: Internet
Author: User

There are several situations recently: I. The assignment is very simple. I want to use latex, but the English language is not hard. It takes half a day to configure a Chinese environment. 2. More and more friends asked me how to input Chinese characters. I did not have a good way to help people, so I had to study how to configure the latex Chinese environment myself.

Environment first

Compile: ctex package (really easy to use, save the configuration to configure. To link: http://www.ctex.org/CTeXDownload)

Editor: sublime Text 3 (but you need to install a plug-in: latextools)

Well, when installing ctex, I heard that this guy fully supports Chinese input, but he hasn't tried it all the time. Today, I learned the following methods:

\ Documentclass {ctexart}

\ Begin {document}

Adding Code does not support latex!

\ End {document}

Now the problem arises, and so many errors are reported:

 

This is obviously not a syntax issue. Why is it wrong to write the syntax. Obviously, the encoding method is incorrect. My default encoding for sublime is not utf8, so this is probably the case.

Change to see:

\ Documentclass[Utf8]{Ctexart}

\ Begin {document}

Adding Code does not support latex!

\ End {document}

Successful. (What is "utf8" later)

Now the question is, what exactly does ctexart do?

We use ctexart, ctexrep, and ctexbook to replace the article in the English text class. The report and book can add Chinese characters freely in the body. You must install the CJK macro package. How can I check whether there is any installation?

You can search for this item and click "CJK". If not, install it easily. (However, based on my experience, some packages cannot be downloaded without FQ .)

We can also see that CJK actually has two packages. We can study what it is for later.

Back to Ang, The ctexart environments are equivalent to the CJK environment automatically added between "\ begin {document}" and "\ end {document. That is to say, the chestnuts above are the same as those below:

\ Documentclass [utf8] {Article}

\ Usepackage {ctex}

\ Begin {document}

Adding Code does not support latex!

\ End {document}

Next let's take a look at the ctexart class options:

Cs4size, c5size:Use the default font size (the latter is the default)

GBK, utf8:Use GBK and utf8 encoding (the former is the default, and the tragedy is not changed at the beginning .)

Winfonts:There are only six types of fonts for Windows:, and (default setting)

Cap:Use a Chinese title Style

Nocap:Retain the English title Style

Punct:Adjust the Chinese Table vertex (width) (default option)

Nopunct:Opposite to punct

Space:Use the reserved space mode of CJK to retain spaces between Chinese characters (similar to English ). You need to process the spaces between Chinese characters and the spaces generated by line breaks by yourself (you can avoid adding % at the end of the line). Otherwise, the typographical results may not conform to the Chinese style. This mode can be converted to nospace through \ ctexnospace.

Nospace:Use the ignore space mode of CJK, that is, the CJK * Environment mode. CJK automatically ignores spaces between Chinese characters, which is in line with Chinese habits. In this mode, you can use ~ To separate Chinese and English characters. The spacing is slightly smaller than that of common spaces. This mode can be converted to the space mode through the \ ctexspace command. This is the default mode of the ctex macro package.

Indent:Blank space at the beginning of the field

Noindent:No space at the beginning of the field

Let's look at the command:

Font command:\ Songti \ heiti \ fangsong \ kaishu \ Lishu \ youyuan

Font size command:\ Zihao {Font Size}(There are 16 options 0-6,-0--6, 7, and 8)

Padding command:\ Ziju {Multiples of word width}

Convert numbers to Chinese characters:\ Ctexnumber {Result}{Number}(This command is equivalent to defining a new command. When using the command defined by result, the Chinese character version of the number is automatically output .)

\ Ctexdigits {Result}{Number}(Similar to the previous one, it just changes to a digit .)

(Example:

The output result is:

Unit title settings of the macro package: \ ctexsetup [<Key1>=<Value1>,<Key2>=<Value2>,…] {<Type>}

This is complicated and will not be written for the moment. Wait until I need it!

References: ctex.pdf

Finally, I would like to extend my high respect to developers! (After all, this is the first Chinese manual I have ever seen. It is not easy !)

[Latex] how to write Chinese?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.