3

What I'm trying to do is pretty basic it seems, but it's also above my pay grade: change the font and the color used for the TOC title Contents and the LOT title List of Tables (see attached screen caps).

I'd like the Candara font I use for my chapters, and the color I've picked for them, to be used for both "Table of Contents" and "List of Tables"

% PREAMBLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[oneside,centered,twocolumn]{book}
%\documentclass[a4paper,oneside,centered,twocolumn]{book}
\special{papersize=215.9mm,279.4mm}
%\usepackage[top=3cm, bottom=3.2cm, left=2.5cm, right=2.5cm]{geometry}

\usepackage[english]{babel}
\usepackage{tocloft} % Customization of TOC LOF LOT
\usepackage[table,xcdraw]{xcolor} % For shading in tables
\usepackage{pdfcolmk}
\usepackage{multirow}

%\usepackage{lscape} %to put the long table of dwellings sideways
%\usepackage{wallpaper}
\usepackage{blindtext}
%\usepackage{showframe}

\usepackage{textcomp}
\usepackage{pdfpages}
\usepackage{ltablex}
\usepackage{nicefrac} % to write fractions
\usepackage{attrib} % For source of quotations
\usepackage{lettrine} % For NewThought formatting
\usepackage{array} % To define width of columns in long table
\usepackage{booktabs} % Nicer spacing in columns
\usepackage{siunitx} % To write Celsius, etc.
\usepackage{enumitem} % To create item lists
\usepackage{caption} % To change way captions are labelled
\usepackage{scrextend}
\usepackage{threeparttable} % For table notes + To allow footnote material to stay with the tabular environment
\usepackage{etoolbox} % To make table footnote font smaller
\usepackage{threeparttablex}
\appto\TPTnoteSettings{\footnotesize}
\usepackage{textcomp} % For Numero symbol
\usepackage[T1]{fontenc}
\usepackage{titlesec,color}
\usepackage{xcolor}
\usepackage[linguistics,edges]{forest}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{titling}
\usepackage{fontspec}
\usepackage{newpxtext} % Font for document instead of obsolete Palatino
\usepackage{fancyhdr}
\usepackage{etoolbox}

