如何自定义目录、参考书目和索引的标题?

如何自定义目录、参考书目和索引的标题?

各位。我快写完我的书了,现在我还要解决最后一个问题:我需要自定义目录、简介(是一个 \chapter* 文件)、参考书目和索引的标题,以便它们看起来与其余章节一样。

这是关于我如何自定义章节标题(页眉)的 MWE,但它不适用于目录、参考书目、索引和标有星号的章节。

\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}

提供更多重要信息的几点说明:1. 如果我将简介设置为 \chapter 章节,它会按我需要的方式显示其标题,但当我将其设置为 \chapter* 章节时则不会显示。2. 如果我将简介设置为 \chapter 章节,但将其定位到 \frontmatter 部分(如果我使用前言、正文和后记部分),则标题不会按我需要的方式再次显示!3. 我猜问题出现的原因是 \titleformat 命令未针对目录、参考书目、索引和“*”节、部分等章节类型进行定义……

所以,我想到一种方法来将这些部分设置为像普通章节一样(如 \chapter),但我不知道这是否可行。如果不行,我该如何根据需要自定义这些标题部分?

此图像是我使用 MWE 中显示的代码所得到的样本(简历) 我需要但没有得到的标题样式

这是标题的灰色框架的图像: 标题的灰色框架

我需要获取目录、参考书目、简介和索引的标题,就像获取第 1 章和附录 A 的标题一样。我该怎么做?顺便问一下:为什么参考书目计数器设置为 1?

感谢您的帮助。

答案1

要使用带星号的命令的可能性,titlesec您可以使用以下命令(这不会修复目录标题,而只会修复使用 的标题\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}

这并不能解决大标题的问题,它只回答了如何自定义设置的标题的问题\chapter*

tocloft编辑:改变了导致 ToC、LoF 和 LoT 正确标题的行为。

相关内容