![装饰部分标题](https://linux22.com/image/370792/%E8%A3%85%E9%A5%B0%E9%83%A8%E5%88%86%E6%A0%87%E9%A2%98.png)
我想在书中章节标题后面添加一条长约 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}