如何使用固定宽度的右规则和行填充的左规则来获得以下结果?
答案1
只需从中获取定义article.cls
并添加规则:
\documentclass{article}
\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\xhrulefill \normalfont\Large\bfseries\zz{2cm}}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\xhrulefill\normalfont\large\bfseries\zz{1.5cm}}}
\newcommand\zz[2]{\mbox{ #2 \makebox[#1]{\xhrulefill}}}
\newcommand\xhrulefill{\noindent\leaders\vrule height5pt depth -4pt \hskip 0pt plus 1fill}
\makeatother
\begin{document}
\tableofcontents
\section{oops}
\subsection{ahhh}
hello
\section{hoops}
\subsection{hahhh}
goodbye
\end{document}