我正在尝试使用memoir
类模板编译我的论文。当我导入章节时,文件编译得很好,但是当我在后记部分 ( \bibliographystyle{chicago} \bibliography{bibliography}
) 中输入参考书目的代码时,文件中出现以下错误.bbl
,并且文件无法编译:
error: \begin{thebibliography} on input line 1 ended by \end{bibitemlist}. \end{thebibliography} error: \begin{document} ended by \end{thebibliography}. \end{thebibliography} error: Extra \endgroup. \end{thebibliography}
问题是,当我.bib
在文档类中对各个章节使用相同的文件和命令时,参考书目生成没有任何问题,但它不适用于我的论文回忆录类项目。我使用的是 TeXstudio,如果这很重要,我的 bib 文件是由 Mendeley 自动生成的。
任何帮助将不胜感激!
编辑:我尽力用尽可能少的代码重现错误。我希望这能让事情更清楚:
\documentclass[12pt,a4paper,openbib]{memoir}
\usepackage{datetime}
\frenchspacing
\OnehalfSpacing
\setsecnumdepth{subsection}
\maxsecnumdepth{subsubsection}
\usepackage{calc,soul}
\makeatletter
\newlength\dlf@normtxtw
\setlength\dlf@normtxtw{\textwidth}
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
\sbox\feline@chapter{%
\resizebox{!}{#1}{\fboxsep=1pt%
\colorbox{gray}{\color{white}\thechapter}%
}}%
\rotatebox{90}{%
\resizebox{%
\heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
{!}{\scshape\so\@chapapp}}\quad%
\raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
}
\newcommand\feline@chm[1][4cm]{%
\sbox\feline@chapter{\feline@chapter@marker[#1]}%
\makebox[0pt][c]{% aka \rlap
\makebox[1cm][r]{\usebox\feline@chapter}%
}}
\newcommand{\clearemptydoublepage}{\newpage{\thispagestyle{empty}\cleardoublepage}}
\makeindex
\usepackage{import}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{breqn}
\usepackage{slashed}
\usepackage{float}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{chicago}
\usepackage{physics}
\usepackage{tikz-feynman}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,positioning,shadows,shapes}
\usepackage{graphicx}
\usepackage{qtree}
\usepackage[linguistics]{forest}
\graphicspath{ {images/} }
\usepackage{booktabs}
\usepackage{array}
\usepackage[T1]{fontenc}
\widowpenalty=1000
\clubpenalty=1000
\begin{document}
\renewcommand{\contentsname}{Table of Contents}
\maxtocdepth{subsection}
\tableofcontents*
\clearemptydoublepage
\listoffigures
\clearemptydoublepage
\mainmatter
\pagenumbering{arabic}
\clearemptydoublepage
Lorem ipsum \nocite{vanFraassen1980}
\backmatter
\bibliographystyle{chicago}
\bibliography{test}
\clearemptydoublepage
\end{document}
答案1
该问题可以在以下 MWE 中重现
\documentclass[british]{memoir}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{chicago}
\begin{filecontents}{\jobname.bib}
@book{elk,
author = {Anne Elk},
title = {A Theory on Brontosauruses},
year = {1972},
publisher = {Monthy \& Co.},
location = {London},
}
\end{filecontents}
\begin{document}
Lorem \cite{elk,article-full}
\bibliographystyle{chicago}
\bibliography{\jobname,xampl}
\end{document}
类memoir
和chicago
包都会改变环境的定义thebibliography
。不幸的是,chicago
这样做的方式忽略了thebibliography
环境本身:它只改变了环境的开始代码,而不是结束代码。假设thebibliography
这通常的定义没什么大不了的,但随着memoir
额外的变化,事情就出错了。
我建议采用以下解决方法,即memoir
在加载后恢复的重新定义chicago
,但对参考书目格式进行必要的调整。
\documentclass[british]{memoir}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{chicago}
\makeatletter
\renewenvironment{thebibliography}[1]{%
\bibsection
\begin{bibitemlist}{#1}}{\end{bibitemlist}\postbibhook}
\renewenvironment{bibitemlist}[1]{%
\typeout{bibitemlist}
\list{\@biblabel{\@arabic\c@enumiv}}%
{\leftmargin\z@
\advance\leftmargin\bibindent
\itemindent -\bibindent
\listparindent \itemindent
\parsep \z@
\@openbib@code
\usecounter{enumiv}%
\let\p@enumiv\@empty
\renewcommand\theenumiv{\@arabic\c@enumiv}%
\biblistextra}%
\sloppy
\clubpenalty4000
\@clubpenalty \clubpenalty
\widowpenalty4000%
\sfcode`\.\@m}%
{\def\@noitemerr
{\@latex@warning{Empty `thebibliography' environment}}%
\endlist}
\makeatother
\begin{filecontents}{\jobname.bib}
@book{elk,
author = {Anne Elk},
title = {A Theory on Brontosauruses},
year = {1972},
publisher = {Monthy \& Co.},
location = {London},
}
\end{filecontents}
\begin{document}
Lorem \cite{elk,article-full}
\bibliographystyle{chicago}
\bibliography{\jobname,xampl}
\end{document}