Skip to content

解决overleaf编译的时候,一级标题加粗是宋体的问题 #15

@Ixiaohuihuihui

Description

@Ixiaohuihuihui

我用overleaf编译,选择的是:xelatex。会出现加粗的一级标题是宋体,而不加粗的是楷体的问题,如图所示:

Image

这是因为:

  • ​楷体默认无加粗版本:直接使用 \bfseries 会回退到默认宋体加粗。

  • ​命令顺序冲突:\bfseries 覆盖了楷体设置。

所以我修改了.sty文件中的两个地方:

(1) 在nsfc.sty文件的第六行以后添加楷体加粗,并且进行伪加粗,代码如下:

\usepackage{fontspec}
\setCJKfamilyfont{kaishu}[
  AutoFakeBold 
]{AR PL UKai CN} 
\renewcommand{\kaishu}{\CJKfamily{kaishu}}

(2)第二处修改,替换nsfc.sty的这段代码(27-32行附近),将一级标题改成楷体加粗;

\newcommand{\nsfClr}[1]{\textcolor[rgb]{0.0,0.44,0.753}{#1}}
\newcommand{\alert}[1]{\nsfClr{\emph{\kaishu #1}}}
\newcommand{\ContentDes}[1]{
   \setcounter{section}{0}
   {\large \kaishu\bfseries \alert{#1} }% %{\vspace*{12pt} \NsfcNote{#2} }%
}

(3)第三处修改(47-51行附近),二级标题楷体加粗:

\newcommand{\NsfcSection}[3]{{\large
  \setcounter{section}{#1}
  \setcounter{subsection}{0}
  \indent 
  \nsfClr{#1. }{%
    \alert{\kaishu\bfseries #2}% 楷体加粗
  }{%
    \alert{\kaishu #3}% 楷体普通
  }%
}}

现在我的效果是这样:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions