节标题旁边的水平线

节标题旁边的水平线

我找到了在节标题上方或下方添加线条的好方法。一条填满整个宽度的水平线。

是否可以添加这样一条线,延伸其余的宽度,精确放置旁边标题?也就是说,位于行高的中间(不是顶部或底部)?

答案1

类似的东西?在互联网上找到了这个凸起规则的构造:

\documentclass[a4paper]{article}
    \usepackage[explicit]{titlesec}
    % Raised Rule Command:
    % Arg 1 (Optional) - How high to raise the rule
    % Arg 2 - Thickness of the rule
    \newcommand{\raisedrulefill}[2][0ex]{\leaders\hbox{\rule[#1]{1pt}{#2}}\hfill}
    \titleformat{\section}{\Large\bfseries}{\thesection. }{0em}{#1\,\raisedrulefill[0.4ex]{2pt}}
\pagestyle{plain}

\begin{document}

  \section{A short title}
  This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.

  \section{Another purposely very long title that extends on more than one line}
  This is another paragraph.This is another paragraph.This is another paragraph.This is another paragraph.This is another paragraph.This is another paragraph.This is another paragraph.This is another paragraph.

\end{document} 

在此处输入图片描述

相关内容