![将索引页的标题居中,而不影响目录](https://linux22.com/image/343199/%E5%B0%86%E7%B4%A2%E5%BC%95%E9%A1%B5%E7%9A%84%E6%A0%87%E9%A2%98%E5%B1%85%E4%B8%AD%EF%BC%8C%E8%80%8C%E4%B8%8D%E5%BD%B1%E5%93%8D%E7%9B%AE%E5%BD%95.png)
我有以下文档。我想将索引页的标题居中。问题是,在目录中,这个标题居中了,这是不理想的(见下图)。有办法解决这个问题吗?
\documentclass[10pt]{book}
\usepackage{makeidx}
\makeindex
\renewcommand*{\indexname}{\makebox[1.0\linewidth]{my index name}}
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{First section}
\index{hello}
\chapter*{\makebox[1.0\linewidth]{List of notations}}
\addcontentsline{toc}{chapter}{List of notations}
\cleardoublepage
\addcontentsline{toc}{chapter}{\indexname}
\printindex
\end{document}
答案1
\indexname
仅用于保存索引标题,而不包含任何格式。将 定义为您的特殊索引标题,并使用包单独\indexname
修改标题的格式。切换到居中章节标题;您可以通过 切换回来。\chapter
sectsty
\chapterfont{\centering}
\chapterfont{\raggedright}
\documentclass[10pt]{book}
\usepackage{makeidx}
\makeindex
\renewcommand*{\indexname}{my index name}
\usepackage{sectsty}
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{First section}
\index{hello}
\chapterfont{\centering}%
\chapter*{List of notations}
\addcontentsline{toc}{chapter}{List of notations}
\cleardoublepage
\addcontentsline{toc}{chapter}{\indexname}
\printindex
\end{document}