These days, I’m trying to edit some Chinese text documents edit in LaTeX language. It’s not a problem in Windows since Chinese font support, and Windows OS is popular used in Chinese forum. For English supporting is not a problem in LaTeX, but Chinese edit problem I encounter under Mac OS. I’m trying to make the notes to remember the steps here in case of somebody needs it as well.
Step 1. Choose good editor and compiler package
As friend recommend, I used TeXstudio for my LaTeX document editing, this tool was quite good when I used under Windows, I suppose it will do great job under Mac OS as well. And Install the MacTeX the LaTeX compiling supporting.
Step 2. Change the PDFLaTeX
command to XeLaTeX
The first problem I encounter is when I finish a sample document editing, and tried to compile it, TeXstudio will use the default command PDFLaTeX
to compile it. It works under PC, but failed under Mac system. So the first thing you need to set the default command to XeLaTeX
.
In TeXstudio, you can change the option via “Preferences” -> “Build” -> “Default compiler”, select the value as XeLaTeX
. Now if you compile this document, it works fine:
1 2 3 4 5 6 7 8 |
|
and the result is like this:
Step 3. Support Chinese words editing
But if we change the English content to Chinese, it doesn’t work well, such like this:
1 2 3 4 5 6 7 8 |
|
Except the English words can be displayed well, everything is mass, unreadable. So we need use ctex
package to support it. so add the \usepackage{ctex}
after \documentclass{article}
, the result is still bad. So I realize the problem might be caused by the fonts supporting. And then I inserted these lines before \begin{document}
, the document like this:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
and change the encoding to UTF-8
then the final result likes this:
Step 4. How do I know the font’s name
As you see, I insert these line about the font supporting, but you may ask why I know the Chinese font name. Yes, it’s tricky, :p Firstly, I installed Microsoft Office, and I open the Microsoft Word, you can find the font name from the font dropbox, after you selected a font, the font text box will show its name. See, that’s why I know the font name exactly.
In the eend
Here I give an example of the Chinese words editing, hope it’s useful for your reference.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
-EOF-