书籍文档类中的参考书目作为章节(在 ToC、fancyhdr 中)

书籍文档类中的参考书目作为章节(在 ToC、fancyhdr 中)

我希望我的参考书目被视为具有类的章节book,但现在它被视为上一章的一部分(LE 标题属于上一章,并且它未加粗/目录中的间距不正确)。我在网上找到的所有修复方法都不起作用,也许是因为我有其他冲突的命令?这是一个最小的工作示例:

main.tex

\documentclass[12pt,letterpaper,openany]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{titling}
\usepackage{url}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}
\usepackage{caption}
\usepackage{sidecap}
\usepackage{fancyhdr}
\usepackage{setspace}
\usepackage{float}
\usepackage{indentfirst}
\setlength\parindent{0.5in}
\usepackage[nottoc]{tocbibind}
\usepackage[titletoc,toc,title,page]{appendix}
\usepackage{longtable, booktabs}
\usepackage{subfiles}
\usepackage{apacite}
\usepackage{etoolbox}
\usepackage{textgreek}
\makeatletter
\patchcmd{\nocite}{\ifx\@onlypreamble\document}{\iftrue}{}{}
\makeatother


\fancypagestyle{plain}{%
\fancyhf{}% clears all header and footer fields
\fancyhead[LE,RO]{\thepage}}
\setlength{\headheight}{14.5pt}

\begin{document}

\tableofcontents
\listoffigures
\listoftables


\chapter{Chapter1}
\subfile{Chapter1.tex}

\bibliographystyle{apacite}
\bibliography{main.bib}

\end{document}

Chapter1.tex

\documentclass[main.tex]{subfiles}

\begin{document}

Example \cite{CentralDogma}.

\end{document}

main.bib

@article{CentralDogma,
  doi = {10.1038/227561a0},
  year  = {1970},
  publisher = {Springer Nature},
  volume = {227},
  number = {5258},
  pages = {561--563},
  author = {Francis Crick},
  title = {Central Dogma of Molecular Biology},
  journal = {Nature}
}

答案1

使用以下选项加载 apacite 包nosectionbib

\documentclass[12pt,letterpaper,openany]{book}
\usepackage[nosectionbib]{apacite}% <- option nosectionbib
\begin{document}
\tableofcontents
\chapter{Chapter1}
\section{Section 1}
\cite{CentralDogma}
\bibliographystyle{apacite}
\bibliography{main}
\end{document}

或者把参考书目放在后面:

\documentclass[12pt,letterpaper,openany]{book}
\usepackage{apacite}
\begin{document}
\tableofcontents
\chapter{Chapter1}
\section{Section 1}
\cite{CentralDogma}
\backmatter% <- added
\bibliographystyle{apacite}
\bibliography{main}
\end{document}

结果:

在此处输入图片描述

答案2

我精简了您给出的代码,使其更加简洁:

\documentclass[12pt,letterpaper,openany]{book}

\usepackage[utf8]{inputenc}
\usepackage{url}
\usepackage[margin=1in]{geometry}

\usepackage{apacite}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\nocite}{\ifx\@onlypreamble\document}{\iftrue}{}{}
\makeatother


\begin{document}

\tableofcontents

\chapter{Chapter1}
\section{Section 1}

\cite{CentralDogma}

\bibliographystyle{apacite}
\bibliography{main} % bibliography file without extention .bib!

\end{document}

结果是:

生成的 pdf

在类中boob.cls 定义了环境。我们现在可以用代码重新定义它(参见第二行,我们\chapter*随意使用):

\renewenvironment{thebibliography}[1]
 {\chapter*{\bibname}% <============================================
  \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
  \list{\@biblabel{\@arabic\c@enumiv}}%
       {\settowidth\labelwidth{\@biblabel{#1}}%
        \leftmargin\labelwidth
        \advance\leftmargin\labelsep
        \@openbib@code
        \usecounter{enumiv}%
        \let\p@enumiv\@empty
        \renewcommand\theenumiv{\@arabic\c@enumiv}}%
  \sloppy
  \clubpenalty4000
  \@clubpenalty \clubpenalty
  \widowpenalty4000%
  \sfcode`\.\@m}
 {\def\@noitemerr
   {\@latex@warning{Empty `thebibliography' environment}}%
  \endlist} 

附完整代码

\documentclass[12pt,letterpaper,openany]{book}

\usepackage[utf8]{inputenc}
\usepackage{url}
\usepackage[margin=1in]{geometry}

\usepackage{apacite}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\nocite}{\ifx\@onlypreamble\document}{\iftrue}{}{}
\renewenvironment{thebibliography}[1]
     {\chapter*{\bibname}% <==============================================
      \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
\makeatother


\begin{document}

\tableofcontents

\chapter{Chapter1}
\section{Section 1}

\cite{CentralDogma}

\bibliographystyle{apacite}
\bibliography{main} % bibliography file without extention .bib! <===========

\end{document}

得到结果:

新 pdf

相关内容