How to type Chinese characters in LaTex (on Mac, using TeXShop)

This is one of the easiest ways to type Chinese characters in LaTeX on Mac, using the default TeXShop editor. (If you know of an easier way, please let me know in the comments below!)

I have tried for hours, experimenting with different packages, before “discovering” the following steps. Hope it helps!

Step 1) Add “\usepackage{ctex}” to the beginning of the document. This will load the main package ctex.

Step 2) It is very important to save the LaTeX file in UTF-8 format, otherwise all Chinese characters will appear as question marks. The preferred way to do this is via:

TeXShop > Preferences > Encoding = Unicode (UTF-8). (see image below)

This will “permanently” set the format as UTF-8 by default. If you don’t do this, an annoying thing that can happen is that your TeX file reverts to “non-UTF8” upon saving. That means, the Chinese characters may appear correctly at first, but once you re-save the file, all Chinese characters become question marks again.

Alternatively, if you don’t want to set UTF-8 as default, you may add the following line to the very first line of the TeX document:

% !TEX encoding = UTF-8 Unicode

This will make TeXShop remember to save it in UTF-8 format every time.

Step 3) Just type Chinese characters directly into the LaTeX file. No “wrapper” is needed around the Chinese characters.

Step 4) When you compile the document, be sure to compile it by XeLaTeX. You can select this option next to the “Typeset” button. If you compile it using normal LaTeX, you will get the following error:

“Critical ctex error:”fontset-unavailable

CTeX fontset `fandol’ is unavailable in current mode.”


For Windows users, I suppose the above steps still work. I have not tried it personally though. Other packages may work only for Windows/Mac specifically since each system have different preloaded Chinese fontsets.

Advertisements

About mathtuition88

http://mathtuition88.com
This entry was posted in maths tuition and tagged , . Bookmark the permalink.

One Response to How to type Chinese characters in LaTex (on Mac, using TeXShop)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.