目录设置这里说section是黑体,但出来是宋体

发布于 2021-05-22 23:18:22
关注者
0
被浏览
2.5k
3 个回答
如果您有什么不同意见,您是对的,我是错的。
这家伙很懒,什么也没写!

不给 MWE 你就别用这个模板了

\documentclass{ctexart}
\usepackage{tocloft}
\renewcommand{\cftsecfont}{\heiti}
\begin{document}
  \tableofcontents
  \section{测试}
\end{document}
I am myself
I am myself 2021-05-22
这家伙很懒,什么也没写!

c212b03c715ad7fc2e513a7389df408e.png

MWE :

\documentclass[UTF8,a4paper]{ctexart}
%---------------------------------------------------------------------------
  % 设置字体
  %\usepackage[fontset=windows]{ctex}
  \usepackage{fontspec} %引入字体Times New Roman字体
  %\setmainfont{Times New Roman}             %设置正文字体为Times New Roman
  \usepackage{xeCJK} %调用系统中已安装的字体
  \setCJKmainfont{SimSun}
  \setmainfont{Times New Roman}
  %% 支持汉字加粗
  \let\heiti\relax % 黑体
  \newCJKfontfamily\heiti{SimHei}[AutoFakeBold]
  \setCJKsansfont{SimHei}[AutoFakeBold]

  \let\songti\relax % 宋体
  \newCJKfontfamily\songti{SimSun}[AutoFakeBold]
  \setCJKmainfont{SimSun}[AutoFakeBold]

  %% 目录格式设置
  \usepackage{tocloft}      %必须这么写,否则会报错
  \renewcommand{\contentsname}{\centerline{\Large{\heiti{目\quad\quad 录}}}}
  %\renewcommand{\cftchapleader}{\cftdotfill{0.6}} %设置chapter条目的引导点间距
  \renewcommand{\cftsecleader}{\cftdotfill{0.6}}
  \renewcommand{\cftsubsecleader}{\cftdotfill{0.6}}
  \renewcommand{\cftsubsubsecleader}{\cftdotfill{0.6}}
  %\renewcommand{\cftchapfont}{\hts}    %设置chapter条目的字体
  \renewcommand{\cftsecfont}{\heiti}    %设置section条目的字体
  %\renewcommand{\cftsecfont}{\hts}    %设置section条目的字体
  \renewcommand{\cftsecfont}{\large}    %设置section条目的四号
  \renewcommand{\cftsubsecfont}{\songti} %设置subsection条目的字体
  \renewcommand{\cftsubsecfont}{\large} %设置subsection条目的字体
  \renewcommand{\cftsubsubsecfont}{\songti} %设置subsection条目的字体
  \renewcommand{\cftsubsubsecfont}{\large} %设置subsection条目的字体

   %---------------------------------------------------------------------------
  %%%%定制标题样式
  %%%%% section
  \CTEXsetup[name={第,章 },format={\centering\heiti\zihao{-2}},aftername={\enspace},   beforeskip={24bp},afterskip={18bp}]{section} %name选项中不要使用中文逗号 \zihao(-    2)字号小二
  %%%%% subsection
  \CTEXsetup[format={\raggedright\songti\zihao{-3}},aftername={\enspace},              beforeskip={24bp},afterskip={6bp}]{subsection}
  %%%%% subsubsection
  \CTEXsetup[format={\raggedright\songti\zihao{4}},aftername={\enspace},               beforeskip={12bp},afterskip={6bp}]{subsubsection}

 \begin{document}\zihao{-4}
 \newpage
  \tableofcontents
  \thispagestyle{empty}
  \section{测试section}
 \subsection{测试subsection}

 \end{document}

运行之后,目录中的section与subsection并没有区别

行者
行者 2021-05-25
这家伙很懒,什么也没写!

你的代码里,设置了2次 section 和 subsection 条目的字体,第2次的把第1次的覆盖了。

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览