How can I modify the font of the chapter* command. I essentially want to keep it the same except to make the font a little smaller. How could I do this using titlesec. Also how can I redefine the chapter* command so that I can add these sections to the table of contents.
1 Answer
You can use the numberless
feature of titlesec
, but you must also define a format for the numbered chapters.
\documentclass{book}
\usepackage{titlesec}
% the following emulates the standard
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}
{\chaptertitlename\ \thechapter}
{20pt}
{\Huge}
% format for numberless chapters
\titleformat{name=\chapter,numberless}[display]
{\large\sffamily}
{}% this argument isn't used
{0pt}% unused
{\managechapter}
\makeatletter
\newcommand{\managechapter}[1]{%
#1% print the title
\if@mainmatter
\addcontentsline{toc}{chapter}{#1}% send to the toc
\@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}% like book does usually
\fi
}
\makeatother
\begin{document}
\frontmatter
\tableofcontents
\listoffigures
\mainmatter
\chapter*{Introduction}
\chapter{Normal chapter}
\end{document}
In the numberless format I used a very distinctive font choice, just to show the result. Notice that this also changes the format for the table of contents and the other lists.
The \if@mainmatter
condition is necessary, as you don't want that the table of contents ends up listed in itself.
If you want the list of figures and similar chapters to go in the toc, add
\usepackage[nottoc]{tocbibind}
-
Really appreciate this. From what I understand the manage chapter is adding the chapter to the toc, is there any way to turn this into a optional thing where I can pass an argument in to make it appear in the TOC or not?– xyz04Commented Jun 6 at 5:31
-
@xyz04 Can you be more specific about how you would decide when an unnumbered chapter should go in the tocor not?– egregCommented Jun 6 at 7:41
-
I mean my idea was that it would be nice to have some control over if I want an unnumbered chapter to be included in the toc when working in the main matter. I don't know if realistically this is possible but it would be nice to have this functionality.– xyz04Commented Jun 6 at 20:36
titlesec
, so please show what you've tried thus-far\chapter
and\chapter*
?