-1

everybody. I'm finishing my book and I have to solve one las problem: I need to custom the titles of Table of Contents, Introduction (is a \chapter* file), Bibliography and Index in order that they look like the rest of the chapters.

This is a MWE of how I could custom the titles (headers) of the chapters but it doesn't work with the ToC, bibliography, index and chapters marked with asterisk.

\documentclass[reqno]{book}
\usepackage[spanish]{babel}
\usepackage{fontspec}
\usepackage[paperheight=254.81mm,paperwidth=184.81mm,text=
{130mm,186mm},centering]{geometry}
\usepackage[explicit]{titlesec}
\usepackage[svgnames]{xcolor}
\usepackage[titletoc]{appendix}
\usepackage{titletoc}
\usepackage{tocloft}

\newcommand*{\chapnumfont}{%
\fontsize{3.2cm}{5cm}%
\selectfont%
}
\newcommand*{\chaptitlefont}{%
\fontsize{22}{26}%
\selectfont%
}

\titleformat{\chapter}[block]
{\normalfont\huge\bfseries}
{\hspace{-2cm}\parbox{0ex}{\includegraphics[width=1.2\textwidth,height=2
\baselineskip]{RecuadroChap_Original.pdf}}} 
{0pt}
{\begin{minipage}{11cm}\hspace{2cm}\filleft\chaptitlefont #1\end{minipage}
\begin{minipage}{4cm} \filleft\chapnumfont\thechapter}[\end{minipage}]

\renewcommand{\cftchappresnum}{\bfseries Capítulo }
\renewcommand{\cftchapaftersnum}{}
\renewcommand{\cftchapaftersnumb}{\vskip0.5ex}
\renewcommand{\cftchapnumwidth}{0mm}

\begin{document}
\tableofcontents
\chapter*{Introducción}
\chapter{Álgebra de matrices}
\begin{appendices}
\chapter{Uso de los comandos en MATLAB y MuPAD}
\end{appendices}
\bibliography{Referencias}
\begin{thebibliography}{0}
\end{thebibliography}
\end{document}

A few notes for providing more and important information: 1. If I set the Introduction as a \chapter chapter, it shows its title like I need, but it doesn't when I set it as a \chapter* chapter. 2. If I set the Introduction as a \chapter chapter but I position it into the \frontmatter part (if I use front, main and back matter parts), the title is not shown like I need, again! 3. I guess that the problem rises because the \titleformat command is not defined for types of chapters like the ToC, bibliography, index and the "*" sections, parts,...

So, I was thinking of a way to set those parts like normal chapters (as \chapter) but I dont know if it is possible. If it's not, how could I custom those title parts like I need?

This image is a sample (resume) of what I get with the code shown in my MWE Title styles that I need and I don't get

And this is the image of the gray frame for titles: Gray frame for titles

I need to get the titles of the Toc, Bibliogrphy, Introduction and Index in the same way that I got the titles of Chapter 1 and the Appendix A. How can I do it? By the way: why the bibliography counter is set on 1?

Thanks for your help.

  • How do you manage the height of the title? The title of your second example overflows the graphic file. – Bernard Jul 31 '17 at 9:17
  • You should perhaps use TikZ or tcolorbox for those boxes in your titles. – Skillmon Jul 31 '17 at 10:25
  • If titlesec doesn't work out, the TOC is formatted by macros like \l@chapter{title}{page number}. – John Kormylo Jul 31 '17 at 13:51
  • 1
    According to your profile you have answers to some of your questions, but you accepted only one and did not cast any upvote yet -- this is not how TeX.SE works! – user31729 Aug 6 '17 at 15:48
1

To use the possibilities of titlesec for starred commands you can use the following (this does not fix the ToC heading, but only the ones using \chapter*):

\documentclass[reqno]{book}
\usepackage[spanish]{babel}
\usepackage{fontspec}
\usepackage[paperheight=254.81mm,paperwidth=184.81mm,text={130mm,186mm},centering]{geometry}
\usepackage[explicit]{titlesec}
\usepackage[svgnames]{xcolor}
\usepackage[titletoc]{appendix}
\usepackage{titletoc}
\usepackage[titles]{tocloft}% the titles option changes tocloft to use the standard latex commands for typesetting the titles
\usepackage{graphicx}

\newcommand*{\chapnumfont}{%
\fontsize{3.2cm}{5cm}%
\selectfont%
}
\newcommand*{\chaptitlefont}{%
\fontsize{22}{26}%
\selectfont%
}

\titleformat{\chapter}[block]
{\normalfont\huge\bfseries}
{\hspace{-2cm}\parbox{0ex}{\includegraphics[width=1.2\textwidth,height=2
\baselineskip]{example-image}}} 
{0pt}
{\begin{minipage}{11cm}\hspace{2cm}\filleft\chaptitlefont #1\end{minipage}
\begin{minipage}{4cm} \filleft\chapnumfont\thechapter}[\end{minipage}]

\titleformat{name=\chapter,numberless}[block] %this is for \chapter*
{\normalfont\huge\bfseries}
{\hspace{-2cm}\parbox{0ex}{\includegraphics[width=1.2\textwidth,height=2
\baselineskip]{example-image}}} 
{0pt}
{\begin{minipage}{11cm}\hspace{2cm}\filleft\chaptitlefont #1\end{minipage}
\begin{minipage}{4cm}}[\end{minipage}]

\renewcommand{\cftchappresnum}{\bfseries Capítulo }
\renewcommand{\cftchapaftersnum}{}
\renewcommand{\cftchapaftersnumb}{\vskip0.5ex}
\renewcommand{\cftchapnumwidth}{0mm}

\begin{document}
\tableofcontents
\chapter*{Introducción}
\chapter{Álgebra de matrices}
\begin{appendices}
\chapter{Uso de los comandos en MATLAB y MuPAD}
\end{appendices}
\bibliography{Referencias}
\begin{thebibliography}{0}
\end{thebibliography}
\end{document}

This doesn't fix the issue with large titles, it only answers the question, how to customize the titles set up with \chapter*.

EDIT: Changed the behaviour of tocloft resulting in correct headings for ToC, LoF and LoT.

  • Thnanks, Skillmon!!!! It worked perfectly!!!!! Now I have to custom the titles of the ToC, the bibliography and the index. Is it possible to cheat the \titleformat command in order to accept the \contentsname, \bibliography and the index? – Fabio Aug 1 '17 at 2:22
  • @Fabio on this site, we usually say thanks through hitting the upvote buttom. The issue of not accepting the \contentsname and stuff is not the fault of the \titleformat but the fault of the commands typesetting the headers of the corresponding sections (so in case of the ToC, tocloft is at fault). I'll look into it. – Skillmon Aug 1 '17 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.