Page LayoutHow to add chapter headings to LOT / LOF

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
greybadger
Posts: 13
Joined: Fri Aug 21, 2009 2:36 pm

How to add chapter headings to LOT / LOF

Post by greybadger »

Hi,

I'd like my LoT and LoF layout to be similar to the ToC, such that I get a boldfaced line, with the chapter number and title (I'd rather not have the page number there) displayed before the relevant entries.

Is this possible? I'm already using the toclof package to fix some layout issues, but I can't see anything in the documentation to do that...

Cheers!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

How to add chapter headings to LOT / LOF

Post by Stefan Kottwitz »

Hi,

perhaps post a minimal working example showing how you are generating the toc now, using tocloft etc.

Stefan
LaTeX.org admin
greybadger
Posts: 13
Joined: Fri Aug 21, 2009 2:36 pm

How to add chapter headings to LOT / LOF

Post by greybadger »

Sure, apologies. The following is a cut-down version of my document with all relevant formatting.

Code: Select all

\documentclass[a4paper,11pt,twoside,openright]{report}
\usepackage{fancyhdr}
\usepackage[a4paper,top=3.1cm,bottom=2.5cm,inner=4.0cm,outer=2cm]{geometry}
\usepackage{titlesec}
\usepackage[font=small,labelfont=bf]{caption}

% Set TOC / LOT / LOF number spacing
\usepackage{tocloft}
\setlength{\cftsecnumwidth}{2.5em}
\setlength{\cftsubsecnumwidth}{2.8em}
\setlength{\cftfignumwidth}{2.6em}
\setlength{\cfttabnumwidth}{2.6em}

% Set chapter title format
\titleformat{\chapter}{\bf\huge}{\thechapter .}{1em}{}

% Set page header / footer style
\pagestyle{fancy} 
\headheight 13.59999pt
\renewcommand{\chaptermark}[1]{\markboth{#1}{}} 
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} 
\fancyhf{} 
\fancyhead[LO]{\bfseries\rightmark} 
\fancyhead[RE]{\bfseries\leftmark} 
\fancyfoot[C]{\thepage}
\fancypagestyle{plain}{
\fancyhead{} 
\renewcommand{\headrulewidth}{0pt}
} 

\begin{document}

\tableofcontents
\cleardoublepage
\listoffigures
\cleardoublepage
\listoftables
\cleardoublepage

\chapter{A chapter}
\section{First section}
\subsection{The figure}
This is a chapter with one figure and a table.
\begin{figure}[htbp]
   FIGURE HERE
  \caption{First figure}
\end{figure}
\begin{table}[htbp]
   TABLE HERE
  \caption{First table}
\end{table}

\chapter{Another chapter}
\section{First section}
\subsection{The table}
This is a chapter with one table and a figure.
\begin{table}[htbp]
   TABLE HERE
  \caption{First table}
\end{table}
\begin{figure}[htbp]
   FIGURE HERE
  \caption{First figure}
\end{figure}

\end{document}
I just use the tocloft package to change the number spacing as I have double-digit count figures, so the numbering was running into the captions.

So what I'd like is for the LoT / LoF to follow the same format as the ToC. Looking at it, it would be best if the chapter headings did have page numbers in the LoT / LoF too.

Thanks in advance.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to add chapter headings to LOT / LOF

Post by gmedina »

Hi,

use some \addcontentsline commands; in your example:

Code: Select all

...
\chapter{A chapter}
\addcontentsline{lof}{chapter}{A chapter}
\addcontentsline{lot}{chapter}{A chapter}
(chapter contents)
...
\chapter{Another chapter}
\addcontentsline{lof}{chapter}{Another chapter}
\addcontentsline{lot}{chapter}{Another chapter}
(chapter contents)
....
1,1,2,3,5,8,13,21,34,55,89,144,233,...
greybadger
Posts: 13
Joined: Fri Aug 21, 2009 2:36 pm

Re: How to add chapter headings to LOT / LOF

Post by greybadger »

Hi, thanks for the suggestion. This is nearly there... It's now just lacking the chapter number before the chapter title in the LoT / LoF entries. Is there any way to force those to be displayed like the would in the ToC?

Thanks.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to add chapter headings to LOT / LOF

Post by gmedina »

Add this to the preamble of your document:

Code: Select all

\newcommand\addloflot[1]{%
  \addcontentsline{lof}{chapter}{\protect\makebox[1.4em][l]{\thechapter}#1}
  \addcontentsline{lot}{chapter}{\protect\makebox[1.4em][l]{\thechapter}#1}}
And use the new command in the following way:

Code: Select all

...
\chapter{A chapter}
\addloflot{A chapter}
(chapter contents)
...
\chapter{Another chapter}
\addloflot{Another chapter}
(chapter contents)
...
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply