为小节标题添加下划线

为小节标题添加下划线

你好,我在论文中使用乳胶,我需要做一些改变以符合学校的规定。

我目前使用以下命令\subsection

\makeatletter
\renewcommand\subsection{\@startsection{subsection}{1}{\z@}%
                                  {-3.5ex \@plus -1ex \@minus -.2ex}%
                                  {2.3ex \@plus.2ex}%
                                  {\normalfont\large\bfseries}}
\makeatother

这让我

4.2.3 系统尺度上的准平衡

但我只需要在“系统尺度上的准平衡”下划线,而不是子节编号。我搜索过,但找不到能满足我要求的解决方案,任何帮助都将不胜感激。

答案1

这会修补\@sect命令并使用条件检查的第一个参数是否为\@sectsubsection\ulsoul包中应用然后执行格式化。我article为此假设了标准类——但它不适用于scrartcl等。

\documentclass{article}

\usepackage{soul}

\usepackage{xpatch}
\makeatletter
\xpatchcmd{\@sect}{%
  #8%
}{%
  \ifstrequal{#1}{subsection}{%
    \ul{#8}%
  }{%
    #8%
  }%
}{\typeout{successful patching}}{\typeout{Nope}}
\makeatother

\begin{document}
\tableofcontents
\section{First}
\subsection{Underlined with a very very very very very very very veryvery very very veryvery very very very long}
\subsubsection{Not underlined with a very very very very very very very veryvery very very veryvery very very very long}

\end{document}

在此处输入图片描述

相关内容