如果用Sublime编译时由于默认采用了pdfLatex进行编译,而fontspec宏包不是由其实现的,一般会出现
Fatal Package fontspec Error: The fontspec package requires either XeTeX or [\msg_fatal:nn {fontspec} {cannot-use-pdftex}]
这个时候建议使用xelatex
进行编译
xelatex o1.tex # 01.tex 为tex的源码
编译过程中可能报错其内容为可能带找不到字体的问题。具体内容可能如下:
(c:/texlive/2019/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsnew.def
kpathsea: Running mktextfm KaiTi/OT
The command name is C:\texlive\2019\bin\win32\mktextfm
kpathsea: Running mktexmf KaiTi/OT.mf
The command name is C:\texlive\2019\bin\win32\mktexmf
name = KaiTi/OT, rootname = KaiTi/OT, pointsize =
mktexmf: empty or non-existent rootfile!
Cannot find KaiTi/OT.mf.
kpathsea: Appending font creation commands to missfont.log.
kpathsea: Running mktextfm KaiTi/B/OT
其原因可能是相应的字体无法找到, 比如我电脑上的楷体
的名字叫楷体_GB2312
而非KaiTi
将文件tex/latex/ctex/fontset/ctex-fontset-windowsnew.def
中的内容
\setCJKmainfont
[ BoldFont = SimHei , ItalicFont = KaiTi] { SimSun }
\setCJKsansfont
[ BoldFont = { *~Bold } ] { Microsoft~YaHei }
\setCJKmonofont { FangSong }
\setCJKfamilyfont { zhkai } { KaiTi }
修改为:
\setCJKmainfont
[ BoldFont = SimHei , ItalicFont = 楷体_GB2312 ] { SimSun }
\setCJKsansfont
[ BoldFont = { *~Bold } ] { Microsoft~YaHei }
\setCJKmonofont { FangSong }
\setCJKfamilyfont { zhkai } { 楷体_GB2312 }
最后再采用xelatex
进行编译就可以编译通过了。
Binary file doc/generic/latex-notes-zh-cn/latex-notes-zh-cn.pdf matches
doc/generic/zhspacing/zhs-man.tex:227: ItalicFont=KaiTi]{SimSun}
doc/generic/zhspacing/zhs-man.tex:229:\newfontfamily\zhttfont[BoldFont=SimHei]{KaiTi}
doc/generic/zhspacing/zhs-man.tex:336:punctuations using some fonts such as \fntname{KaiTi\_GB2312} etc. I've told
Binary file doc/latex/ctex-faq/ctex-faq.pdf matches
doc/latex/elegantbook/elegantbook-cn.tex:79:\setCJKmainfont[BoldFont={SimHei},ItalicFont={KaiTi}]{SimSun}
doc/latex/elegantbook/elegantbook-cn.tex:80:\setCJKsansfont[BoldFont={SimHei},ItalicFont={KaiTi}]{KaiTi}
doc/latex/elegantbook/elegantbook-cn.tex:81:\setCJKmonofont[BoldFont={SimHei},ItalicFont={KaiTi},Scale=0.7]{Microsoft YaHei}
doc/latex/elegantbook/elegantbook-en.tex:80:\setCJKmainfont[BoldFont={SimHei},ItalicFont={KaiTi}]{SimSun}
doc/latex/elegantbook/elegantbook-en.tex:81:\setCJKsansfont[BoldFont={SimHei},ItalicFont={KaiTi}]{KaiTi}
doc/latex/elegantbook/elegantbook-en.tex:82:\setCJKmonofont[BoldFont={SimHei},ItalicFont={KaiTi},Scale=0.7]{Microsoft YaHei}
Binary file doc/latex/seuthesis/sample-bachelor.pdf matches
Binary file doc/latex/seuthesis/seuthesis.pdf matches
Binary file doc/latex/xtuthesis/xtuthesis.pdf matches
doc/latex/zhlipsum/zhlipsum-en.tex:40:\setCJKmonofont{FangSong}[ItalicFont=KaiTi]
doc/luatex/luatexja/luatexja-zhfonts.tex:234: 楷体 & \texttt{simkai.ttf} & KaiTi & {\jfontspec{KaiTi}我能吞下玻
璃而不伤身体} \\
doc/plain/impatient-cn/fonts.tex:31: \def\kai{KaiTi}
doc/support/asymptote-faq-zh-cn/src/preamble_newnew.tex:10:\setCJKmainfont[BoldFont=SimHei,ItalicFont=KaiTi_GB2312]{SimSun}
doc/support/asymptote-manual-zh-cn/src/winfonts.tex:5:\setCJKmainfont[BoldFont={SimHei}, ItalicFont={KaiTi_GB2312}]{SimSun}
doc/support/asymptote-manual-zh-cn/src/winfonts.tex:9:\setCJKfamilyfont{rm}[BoldFont={SimHei}, ItalicFont={KaiTi_GB2312}]{SimSun} % 同 main
doc/support/asymptote-manual-zh-cn/src/winfonts.tex:14:\setCJKfamilyfont{kai}{KaiTi_GB2312}
doc/xelatex/xecjk/example/xeCJK-example-fallback.tex:13:\setCJKmainfont[AutoFakeBold,AutoFakeSlant]{KaiTi_GB2312}
doc/xelatex/xecjk/example/xeCJK-example-mathblock.tex:15:\setCJKmonofont{KaiTi}
doc/xelatex/xecjk/example/xeCJK-example-mathblock.tex:26: \setCJKmonofont [ #1 ] { KaiTi }
fonts/misc/cjk-gs-integrate/cjkgs-macos-removeonly.dat:477:Name: STKaiTi-TC-Bold
fonts/misc/cjk-gs-integrate/cjkgs-macos-removeonly.dat:487:Name: STKaiTi-TC-Regular
fonts/misc/cjk-gs-integrate/cjkgs-sinotype.dat:36:# index 2: STKaiTi-TC-Bold
fonts/misc/cjk-gs-integrate/cjkgs-sinotype.dat:39:# index 5: STKaiTi-TC-Regular
scripts/cjk-gs-integrate/cjk-gs-integrate.pl:2558:Name: KaiTi
source/latex/ctex/ctex.dtx:9705: [ BoldFont = SimHei , ItalicFont = KaiTi_GB2312 ] { SimSun }
source/latex/ctex/ctex.dtx:9708: \setCJKfamilyfont { zhkai } { KaiTi_GB2312 }
source/latex/ctex/ctex.dtx:9713: [ BoldFont = SimHei , ItalicFont = KaiTi ] { SimSun }
source/latex/ctex/ctex.dtx:9717: \setCJKfamilyfont { zhkai } { KaiTi }
source/latex/ctex/ctex.dtx:10652: {windowszhkai} {KaiTi} ,
source/latex/fduthesis/fduthesis.dtx:3492: \@@_set_cjk_font_kai:n { KaiTi }
source/latex/seuthesis/seuthesis.dtx:736:\setCJKfamilyfont{zhkai}{KaiTi}
source/latex/xduthesis/xduthesis.dtx:435:\setCJKmonofont{KaiTi_GB2312}
source/latex/xduthesis/xduthesis.dtx:439:\setCJKfamilyfont{kai}{KaiTi_GB2312}
source/latex/zhlipsum/zhlipsum.dtx:203:\setCJKmonofont{FangSong}[ItalicFont=KaiTi]
source/xelatex/mynsfc/mynsfc.dtx:262:\setCJKfamilyfont{kai}{KaiTi}
source/xelatex/xecjk/xeCJK.dtx:890:% \setCJKmainfont[AutoFakeBold,AutoFakeSlant]{KaiTi_GB2312}
source/xelatex/xecjk/xeCJK.dtx:895:% 之后,就设置了 |SimSun| 是 |KaiTi_GB2312| 的备用字体,而 |SimSun-ExtB| 是
source/xelatex/xecjk/xeCJK.dtx:955:% KaiTi,楷体
source/xelatex/xecjk/xeCJK.dtx:13335:\setCJKmainfont[AutoFakeBold,AutoFakeSlant]{KaiTi_GB2312}
source/xelatex/xecjk/xeCJK.dtx:13898:\setCJKmonofont{KaiTi}
source/xelatex/xecjk/xeCJK.dtx:13909: \setCJKmonofont [ #1 ] { KaiTi }
tex/context/base/mkii/font-chi.mkii:973:\definefontsynonym [SimplifiedChineseKaiTiRegular] [gbkai] [encoding=gbk]
tex/context/base/mkii/font-chi.mkii:974:\definefontsynonym [SimplifiedChineseKaiTiSlanted] [gbkaisl] [encoding=gbk]
tex/context/base/mkii/font-chi.mkii:975:\definefontsynonym [SimplifiedChineseKaiTiBold] [gbkai] [encoding=gbk]
tex/context/base/mkii/font-chi.mkii:976:\definefontsynonym [SimplifiedChineseKaiTiBoldSlanted] [gbkaisl] [encoding=gbk]
tex/context/base/mkii/font-chi.mkii:978:\definefontsynonym [TraditionalChineseKaiTiRegular] [b5kai] [encoding=big5]
tex/context/base/mkii/font-chi.mkii:979:\definefontsynonym [TraditionalChineseKaiTiSlanted] [b5kaisl] [encoding=big5]
tex/context/base/mkii/font-chi.mkii:980:\definefontsynonym [TraditionalChineseKaiTiBold] [b5kai] [encoding=big5]
tex/context/base/mkii/font-chi.mkii:981:\definefontsynonym [TraditionalChineseKaiTiBoldSlanted] [b5kaisl] [encoding=big5]
tex/context/base/mkii/font-chi.mkii:1012:\defineunicodefont [SimKaiTi] [SimplifiedChineseKaiTi] [chinese]
tex/context/base/mkii/font-chi.mkii:1013:\defineunicodefont [TraKaiTi] [TraditionalChineseKaiTi] [chinese]
tex/context/base/mkii/font-chi.mkii:1021:% \definealternativestyle [ChineseTitleFont] [\bfd\SimKaiTi] []
tex/generic/ctex/ctexmakespa.tex:57: {windowszhkai} {KaiTi} ,
tex/latex/ctex/fontset/ctex-fontset-windowsnew.def:97: [ BoldFont = SimHei , ItalicFont = KaiTi ] { SimSun } tex/latex/ctex/fontset/ctex-fontset-windowsnew.def:101: \setCJKfamilyfont { zhkai } { KaiTi }
tex/latex/ctex/fontset/ctex-fontset-windowsold.def:85: [ BoldFont = SimHei , ItalicFont = KaiTi_GB2312 ] { SimSun }
tex/latex/ctex/fontset/ctex-fontset-windowsold.def:88: \setCJKfamilyfont { zhkai } { KaiTi_GB2312 }
tex/latex/elegantbook/elegantbook.cls:58: \setCJKmainfont[BoldFont={SimHei},ItalicFont={KaiTi}]{SimSun}
tex/latex/elegantbook/elegantbook.cls:59: \setCJKsansfont[BoldFont={SimHei},ItalicFont={KaiTi}]{KaiTi}
tex/latex/elegantbook/elegantbook.cls:60: \setCJKmonofont[BoldFont={SimHei},ItalicFont={KaiTi},Scale=0.7]{Microsoft YaHei}
tex/latex/elegantbook/elegantbook.cls:68: \setCJKfamilyfont{zhkai}{KaiTi}
tex/latex/elegantnote/elegantnote.cls:55: \setCJKmainfont[BoldFont={SimHei},ItalicFont={KaiTi}]{SimSun}
tex/latex/elegantnote/elegantnote.cls:56: \setCJKsansfont[BoldFont={SimHei},ItalicFont={KaiTi}]{KaiTi}
tex/latex/elegantnote/elegantnote.cls:57: \setCJKmonofont[BoldFont={SimHei},ItalicFont={KaiTi},Scale=0.9]{Microsoft YaHei}
tex/latex/elegantnote/elegantnote.cls:65: \setCJKfamilyfont{zhkai}{KaiTi}
tex/latex/fduthesis/fduthesis-en.cls:511: \__fdu_set_cjk_font_kai:n { KaiTi }
tex/latex/fduthesis/fduthesis.cls:548: \__fdu_set_cjk_font_kai:n { KaiTi }
tex/latex/hithesis/ctex-fontset-siyuan.def:66: [ BoldFont = SimHei , ItalicFont = KaiTi ] { SourceHanSerifCN-Regular }
tex/latex/hithesis/ctex-fontset-siyuan.def:70: \setCJKfamilyfont { zhkai } { KaiTi }
tex/latex/xduthesis/xduthesis.cls:79:\setCJKmonofont{KaiTi_GB2312}
tex/latex/xduthesis/xduthesis.cls:83:\setCJKfamilyfont{kai}{KaiTi_GB2312}
tex/luatex/luatexja/addons/luatexja-zhfonts.sty:18:\newjfontface\kai{KaiTi}
tex/xelatex/mynsfc/mynsfc.cls:114:\setCJKfamilyfont{kai}{KaiTi}