如何在章节编号和章节标题之间添加一条线

如何在章节编号和章节标题之间添加一条线

我想知道是否有办法在章节编号和章节标题之间添加一行。

就像我现在得到的是这样的:

http://imgur.com/SiGA2

我想要的是一条水平线,如下所示:

在此处输入图片描述

与页面边框颜色相同

我用来开始一个章节的代码是:

\chapter{\Large REFERENCES}
\vspace*{-35pt}
\begin{enumerate}
\item C. Scott Ananian and Greg Humphreys, \textit{Theseus: A Maze-Solving Robot}, Princeton University, New Jersey, May 1997
\item Chang Yeun Chung, \textit{Micromous: Maze Solving Robot}, Universiti Teknologi, Malaysia, May 2009
\item Bob Clough, \textit{Rooter - A MicroMouse Maze Solving Robot}
\item Tondra De, Drew Hall, \textit{The Inception of Chedda: A detailed design and analysis of Micromouse}, University of Nevada, Las Vegas, Fall 2004
\item Kelly Ridge, Sanjeev Giri, Peter Shaw, Jason Flynn, \textit{MightyMouse: An Autonomous Maze Solving Robot}
\item Michael Gims, Sonja Lenz, Dirk Becker, \textit{MICROMOUSE: Microprocessor Controlled Vehicle}, University of East London, May 19999
\item Faton Avdiu, Andy Zhou, Redwan Ahmed, Emmanuel Hereira, Allen Gutierrez, Mohammad M. Hossain, \textit{MICROMOUSE}, City College of New York, Spring 2008
\item Philips Semiconductor, \textit{LPC214x User Manual}, 25$^th$ August 2005, Volume 1, Revision 1
\item Brian Beckman, \textit{The Physics of Racing}
\item Andrew N. Sloss, Dominic Symes, Chris Wright, \textit{Arm System Developer's Guide: Designing and Optimizing System Software}, Published by: Elsevier Inc., 2004
\item \textit{The amazing micromice: see how they won}, users.ece.gatech.edu/\%7Ehamblen/papers/micromouse/mmrace.pdf
\item \textit{Software Suggestions}, http://micromouseinfo.com/introduction/software.html, 5$^th$ November 2004
\item
\end{enumerate}

\listoffigures另外,当我使用或 时,我会不断在章节名称周围看到这些框\tableofcontents

在此处输入图片描述

有办法去除它们吗?

答案1

要更改章节标题格式,您可以使用标题安全包裹:

\documentclass{book}
\usepackage{titlesec}
\usepackage{lipsum} 
\usepackage{xcolor} 

\titleformat{\chapter}[display]
  {\normalfont\bfseries\LARGE}
  {\chaptertitlename~\thechapter}{1pc}
  {{\color{brown}\titlerule[2pt]}\vspace{1pc}\MakeUppercase}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\bfseries\LARGE}{}{1pc}
  {\MakeUppercase}

\begin{document}
\tableofcontents

\chapter{Test Chapter}
\lipsum[2]

\end{document}

第二个\titleformat使用该numberless选项,因此它只对未编号的章节有效;由于您没有提供有关所用文档类别的信息,我所能做的就是猜测原始设置的近似值;根据您的需要更改值。

在此处输入图片描述

为了解决超链接周围的框的问题,请hyperref按以下方式加载包:

\usepackage[hidelinks]{hyperref}

答案2

\@makechapterhead下面通过修补标准命令(发出\chapter或时调用\chapter*)来复制 Gonzalo 的输出bookreport文档类别。在文档序言中包括以下内容:

\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\patchcmd{\@makechapterhead}% <cmd>
  {\vskip 20\p@}% <search>
  {\vskip13.25\p@{\color{brown}\hrule height 2\p@}\vskip13.25\p@}% <replace>
  {}{}% <success><failure>
\makeatother

以下是 MWE 中的章节标题:

在此处输入图片描述

\documentclass{book}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\begin{document}
\tableofcontents
\chapter{First chapter}\lipsum[1]

\makeatletter
\patchcmd{\@makechapterhead}% <cmd>
  {\vskip 20\p@}% <search>
  {\vskip13.25\p@{\color{brown}\hrule height 2\p@}\vskip13.25\p@}% <replace>
  {}{}% <success><failure>
\makeatother

\chapter{Second chapter}\lipsum[2]
\chapter*{Last chapter}\lipsum[3]
\end{document}

相关内容