![有没有更简单的解决方案可以在目录、图表列表、表格列表、缩写列表的上方和下方添加水平线?](https://linux22.com/image/472953/%E6%9C%89%E6%B2%A1%E6%9C%89%E6%9B%B4%E7%AE%80%E5%8D%95%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%8F%AF%E4%BB%A5%E5%9C%A8%E7%9B%AE%E5%BD%95%E3%80%81%E5%9B%BE%E8%A1%A8%E5%88%97%E8%A1%A8%E3%80%81%E8%A1%A8%E6%A0%BC%E5%88%97%E8%A1%A8%E3%80%81%E7%BC%A9%E5%86%99%E5%88%97%E8%A1%A8%E7%9A%84%E4%B8%8A%E6%96%B9%E5%92%8C%E4%B8%8B%E6%96%B9%E6%B7%BB%E5%8A%A0%E6%B0%B4%E5%B9%B3%E7%BA%BF%EF%BC%9F.png)
我已经改进了相同的迭代但失败了:
\documentclass[a4paper,12pt]{report}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{blindtext}
\begin{document}
% For Content
{\rule[0.1cm]{\textwidth}{2.5pt}}
\tableofcontents
{\rule[0.1cm]{\textwidth}{2.5pt}}
\clearpage
% For Figures
{\rule[0.1cm]{\textwidth}{2.5pt}}
\listoffigures
{\rule[0.1cm]{\textwidth}{2.5pt}}
\clearpage
% For Tables
{\rule[0.1cm]{\textwidth}{2.5pt}}
\listoftables
{\rule[0.1cm]{\textwidth}{2.5pt}}
\clearpage
\chapter{This is chapter-1}
\section{Having two sections, this is first one}
\blindtext[1]
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{example-image-a}
\caption{This is a MWE figure}
\label{fig:dum}
\end{figure}
\blindtext[1]
\section{And this one is second}
\blindtext[1]
\begin{table}[h]
\caption{This is a MWE table}
\centering
\begin{tabular}{ccccc}
\toprule
V1 & V2 & V3 & V4 & V5 \\
\midrule
0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
0.00 & 0.00 & 0.00 & 0.00 & 0.00 \\
\bottomrule
\end{tabular}
\label{tab:1}
\end{table}
\blindtext[1]
\end{document}
问题在于这些命令在标题行之前和内容、图形、表格等上下文之后创建行。
我需要这些线正好位于中心位置,并且正好位于标题内容的上方和下方,而不是位于内容之后。
我曾经探索过类似的问题,但未能找到简化的解决方案。
还用MWE更新了这个问题。希望它能帮助你更好地理解这个问题。
答案1
如果你想坚持使用包fncychap
。根据手动的
,您可以更新命令\DOTIS
以保留默认格式和空间设置,并且仅为参数#1添加顶部规则和底部规则。
注意规则宽度已定义使用
\RW
哪个将根据命令进行更改\ChRuleWidth{<some length>}
。这样,规则宽度将在普通章节和 toc,lot,lof 之间保持一致。如果您不想这样,请使用\RW
某个长度值更改命令。例如:
\renewcommand{\DOTIS}[1]{%
\raggedright \CTV \FmTi {\rule{\textwidth}{2pt}\par#1\par\rule[12pt]{\textwidth}{2pt}}\par \nobreak \vskip 40\p@
}
这是一个完整工作的示例:
\documentclass[a4paper,12pt]{report}
\usepackage{booktabs}
\usepackage[Lenny]{fncychap}
\ChRuleWidth{2.5pt}
\makeatletter
\renewcommand{\DOTIS}[1]{%
\raggedright \CTV \FmTi {\rule{\textwidth}{\RW}\par#1\par\rule[12pt]{\textwidth}{\RW}}\par \nobreak \vskip 40\p@
}
\makeatother
\usepackage{duckuments}
\begin{document}
\duckument[toc]
\end{document}