0%

ElegantLaTeX-Paper模板字体问题的解决过程

为电脑重装MacTeX后,在使用ElegantPaper模板的过程中,遇到了字体异常显示的问题。本人在GitHub提交了issues,并得到了sikouhjw的耐心解答,最终解决了问题。特将此问题以及其解决过程记录如下。

问题

基本信息

  • 系统:Mac
  • 发行版:MacTeX 2020
  • 模板:ElegantPaper 0.09
  • 编辑器:VSCode
  • 编译方式:XeLaTeX

MWE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
\documentclass[lang=cn]{elegantpaper}

\title{标题字体}
\author{}
\date{}

\begin{document}

\maketitle

\begin{abstract}
逗号,逗号
\keywords{逗号,逗号}
\end{abstract}

\section{字体}
逗号,逗号

\end{document}

问题

  1. 篇名、小标题、“摘要”、“关键词”的字体变为Fandol系列字体
  2. 摘要内容、正文的中文逗号变成FandolSong的逗号

Warings如下:

1
2
3
4
5
Font "FandolSong-Regular" does not contain requested
(fontspec) Script "CJK".

Font "FandolKai-Regular" does not contain requested
(fontspec) Script "CJK".

PDF截图

输出PDF预览

初步解决方案及反馈

解决方案

  1. 使用fontset = mac选项更正CTeX宏集的字体检测

  2. 使用sudo tlmgr update --all命令更新宏包和其他相关组件

反馈

  1. 中文字体和逗号已经变更为Mac中的默认字体,但与更改前的字体比较相似。

更新宏包后调用的字体

  1. 使用pdffonts paper.tex可以看出更新宏包前后,输出PDF的字体结构变化。

    • 更新宏包前:

      1
      2
      3
      4
      5
      6
      7
      name                                 type              encoding         emb sub uni object ID
      ------------------------------------ ----------------- ---------------- --- --- --- ---------
      NBPJAL+FandolSong-Bold-Identity-H CID Type 0C Identity-H yes yes no 5 0
      NATVCG+FandolKai-Regular-Identity-H CID Type 0C Identity-H yes yes no 7 0
      HLGVII+TeXGyreTermesX-Regular Type 1C WinAnsi yes yes yes 8 0
      YIOMZF+TeXGyreTermesX-Bold Type 1C WinAnsi yes yes yes 9 0
      FYXSID+FandolSong-Regular-Identity-H CID Type 0C Identity-H yes yes no 11 0
    • 更新宏包后:

    1
    2
    3
    4
    5
    6
    7
    name                                 type              encoding         emb sub uni object ID
    ------------------------------------ ----------------- ---------------- --- --- --- ---------
    IWTXZO+STSongti-SC-Bold CID TrueType Identity-H yes yes yes 5 0
    XUYMGA+STKaitiSC-Regular CID TrueType Identity-H yes yes yes 7 0
    YJRCJA+TeXGyreTermesX-Regular Type 1C WinAnsi yes yes yes 8 0
    FPOJAO+TeXGyreTermesX-Bold Type 1C WinAnsi yes yes yes 9 0
    SNSHQV+STSongti-SC-Light CID TrueType Identity-H yes yes yes 11 0
  2. 根据编译器的Warings,也可以看出调用字体的变化:

    1
    2
    3
    4
    5
    Font "Kaiti SC" does not contain requested Script
    (fontspec) "CJK".

    Font "Songti SC Light" does not contain requested
    (fontspec) Script "CJK".

问题

  1. 如何更改为模板中使用的标题字体
  2. 是否仿照模板1.4 中文字体选项的示例自定义

深入解决

对上述问题的解释

如何更改为模板中使用的标题字体

是否仿照模板1.4 中文字体选项的示例自定义

elegantpaper-cn.pdf中,用到的字体是中易字库,是CTeX宏集在Win下默认调用的字库,Mac中没有。建议有三个:

  1. 去网上下载、安装中易字库
  2. 不需要仿照模板手册的字体,就用默认的就好
  3. 要追求字体效果,可以试试模板手册里写的方正字体

具体解决方案

  1. 如果选择中易字库,指定fontset = windows即可;
  2. 如果选择方正字体,指定chinesefont = founder即可。

最终解决方案

方法

  1. 方正字体官网下载方正宋体方正中宋方正仿宋方正楷体四款字体,并安装。
  2. 在论文模板tex文件中指定chinesefont=founder选项。

效果

将输出PDF中的字体更换为方正字体系列,实现了预想中的效果。

最终效果

-------------本文结束感谢您的阅读-------------
请作者喝杯奶茶~