0

I am trying to compile my thesis using a memoir class template. When I import the chapters the file compiles fine but when I type the code for the bibliography in the backmatter section (\bibliographystyle{chicago} \bibliography{bibliography}) I get the following errors in the .bbl file and the file doesn't compile:

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}

The problem is that when I use the same .bib file and commands in a document class for the individual chapters, the bibliography is generated without any issues, but it doesn't work on my thesis memoir class project. I'm using TeXstudio, and my bib file is autogenerated by Mendeley if this matters.

Any help would be greatly appreciated!

EDIT: I did my best to reproduce the error with as little code as possible. I hope this makes things clearer:


\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}

3
  • It would help a lot if you could show us a small example document that reproduces the error with as little code as possible. I just tried the small example document at gist.github.com/moewew/b052d91c742d370f2ae1975ce230c291 and things worked fine.
    – moewe
    Commented Feb 15, 2022 at 16:02
  • You are right but I am not sure how I can regenerate the problem with minimum code. The thing is that the problem only appears when I put in the \bibliography command. When I don't everything works perfectly.
    – Floyd
    Commented Feb 15, 2022 at 19:33
  • There must be some code in your document that makes the bibliography fail. Most likely it is code in your preamble. My example shows that there are preambles where chicago works, so you 'just' have to find the bit in your preamble that causes the error. There are many pages like tex.meta.stackexchange.com/q/228/35864 that explain how to best generate an example document.
    – moewe
    Commented Feb 15, 2022 at 19:46

1 Answer 1

2

The problem can be reproduced in the following 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}

Both the memoir class and the chicago package change the definition of the thebibliography environment. Unfortunately, chicago does that in a way that sort of ignores that thebibliography is an environment: It only changes the begin code, not the end code of the environment. Assuming the usual definition of thebibliography this is not a big deal, but with memoir's additional changes, things go wrong.

I suggest the following workaround that restores memoir's redefinition after loading chicago, but applies the required tweaks to the bibliography formatting.

\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}

Nicely formatted bibliography.

4
  • Thanks a lot. I 've implemented your code and the errors dissolved, but the problem now is that my bibliography appears only in one specific style -- which I'm not sure what it is it but it's not chicago -- and the style doesn't change no matter what \bibliography style I choose.
    – Floyd
    Commented Feb 16, 2022 at 9:13
  • @Floyd That is odd. Are you sure there are no other errors that block proper bibliography generation. You may have to pass the option oldfontcommands to memoir to get chicago to work properly.
    – moewe
    Commented Feb 17, 2022 at 6:25
  • I should add that I don't actually know if chicago can give you Chicago style as currently defined by the CMoS. If you need that you may have to look into biblatex-chicago or windycity.
    – moewe
    Commented Feb 17, 2022 at 6:34
  • It is odd indeed. oldfontcommands doesn't help either. But thanks for your help anyway -- much appreciated.
    – Floyd
    Commented Feb 17, 2022 at 7:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .