7

I was wondering if there was a way to add a line between chapter number and chapter title.

As in, what I am getting now is this:

http://imgur.com/SiGA2

What I want is a horizontal line as shown:

enter image description here

of the same color as the page border

The code I use to start a chapter is:

\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}

Also I keep getting these boxes around the section and chapter names when I use \listoffigures or \tableofcontents.

enter image description here

Is there a way to remove those?

2
  • 1
    Those boxes seem to be hyperlinks... Am I right? If not, please provide a MWE illustrating the problem. Apr 18, 2012 at 21:22
  • Yes those are hyperlinks. But I still dont want the boxes to be around those names. Is it possible to remove them? Apr 18, 2012 at 21:28

2 Answers 2

10

To change the chapter heading format, you can use the titlesec package:

\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}

The second \titleformat uses the numberless option so it will only have effect for unnumbered chapters; since you didn't provide information on the document class used, all I can do is to guess approximate values for the original settings; change the values according to your needs.

enter image description here

To solve the issue with the boxes around the hyperlinks, load the hyperref package in the following way:

\usepackage[hidelinks]{hyperref}
3
  • It worked very nicely. I however have three problems: 1. It changed my table of contents formatting from imgur.com/QYjwX to imgur.com/NWayi which I dont want. 2. How do I change the color of that line? I want to make it brown. 3. I still have the problem of the boxes around section names in my table of contents. Apr 18, 2012 at 21:25
  • @KaranThakkar: see my updated answer. Apr 18, 2012 at 21:38
  • Thank you so much. Works totally like I need it. Thank you so much @GonzaloMedina . Apr 18, 2012 at 21:40
1

The following duplicates the output of Gonzalo by patching the standard \@makechapterhead command (called when issuing \chapter or \chapter*) inside the standard book and report document classes. Include the following in your document preamble:

\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

Here a look at the chapter headings in the following MWE:

enter image description here

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .