![索引未显示在目录中,参考书目以大写形式显示](https://linux22.com/image/422252/%E7%B4%A2%E5%BC%95%E6%9C%AA%E6%98%BE%E7%A4%BA%E5%9C%A8%E7%9B%AE%E5%BD%95%E4%B8%AD%EF%BC%8C%E5%8F%82%E8%80%83%E4%B9%A6%E7%9B%AE%E4%BB%A5%E5%A4%A7%E5%86%99%E5%BD%A2%E5%BC%8F%E6%98%BE%E7%A4%BA.png)
我面临两个问题:第一个问题是索引未显示在目录中,第二个问题是参考书目(称为参考文献)以大写形式显示。我打算在下面写下整个代码,希望它有助于找到问题。
谢谢大家。
\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}