Latex 错误:\begin{thebibliography} 在输入第 1 行以 \end{bibitemlist} 结束。\end{thebibliography}

Latex 错误:\begin{thebibliography} 在输入第 1 行以 \end{bibitemlist} 结束。\end{thebibliography}

我正在尝试使用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}

memoirchicago包都会改变环境的定义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}

格式良好的参考书目。

相关内容