Closed aqni closed 1 year ago
测试平台:
我在overleaf上上传了一个(这里),主要区别是封面汉字偏低
texlive应该是包含一套开源中文字体 Fandol
的,所以中文字体在所有平台上都可用。
但是 Times New Roman 是商业字体,仅windows、macos和overleaf自带,ubuntu和某些docker镜像等开源项目应该是不自带的。
一种解决办法是,当无法找到 Times New Roman 字体时,使用开源的类 Times New Roman字体。
一些类 Times New Roman 字体: https://tex.stackexchange.com/questions/211326/best-math-font-with-times-new-roman-in-xelatex
在 commit https://github.com/Tr0py/NKU-thesis-template-2020/commit/ea7e01f76dd45bc956a1db58bedad8a78dde9653 中,我在 Times New Roman 不可用时,使用 STIX 字体。
我测试了docker和ubuntu。看起来有些warning。
Package fontspec Warning: Font "FandolFang-Regular" does not contain requested
(fontspec) Script "CJK".
Package fontspec Warning: Font "FandolSong" does not contain requested Script
(fontspec) "CJK".
Package fontspec Info: Could not resolve font "FandolSong/I" (it probably
(fontspec) doesn't exist).
Package fontspec Warning: Font "FandolHei-Regular" does not contain requested
(fontspec) Script "CJK".
Package fontspec Info: Font family 'FandolHei-Regular(0)' created for font
(fontspec) 'FandolHei-Regular' with options
(fontspec) [Script={CJK},Extension={.otf},BoldFont={FandolHei-Bold}
].
(fontspec)
(fontspec) This font family consists of the following NFSS
(fontspec) series/shapes:
(fontspec)
(fontspec) - 'normal' (m/n) with NFSS spec.:
(fontspec) <->"[FandolHei-Regular.otf]/OT:language=dflt;"
(fontspec) - 'small caps' (m/sc) with NFSS spec.:
(fontspec) - 'bold' (b/n) with NFSS spec.:
(fontspec) <->"[FandolHei-Bold.otf]/OT:language=dflt;"
(fontspec) - 'bold small caps' (b/sc) with NFSS spec.:
成功触发了STIX替代Times New Roman的代码
Class nkuthesis Warning: “Times New Roman”不可用,使用“STIX”替代 on input line 22.
至少看起来封面的楷体不能正常显示。
可能类Unix系统需要额外的字体的安装。pkuthess有过相关文档:《TeX Live + pkuthss 安装使用傻瓜指南》中字体配置相关部分提示用户copy字体文件到指定位置后进行编译。 从这个issue https://github.com/CasperVector/pkuthss/issues/35 看起来,pkuthess也用了字体文件。
我觉得我们的两个方案分别是
好奇其他模板怎么处理字体问题的?
MacOS上面编译失败。找不到"FandolSong"。
Package hyperref Warning: Rerun to get /PageLabels entry.
(/usr/local/texlive/2021/texmf-dist/tex/latex/biblatex/lbx/english.lbx)
(/usr/local/texlive/2021/texmf-dist/tex/latex/biblatex/blx-case-expl3.sty)
No file main.bbl.
Package pgfplots notification 'compat/show suggested version=true': you might b
enefit from \pgfplotsset{compat=1.17} (current compat level: 1.13).
kpathsea: Running mktextfm FandolSong/OT
/usr/local/texlive/2021/texmf-dist/web2c/mktexnam: Could not map source abbreviation O for OT.
/usr/local/texlive/2021/texmf-dist/web2c/mktexnam: Need to update /usr/local/texlive/2021/texmf-dist/fonts/map/fontname/special.map?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input OT
This is METAFONT, Version 2.71828182 (TeX Live 2021) (preloaded base=mf)
kpathsea: Running mktexmf OT
! I can't find file `OT'.
<*> \mode:=ljfour; mag:=1; ; nonstopmode; input OT
Please type another input file name
! Emergency stop.
<*> \mode:=ljfour; mag:=1; ; nonstopmode; input OT
Transcript written on mfput.log.
grep: OT.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input OT' failed to make OT.tfm.
kpathsea: Appending font creation commands to missfont.log.
! Package fontspec Error: The font "FandolSong" cannot be found.
For immediate help type H <return>.
...
l.97 \maketitle
?
其实,只要知道各系统有哪些字体,通过fallback的方式,就能至少找到一个字体。
不过,我最疑惑的是,为什么Fandol字体会找不到,理论上使用了xecjk应该就包含fandol字体了呀。
找不到Fandolsong问题也不大,主要是封面和目录在使用,我换一种实现方式应该可以规避。
至少看起来封面的楷体不能正常显示。
应该是pdf查看器的问题,在windows上我用texworks自带的pdf查看器也无法显示FandolSong字体,封面上的“南开大学”四字,在之前的实现方式中就是用的FandolSong字体。
自动配置项如下:
手动配置项如下:
在mac和windows上使用系统字体,ubuntu、overleaf、docker上自动使用Fandol字体。
但是ctex似乎无法通过自动配置在ubuntu使用思源字体,想要使用ubuntu上的思源字体需要手动配置。
这一问题可以在加载nkuthesis文档类前项ctexart传入选项来手动配置
% head
\PassOptionsToClass{fontset=ubuntu}{ctexart}
\documentclass{nkuthesis}
% other
实在有需要的话,也可以给nkuthesis声明一个选项用来设置fontset=ubuntu
Fandol字体和中易字体是比较像的,但是思源字体和中易字体能很容易的看出区别,我还是建议使用Fandol字体。
如果最新提交的代码测试没有问题的话我就创建一个pull requestt
MacOS可以编译了。除了字体看起来稍有不同。
ubuntu/docker 成功编译。效果如下。感觉还可以!
已合并
Discussed in https://github.com/Tr0py/NKU-thesis-template-2020/discussions/35