我面临两个问题:第一个问题是索引未显示在目录中,第二个问题是参考书目(称为参考文献)以大写形式显示。我打算在下面写下整个代码,希望它有助于找到问题。
谢谢大家。
\documentclass[12pt, a4paper]{book}
\usepackage[nottoc]{tocbibind}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\ps@headings}{\MakeUppercase}{}{}{}
\patchcmd{\ps@headings}{\MakeUppercase}{}{}{}
\patchcmd{\ps@headings}{\MakeUppercase}{}{}{}
\patchcmd{\ps@headings}{\@chapapp\ \thechapter. \ }{\thechapter\ }{}{}
\patchcmd{\ps@headings}{\@chapapp\ \thechapter. \ }{\thechapter\ }{}{}
\patchcmd{\ps@headings}{\thesection. \ }{\thesection\ }{}{}
\patchcmd{\tableofcontents}{\MakeUppercase}{}{}{}
\patchcmd{\tableofcontents}{\MakeUppercase}{}{}{}
\patchcmd{\thebibliography}{\MakeUppercase}{}{}{}
\patchcmd{\thebibliography}{\MakeUppercase}{}{}{}
\patchcmd{\theindex}{\MakeUppercase}{}{}{}
\patchcmd{\theindex}{\MakeUppercase}{}{}{}
\patchcmd{\ps@headings}{\slshape}{}{}{}
\patchcmd{\ps@headings}{\slshape}{}{}{}
\patchcmd{\ps@headings}{\slshape}{}{}{}
\makeatother
\pagestyle{headings}
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\textwidth= 6.4in
\textheight= 8.0in
\topmargin = -18pt
\evensidemargin=0pt
\oddsidemargin=0pt
\headsep=20pt
\parskip=10pt
\usepackage{amssymb,latexsym}
\usepackage{amsmath}
\usepackage{relsize}
\usepackage{longtable}
\usepackage{cancel}
\usepackage{imakeidx}
\usepackage{booktabs}
\usepackage{array}
\makeindex
\usepackage[colorlinks=true,breaklinks]{hyperref}
\usepackage{xcolor}
\definecolor{c1}{rgb}{0,0,1}
\definecolor{c2}{rgb}{0,0.3,0.9}
\definecolor{c3}{rgb}{0.3,0,0.9}
\hypersetup{linkcolor={c1},citecolor={c2},urlcolor={c3}}
\begin{dosument}
\index{Apple}\index{Apricot}
\index{Banana}\index{Cherry}
\frontmatter
\tableofcontents
\chapter{Preface}
\chapter{Notations}
\mainmatter
\chapter{One}
\chapter{Two}
\renewcommand{\bibname}{References}
\begin{thebibliography}{}
\end{thebibliography}
\printindex
\end{document}
答案1
我不明白为什么目录中没有该索引的条目。也许其他人会提供单独的答案。
最近(即今年 10 月 1 日)LaTeX 内核进行了重大更新。其中一项新功能是改进了“钩子”管理;总的来说,这是一件非常好的事情。缺点是,至少目前,包中的命令并非都像etoolbox
以前一样有效。
假设你正在使用最新版本的 LaTeX,即比 更新的版本20200930
,你可能需要替换代码块
\patchcmd{\thebibliography}{\MakeUppercase}{}{}{}
\patchcmd{\thebibliography}{\MakeUppercase}{}{}{}
\patchcmd{\theindex}{\MakeUppercase}{}{}{}
\patchcmd{\theindex}{\MakeUppercase}{}{}{}
和
\AddToHook{env/thebibliography/after}{\@mkboth{\bibname}{\bibname}}
\AddToHook{env/theindex/after}{\@mkboth{\indexname}{\indexname}}
如果你不确定哪个版本安装 LaTeX 后,只需打开日志文件并搜索一行,从顶部开始大约 6 到 8 行,如下所示:
LaTeX2e <2020-10-01> patch level 1
这告诉您我的系统正在使用LaTeX2e <2020-10-01>
。
附录:这是我用来验证路径\AddToHook
是否有效的完整 MWE:
\documentclass[12pt, a4paper]{book}%[20190101]
\usepackage{etoolbox}
\makeatletter
\patchcmd{\ps@headings}{\MakeUppercase}{}{}{}
\patchcmd{\ps@headings}{\MakeUppercase}{}{}{}
\patchcmd{\ps@headings}{\MakeUppercase}{}{}{}
\patchcmd{\ps@headings}{\@chapapp\ \thechapter. \ }{\thechapter\ }{}{}
\patchcmd{\ps@headings}{\@chapapp\ \thechapter. \ }{\thechapter\ }{}{}
\patchcmd{\ps@headings}{\thesection. \ }{\thesection\ }{}{}
\patchcmd{\ps@headings}{\slshape}{}{}{}
\patchcmd{\ps@headings}{\slshape}{}{}{}
\patchcmd{\ps@headings}{\slshape}{}{}{}
\patchcmd{\tableofcontents}{\MakeUppercase}{}{}{}
\patchcmd{\tableofcontents}{\MakeUppercase}{}{}{}
%% The next two instructions require LaTeX2e 2020-10-01:
\AddToHook{env/thebibliography/after}{\@mkboth{\bibname}{\bibname}}
\AddToHook{env/theindex/after}{\@mkboth{\indexname}{\indexname}}
\makeatother
\pagestyle{headings}
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\textwidth= 6.4in
\textheight= 8.0in
\topmargin = -18pt
\evensidemargin=0pt
\oddsidemargin=0pt
\headsep=20pt
\parskip=10pt
\renewcommand{\bibname}{References}
\usepackage[nottoc]{tocbibind}
\usepackage{amssymb,amsmath,relsize,cancel}
\usepackage{array,longtable,booktabs}
\usepackage{imakeidx}
\makeindex
\usepackage{xcolor}
\usepackage[colorlinks=true,breaklinks]{hyperref}
\definecolor{c1}{rgb}{0,0,1}
\definecolor{c2}{rgb}{0,0.3,0.9}
\definecolor{c3}{rgb}{0.3,0,0.9}
\hypersetup{linkcolor={c1},citecolor={c2},urlcolor={c3}}
\begin{document}
\frontmatter
\index{Apple}\index{Apricot}
\index{Banana}\index{Cherry}
\tableofcontents
\chapter{Preface}
\chapter{Notations}
\mainmatter
\chapter{One}
\chapter{Two}
\backmatter
\begin{thebibliography}{9}
\bibitem{x} X
\end{thebibliography}
\printindex
\end{document}