You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用titlesec时给LaTeX标题加粗引发字体变更的问题

LaTeX 加粗标题时字体样式变更问题解决方法

你遇到的问题是:给“Professional Experience”添加\textbf命令后,原本的小体大写(Small Caps)字体变成了常规粗体,这是因为\textbf会重置字体形状,覆盖了\titleformat中设置的\scshape(小体大写)样式。

解决方法

要同时保留小体大写和加粗效果,有两种可行方案:

方案1:修改全局标题格式

直接在\titleformat中添加\bfseries,让所有section标题默认使用加粗小体大写:

\documentclass[10pt]{article}
\usepackage[a4paper,bottom = 0.6in,left = 0.6in,right = 0.6in,top = 1cm]{geometry}
\usepackage{titlesec}
\usepackage[usenames, dvipsnames]{color}
\definecolor{myblue}{RGB}{70,70,200}

\newcommand{\xfilll}[2][1ex]{
\dimen0=#2\advance\dimen0 by #1
\leaders\hrule height \dimen0 depth -#1\hfill}
% 添加\bfseries,确保加粗+小体大写生效
\titleformat{\section}{\large\bfseries\scshape\raggedright}{}{0em}{}

\begin{document}
\section*{{\LARGE \color{myblue} Professional Experience}\xfilll[0pt]{0.5pt}}
\end{document}

方案2:在标题文本内嵌套命令

如果只想给单个标题设置,可在文本内同时使用\bfseries和\scshape,注意命令顺序:

\documentclass[10pt]{article}
\usepackage[a4paper,bottom = 0.6in,left = 0.6in,right = 0.6in,top = 1cm]{geometry}
\usepackage{titlesec}
\usepackage[usenames, dvipsnames]{color}
\definecolor{myblue}{RGB}{70,70,200}

\newcommand{\xfilll}[2][1ex]{
\dimen0=#2\advance\dimen0 by #1
\leaders\hrule height \dimen0 depth -#1\hfill}
\titleformat{\section}{\large\scshape\raggedright}{}{0em}{}

\begin{document}
\section*{{\LARGE \color{myblue} {\bfseries\scshape Professional Experience}}\xfilll[0pt]{0.5pt}}
\end{document}

原理说明

\textbf{文本}等价于{\bfseries 文本},但它会清除之前的字体形状设置;而\bfseries是字体属性开关,能和\scshape叠加生效,前提是你使用的字体支持加粗小体大写样式。如果尝试后仍无效果,建议更换为支持该样式的字体(如Latin Modern系列字体)。

内容的提问来源于stack exchange,提问作者Senthil Vikram Vodapalli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 03:15:45