% To make TOC in two columns and List of Tables into one column.
\usepackage{multitoc}
\makeatletter
\renewcommand*{\@starttoc}[1]{%
            \ifthenelse{\equal{#1}{toc}}{%
            \ifnum\multicolumntoc>1
            \begin{multicols}{\multicolumntoc}%
                \@multitoc@starttoc{#1}%
            \end{multicols}%
            \else
            \@multitoc@starttoc{#1}%
            \fi}{}%
        \ifthenelse{\equal{#1}{lot}}{%
            \ifnum\multicolumnlot>1
            \begin{multicols}{\multicolumnlot}%
                \@multitoc@starttoc{#1}%
            \end{multicols}%
            \else
            \@multitoc@starttoc{#1}%
            \fi}{}%
        \ifthenelse{\equal{#1}{lof}}{%
            \ifnum\multicolumnlof>1
            \begin{multicols}{\multicolumnlof}%
                \@multitoc@starttoc{#1}%
            \end{multicols}%
            \else
            \@multitoc@starttoc{#1}%
            \fi}{}%
}
\makeatother
\renewcommand{\multicolumnlot}{1}


% CHAPTER, SECTION, SUBSECTION STYLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newfontfamily\headingfont[]{Candara}
\titleformat{\chapter}[display]
{\bfseries\color{blue}\filcenter\fontsize{35}{35}\headingfont} % Size of Chapter1&Chapter
{\huge\MakeUppercase\headingfont{\chaptertitlename} \thechapter}
{12pt}
{\tikz[remember picture,overlay]\node[inner sep=0pt] at ($(current page.north) +
        (0pt,-117pt)$) {\includegraphics[width=14cm]{chapterHead_10cm}};}
\titlespacing{\chapter}{0pt}{50mm}{42.5mm}
\titleformat*{\section}{\LARGE\color{orange}\headingfont}
\titleformat*{\subsection}{\Large\color{orange}\headingfont}
\titleformat*{\subsubsection}{\large\color{orange}\headingfont}
\renewcommand{\maketitlehooka}{\headingfont}

\begin{document}

% To inlcude background wallpaper/image
%\CenterWallPaper{1}{TKML_ESB_Page_Background_2}

%\layout    

% FRONTMATTER STARTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\frontmatter

\tableofcontents
\clearpage

\addcontentsline{toc}{section}{\listtablename}
\listoftables
\clearpage

\onecolumn
\thispagestyle{plain} % To not have "List of Tables appear" at the top of the "Preface" page
\section{Preface}
\blindtext
\clearpage

\thispagestyle{plain} % To not have "List of Tables appear" at the top of the "Preface" page
\section{Introduction}
\blindtext
\twocolumn

\clearpage

% MAINMATTER STARTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\mainmatter

\blindtext

\end{document}

Contents LOF

6
  • 1
    Something like \addto\captionsenglish{\renewcommand{\contentsname}{\textcolor{green}{Contents}}} I can't test, because no MWE.
    – Keks Dose
    Commented Apr 16, 2019 at 19:09
  • Thank you. I added a clause to switch "Contents" to the heading font I'm using and it does work ... but it also generates errors. This part \addto\captionsenglish is highlighted in red. Commented Apr 16, 2019 at 19:32
  • 1
    Please make your code snippet compilable!
    – Mensch
    Commented Apr 17, 2019 at 13:43
  • Sorry. I was away. The text is now compilable. Commented Apr 17, 2019 at 18:28
  • 1
    You should not try to use legacy 8-bit fonts together with fontspec, which selects modern fonts. It won’t work (although it could be made to if you really wanted). You should remove the packages fontenc, textcomp, intputenc and newpxtext, and add the command \setmainfont[Scale=1.0]{Candara}. If you want a font that looks like newpx, either replace Candara withTeX Gyre Pagella, or better yet, use the original both of them are cloned from: \setmainfont[Scale=1.0, Ligatures={Common, Rare, TeX}]{Palatino Linotype}.
    – Davislor
    Commented Apr 18, 2019 at 17:36

2 Answers 2

3
+150

There are several issues in your code:

  1. You are loading a lot of packages I guess you do not need. In the following MWE I reduced the loaded packages to be more minimal. If packages are commented please read the comment explaining why I did that.
  2. Because you are loading package fontspec I added command \setmainfont[Scale=1.0]{Candara} to use font Chandara for the document.
  3. Because you are already using package tocloft you can use the following lines to manipulate the used code and color in TOC and LOF:

    \renewcommand{\cfttoctitlefont}{\Huge\color{green}\headingfont} % tocloft
    \renewcommand{\cftloftitlefont}{\Huge\color{green}\headingfont} % tocloft
    \renewcommand{\cftchapfont}{\color{green}\headingfont} % tocloft
    \renewcommand{\cftsecfont}{\color{green}\headingfont} % tocloft
    \renewcommand{\cftsubsecfont}{\color{green}\headingfont} % tocloft
    \renewcommand{\cftchappagefont}{\color{green}\headingfont} % tocloft
    
  4. I use command \Blinddocument from package blindtext to generate dummy text for a complete document ...

With the following complete MWE (see important code changings marked with <======):

\documentclass[oneside,centered,twocolumn]{book}

\special{papersize=215.9mm,279.4mm}
\usepackage[english]{babel}

\usepackage[demo]{graphicx}

\usepackage{tocloft} % Customization of TOC LOF LOT <===================
\usepackage[table,xcdraw]{xcolor} % For shading in tables
%\usepackage{pdfcolmk} % <==== not needed with xelatex
\usepackage{multirow}

\usepackage{blindtext}
%\usepackage{showframe}

\usepackage{caption} % To change way captions are labelled
\usepackage{scrextend}

\usepackage{titlesec}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{titling}
\usepackage{fontspec}
\setmainfont[Scale=1.0]{Candara} % <====================================

\usepackage{fancyhdr}

% To make TOC in two columns and List of Tables into one column.
\usepackage{multitoc}
\makeatletter
\renewcommand*{\@starttoc}[1]{%
    \ifthenelse{\equal{#1}{toc}}{%
        \ifnum\multicolumntoc>1
        \begin{multicols}{\multicolumntoc}%
            \@multitoc@starttoc{#1}%
        \end{multicols}%
        \else
        \@multitoc@starttoc{#1}%
        \fi}{}%
    \ifthenelse{\equal{#1}{lot}}{%
        \ifnum\multicolumnlot>1
        \begin{multicols}{\multicolumnlot}%
            \@multitoc@starttoc{#1}%
        \end{multicols}%
        \else
        \@multitoc@starttoc{#1}%
        \fi}{}%
    \ifthenelse{\equal{#1}{lof}}{%
        \ifnum\multicolumnlof>1
        \begin{multicols}{\multicolumnlof}%
            \@multitoc@starttoc{#1}%
        \end{multicols}%
        \else
        \@multitoc@starttoc{#1}%
        \fi}{}%
}
\makeatother
\renewcommand{\multicolumnlot}{1}


% CHAPTER, SECTION, SUBSECTION STYLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newfontfamily\headingfont[]{Candara}
\titleformat{\chapter}[display]
{\bfseries\color{blue}\filcenter\fontsize{35}{35}\headingfont} % Size of Chapter1&Chapter
{\huge\MakeUppercase\headingfont{\chaptertitlename} \thechapter}
{12pt}
{\tikz[remember picture,overlay]\node[inner sep=0pt] at ($(current page.north) +
    (0pt,-117pt)$) {\includegraphics[width=14cm]{chapterHead_10cm}};}

\titlespacing{\chapter}{0pt}{50mm}{42.5mm}
\titleformat*{\section}{\LARGE\color{orange}\headingfont}
\titleformat*{\subsection}{\Large\color{orange}\headingfont}
\titleformat*{\subsubsection}{\large\color{orange}\headingfont}
\renewcommand{\maketitlehooka}{\headingfont}

\renewcommand{\cfttoctitlefont}{\Huge\color{green}\headingfont} % tocloft <=====
\renewcommand{\cftloftitlefont}{\Huge\color{green}\headingfont} % tocloft <=====
\renewcommand{\cftchapfont}{\color{green}\headingfont} % tocloft <==============
\renewcommand{\cftsecfont}{\color{green}\headingfont} % tocloft <===============
\renewcommand{\cftsubsecfont}{\color{green}\headingfont} % tocloft <============
\renewcommand{\cftchappagefont}{\color{green}\headingfont} % tocloft <==========


\begin{document}

\tableofcontents
\listoffigures
\Blinddocument % <======================================================
\end{document}

you get the following result:

toc

As you can see the font and the color of the heading of TOC is changed, also the color of chapters, sections and subsections in TOC. \cftchappagefont changed the the page number for the chapters in the TOC, you can use \cftsecpagefont simular for sections etc.

1
  • Thank you. This did it. I then had a conflict between my hyperlinks color and the color of the links in the TOC: both were the same when I wanted the two to be different. This simple trick fixed it: tex.stackexchange.com/questions/306613/… Commented Apr 19, 2019 at 9:57
3

enter image description here

Renew the commands \cfttoctitlefont, \cftfigfont, and \cftlottitlefont to any font style you want.

I removed the unnecessary codes for better readability.

\documentclass[oneside,centered,twocolumn]{book}

\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage{blindtext}
\usepackage{tocloft}
\usepackage[]{tocbibind} % use this package to automatically insert list of tables and list of figures into the TOC

\newfontfamily\headingfont[]{Candara}
\newcommand{\toctitlefont}{\Huge \color{orange} \headingfont \bfseries} % font of the titles of lists (e.g., List of Tables)

% Change font style for TOC, LOT, and LOF here
    \renewcommand{\cfttoctitlefont}{\toctitlefont}
    \renewcommand{\cftfigfont}{\tocsecpagefont} 
    \renewcommand{\cftlottitlefont}{\toctitlefont}




\begin{document}

% To inlcude background wallpaper/image
%\CenterWallPaper{1}{TKML_ESB_Page_Background_2}

%\layout    

% FRONTMATTER STARTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\frontmatter

\tableofcontents
\clearpage

%\addcontentsline{toc}{section}{\listtablename} use tocbibind package and remove this
\listoftables
\clearpage

\listoffigures
\clearpage


\onecolumn
\thispagestyle{plain} % To not have "List of Tables appear" at the top of the "Preface" page
\section{Preface}
\blindtext
\clearpage

\thispagestyle{plain} % To not have "List of Tables appear" at the top of the "Preface" page
\section{Introduction}
\blindtext
\twocolumn

\clearpage

% MAINMATTER STARTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\mainmatter

\blindtext

\end{document}

Off-topic: use tocbibind package for better handling of List of Tables, List of Figures, and Index. By default, it will automatically insert their location into the TOC. It also provides easy options like nottoc, notlot, notlof to determine whether tables of contents, list of tables, and list of figures will be inserted into the TOC

1
  • Thank you. I will look into the <tocbibind> package. Commented Apr 19, 2019 at 9:58

You must log in to answer this question.

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