編集

編集

下の図に示すように、セクション タイトルの後に右余白まで伸びる水平線を作成するにはどうすればよいでしょうか。

ここに画像の説明を入力してください

答え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}

5歳の子を見つけたバーナードの答え少しだけアレンジしました:

\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} 

水平線

関連情報