Page LayoutSpecial Customization of LoF and LoT

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
di-mk1
Posts: 5
Joined: Fri Mar 25, 2011 11:23 pm

Special Customization of LoF and LoT

Post by di-mk1 »

Hello people,

I'm using memoir to write my PhD thesis. I want to make a special formatting in the LoF and LoT parts of my thesis. Specifically, I want above each group of figures or tables to print simply a "Chapter x", just for better visualization. I followed the guide here (somehow adapted) using etoolbox. The problem is that the code does not check the \ifbool command and a "Chapter x" is always printed for all chapters, although there are chapters that might not contain figures or tables. What I wanted was to conditionally print the "Chapter x" only for chapters that do contain figures or tables. Attached are some snapshots from the XeLaTeX compilation where you can see the error plus a MWE.

Code: Select all

\documentclass[12pt,a4paper,headsepline,twoside]{memoir}
\usepackage{etoolbox}
\usepackage{graphicx}

\providebool{newchap}

\newcommand{\mytitle}[1]{
    \chapter{#1}
    \global\setbool{newchap}{true}
		\ifbool{newchap}{\addtocontents{lof}{\textbf{Chapter \thechapter} \vspace{8pt}}}{\global\boolfalse{newchap}}
		\ifbool{newchap}{\addtocontents{lot}{\textbf{Chapter \thechapter} \vspace{8pt}}}{\global\boolfalse{newchap}}
}

\begin{document}
\newpage

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

%\pagestyle{contents}
\setcounter{page}{1}
\pagenumbering{roman}

\newpage
\tableofcontents

\newpage

\listoffigures

%
\newpage
\listoftables
\newpage
\pagenumbering{arabic}

\mytitle{Introduction}  \label{ch:1}
\begin{figure}[t]
\centering
\includegraphics[width=5.8in]{ch2_fig2}
\caption{Figure 1}
\label{ch1:fig2}
\end{figure}

\newpage
\mytitle{Mathematical Background} \label{ch:2}
\begin{figure}[t]
\centering
\includegraphics[width=5.8in]{ch2_fig2}
\caption{Figure 2}
\label{ch2:fig1}
\end{figure}

\newpage
\mytitle{Chapter 3} \label{ch:3}
\begin{table}[t]
\renewcommand{\arraystretch}{1.5}
\centering
\begin{tabular}{|l | c |c |c |c |}
\hline

1, 3, 4 & $5L$ & $5L$ & $2L$ & $2L$\\

\hline
\end{tabular}
\caption{Table 1}
\label{ch3:table1}
\end{table}

\newpage
\mytitle{Chapter 4} \label{ch:4}
\begin{table}[t]
\renewcommand{\arraystretch}{1.5}
\centering
\begin{tabular}{|l | c |c |c |c |}
\hline

First BC & $L^2+2L$ & $L^2+L$ & $L^2+3L$ & $L^2+2L$\\
Total & $2L^2+9L$ & $2L^2+8L$ & $2L^2+6L$ & $2L^2+5L$\\
\hline
\end{tabular}
\caption{Table 2}
\label{ch4:table1}
\end{table}

\def\thechapter{A}

\newpage
\end{document}
Attachments
lof.png
lof.png (30.66 KiB) Viewed 2801 times
lot.png
lot.png (29.12 KiB) Viewed 2801 times
Last edited by localghost on Wed Jul 17, 2013 10:59 am, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply