装饰部分标题

装饰部分标题

我想在书中章节标题后面添加一条长约 3 厘米的线段。如何修改以下代码?我添加了,\rule{3cm}{.45pt}但它提示超出容量。

\documentclass[oneside,11pt]{book}

\usepackage{siunitx}
\usepackage{fancybox} 
\usepackage{pgf,tikz}
\usepackage[textwidth=16.25cm,textheight=19cm]{geometry} %kho sach 18x23

\usepackage[mathscr]{eucal}
\usepackage{graphics, graphpap}

\begin{document}
\tableofcontents
\chapter{First Chapter}

\pagebreak
\section{Perimeter {\rule{3cm}{.45pt}} }

\begin{enumerate} 
\item first item
\item second item

\end{enumerate}
\end{document}

答案1

\@sect没有任何包:对等命令的底层宏进行快速而粗略的重新定义\section

重新定义检查是否subsection使用了部分或其他等等,然后应用\rule

\ruledistskip随意改变长度...

\documentclass[oneside,11pt]{book}

\usepackage{siunitx}
\usepackage{fancybox} 
\usepackage{pgf,tikz}
\usepackage[textwidth=16.25cm,textheight=19cm]{geometry} %kho sach 18x23

\usepackage[mathscr]{eucal}
\usepackage{graphics, graphpap}

\newlength\ruledistskip
\setlength{\ruledistskip}{5em}

\makeatletter
\let\l@tex@sect\@sect
\def\@sect#1#2#3#4#5#6[#7]#8{%
  \l@tex@sect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{#8\ifnum0=\pdfstrcmp{#1}{section}%
    \hskip\ruledistskip\rule{3cm}{.45pt}%
    \fi}%
}
\makeatother
\begin{document}


\tableofcontents
\chapter{First Chapter}

\clearpage
\section{Perimeter}

\subsection{Ruleless}

\begin{enumerate} 
\item first item
\item second item

\end{enumerate}
\end{document}

在此处输入图片描述

相关内容