Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q36 如何设置支持中文,需要哪些包,编译器。。。 #44

Open
Lihua1990 opened this issue Feb 13, 2020 · 3 comments
Open

Comments

@Lihua1990
Copy link
Collaborator

看下我的pull request, 有空处理下,基本没改,就是试试pull request, waiting for merge...

@EthanDeng EthanDeng changed the title Q 如何设置支持中文,需要哪些包,编译器。。。 Q36 如何设置支持中文,需要哪些包,编译器。。。 Feb 14, 2020
@EthanDeng
Copy link
Owner

目前主流支持中文有两种方式,一种是 ctex 宏包,另外一种是 xeCJK 宏包,其中可以理解为 ctexxeCJK 更大,并且添加了更多符合中文的东西,但是有个小问题就是,ctex 改的东西太多了,并且也依赖于非常多的宏包。

ctex 宏包支持方式

\documentclass[UTF8]{article}

\usepackage{lipsum}
\usepackage[UTF8,scheme=plain]{ctex}

\begin{document}

\lipsum[1]
中文

\end{document}

你可以使用 pdflatex 或者 xelatex 进行编译,如果主文档大部分是英文,用 pdflatex 就好,如果主文档是中文文档,推荐使用 xelatex(速度慢挺多的)。

xeCJK 宏包支持方式

在使用 pdflatex 编译英文文档时,并不好使用系统字体,如果需要调用系统字体,需要使用 fontspec 指定系统字体,并使用 xelatex 进行编译。类似的,中文如果使用系统字体,可以使用 xeCJK 包,指定中文字体。

\documentclass[UTF8]{article}

\usepackage{lipsum}
\usepackage{xeCJK}
\setCJKmainfont[BoldFont={FZHei-B01},ItalicFont={FZKai-Z03}]{FZShuSong-Z01}
\setCJKsansfont[BoldFont={FZHei-B01},ItalicFont={FZHei-B01}]{FZHei-B01}
\setCJKmonofont[BoldFont={FZHei-B01},ItalicFont={FZHei-B01}]{FZFangSong-Z02}

\begin{document}

\lipsum[1]
中文

\end{document}

其中使用到的字体分别是

  • FZShuSong-Z01:方正书宋
  • FZKai-Z03:方正楷体
  • FZHei-B01:方正黑体

字体文件见:方正字体,提取码:njy9。

@EthanDeng
Copy link
Owner

pr 已经接受了。

@EthanDeng
Copy link
Owner

使用系统已有中文字体

\documentclass{article}

\usepackage{lipsum}
\usepackage{xeCJK}
\setCJKmainfont[BoldFont={SimHei},ItalicFont={STKaiti}]{SimSun}
\setCJKsansfont[BoldFont={SimHei},ItalicFont={STKaiti}]{STKaiti}
\setCJKmonofont[BoldFont={Fangsong},ItalicFont={Fangsong}]{Fangsong}

\begin{document}

\lipsum[1]

中文 \textit{楷体} \textbf{黑体}


\end{document}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants