第一件事,你的源码在我这里无法直接通过编译。
无论选择founder还是ctexfont(默认)选项都会报缺少相关楷体的错误,当然这是误报。
如果使用nofont选项并自己设置正文字体,还是可以正常通过编译,并得到正确的楷体加粗效果的。
比如像这样子设置后:
\ifdefstring{\ELEGANT@chinesefont}{nofont}{
\RequirePackage[UTF8,scheme=plain,fontset=none]{ctex}
\xeCJKsetup{AutoFakeBold=true}\setCJKmainfont{FZKai-Z03}}{\relax}%在导言区设置\documengclass[cn,chinese,nofont]{elegantbook}会得到这样的效果:
第二件事,你应该对你自己修改的模板文件负责。要解决你的问题,请提供你具体更改了哪些代码的信息,否则你提供的模板源码,四舍五入就等于你自己的私有模板,如无必要,没人会愿意阅读。比如,请你关注一下你修改过后的模板文档第139行,此处使用了判断引擎的条件,而无论是否使用XeTeX引擎,宏包xeCJK都需要XeTeX引擎作为支持,如果不使用XeTeX引擎,ctex宏包底层的实现可能取决于其他策略。
补充一些信息...
需要注意到在elegantbook.cls中的definition环境的定义为:
% Line 1079
\ELEGANT@newtheorem{definition}{defstyle}% Line 902
\tcbset{
common/.style={
fontupper=\citshape,
lower separated=false,
% before upper={\setlength{\parindent}{\normalparindent}},
coltitle=white,
colback=gray!5,
boxrule=0.5pt,
fonttitle=\bfseries,
enhanced,
breakable,
top=8pt,
before skip=8pt,
attach boxed title to top left={
yshift=-0.11in,
xshift=0.15in},
boxed title style={
boxrule=0pt,
colframe=white,
arc=0pt,
outer arc=0pt},
separator sign={.},},
defstyle/.style={
common,
colframe=main,
colback=main!5,
colbacktitle=main,
overlay unbroken and last={
\node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) {
\textcolor{main}{$\clubsuit$}};}},
...其中fontupper=\citshape使用的定义为:
\ifcsname kaishu\endcsname
\newcommand{\citshape}{\kaishu}
\else
\newcommand{\citshape}{\itshape}
\fi所以要想在定义环境里加粗,需要保证「楷体」有粗体的字重,或者使用伪粗体...
fontset=windows,将默认使用「中易楷体」(a.k.a. simkai.ttf),没有粗体字重fontset=fandol,默认使用「fandol-kai」同样没有粗体字重fontset=ubuntu使用的是思源字库(win下需要自行安装),其对应使用的楷体为「gkai00mp.ttf」(似乎是文鼎楷体),同样没有粗体的字重fontset=founder),其楷体字形是有粗体的,因此表现正常P.S.一个 不推荐 的方式是使用「伪粗体」,如下在windows的例子:
\documentclass[lang=cn]{elegantbook}
\setCJKfamilyfont{zhkai}[AutoFakeBold]{simkai.ttf}
\renewcommand*{\kaishu}{\CJKfamily{zhkai}}
\begin{document}
\begin{definition}
你好,我想要在这里\textbf{加粗}哈哈哈
我在windows下用的是「中易楷体」,没有粗体
\end{definition}
\end{document}
其实也可以改一下让定义环境里不使用楷体,而是使用常见的宋体.作为示例:
\documentclass[lang=cn]{elegantbook}
\tcbset{common/.append style={fontupper=\normalfont}}
\begin{document}
\begin{definition}
你好,我想要在这里\textbf{加粗}哈哈哈
我现在在windows下用的是「中易宋体」,没有粗体,所以改用「中易黑体」做为粗体
\end{definition}
\end{document}
或者使用fandol-song
\documentclass[lang=cn,fontset=fandol]{elegantbook}
\tcbset{common/.append style={fontupper=\normalfont}}
\begin{document}
\begin{definition}
你好,我想要在这里\textbf{加粗}哈哈哈
我现在在windows下用的是「fandol宋体」,他有粗体
\end{definition}
\end{document}
核心原因还是因为elegant-latex对common这个style使用了楷体,但是有粗字重的楷体太少了...
谢谢!