quotchap
我正在写硕士论文,并在章节标题中使用包。但是我希望参考书目标题左对齐,而不是像其他标题那样右对齐。
我试过了\renewcommand{\bibname}{\leftline{References}}
。但是,它改变了目录和参考书目页眉的对齐方式。
以下是 MWE:
\documentclass{book}
\usepackage{filecontents}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\begin{filecontents}{\jobname.bib}
@book{Knu86,
author = {Knuth, Donald E.},
year = {1986},
title = {The \TeX book},
}
\end{filecontents}
\RequirePackage[times]{quotchap}
\definecolor{chaptergrey}{gray}{0.75}
\begin{document}
\tableofcontents
\chapter{My chapter}
This is a reference \cite{Knu86}
\bibliographystyle{alpha}
\renewcommand{\bibname}{\leftline{Bibliography}} %this lines aligns left and shows how I want that bibliography title loks, but it changes the alignment in toc and in header of page 6. Comment to see how toc and the header of page 6 must look.
\bibliography{\jobname}
\newpage\clearpage\mbox{}\clearpage
\end{document}
答案1
这与quotchap
。相反,这是关于扩展宏进入它们不属于的目录。具体来说\leftline
...
话虽如此,在这种情况下,让它们迁移到 ToC 中会更容易,但在调用时让它们什么也不做\tableofcontents
。以下是一个例子:
\documentclass{book}
\usepackage[nottoc]{tocbibind}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Knu86,
author = {Knuth, Donald E.},
year = {1986},
title = {The \TeX book},
}
\end{filecontents}
\begin{document}
\begingroup
\renewcommand{\leftline}{}
\tableofcontents
\endgroup
\chapter{My chapter}
This is a reference \cite{Knu86}.
\bibliographystyle{alpha}
\renewcommand{\bibname}{\protect\leftline{Bibliography}}
\bibliography{\jobname}
\end{document}
请注意,如何\tableofcontents
将其包裹在\begingroup
...中,\endgroup
其中\leftline
重新定义为不执行任何操作。此外,我已经在您的重新定义中\protect
进行了编辑,否则在写入时会展开\leftline
\bibname
.toc
。