編輯

編輯

如何建立一個部分標題,後面跟著一條延伸到右邊距的水平線,如下圖所示:

在此輸入影像描述

答案1

編輯

如果您不需要節號,您可以只使用\section*{First Section}或更改範例,如下所示(如果您需要目錄,這可能會很麻煩):

\documentclass[a4paper]{article}
\usepackage{xcolor, blindtext}
\usepackage[explicit]{titlesec}

\newcommand{\sectionrule}[2][0ex]{\leaders\hbox{{\color{cyan}\rule[#1]{1pt}{#2}}}\hfill}
\titleformat{\section}{\Large\bfseries}{}{0pt}{#1\,\sectionrule[0.5ex]{1.5pt}}

\begin{document}

  \section{First Section}
  \blindtext
  
  \section{Second Section}
  \blindtext

\end{document}

我找到了一個五歲的伯納德的回答我只是稍微修改了一下:

\documentclass[a4paper]{article}
\usepackage{xcolor, blindtext}
\usepackage[explicit]{titlesec}

\newcommand{\sectionrule}[2][0ex]{\leaders\hbox{{\color{cyan}\rule[#1]{1pt}{#2}}}\hfill}
\titleformat{\section}{\Large\bfseries}{\thesection}{1em}{#1\,\sectionrule[0.5ex]{1.5pt}}

\begin{document}

  \section{First Section}
  \blindtext
  
  \section{Second Section}
  \blindtext

\end{document} 

水平線

相關內容