1

The goal is to have an environment that takes a citation key and displays it in a section header, among other things. I've simplified the environment considerably for the sake of an MWE. The code is:

\documentclass[10pt]{article}

\usepackage[globalcitecopy,subsectionbib]{bibunits}
\usepackage[round]{natbib}
\usepackage[nottoc,numbib]{tocbibind}

\begin{filecontents*}{mwecitations.bib}
@book{goossens93,
    author = "Frank Mittelbach and Michel Goossens  and Johannes Braams and David Carlisle  and Chris Rowley",
    title = "The {LaTeX} Companion",
    year = "1993",
    publisher = "Addison-Wesley",
    address = "Reading, Massachusetts"
}
@article{fujita2010economic,
    title={Economic effects of the unemployment insurance benefit},
    author={Fujita, Shigeru},
    journal={FRB Phil. Business Review},
    volume={4},
    year={2010}
}
@article{rothstein2011unemployment,
    title={Unemployment insurance and job search in the {Great Recession}},
    author={Rothstein, Jesse},
    journal={NBER},
    volume={w17534},
    year={2011}
}
\end{filecontents*}

\newenvironment{thediscussion}[1]{\section*{\cite*{#1}}}{\putbib \pagebreak}

\defaultbibliography{mwecitations}
\defaultbibliographystyle{plainnat}
\bibliographystyle{plainnat}

\begin{document}
\bibliographyunit[\section]
\tableofcontents

\begin{thediscussion}[goossens93]
Discussion goes here.
\end{thediscussion}

\begin{thediscussion}[rothstein2011unemployment]
More discussion here.
Additional citations are \cite*{rothstein2011unemployment} and \cite*{fujita2010economic}.
\end{thediscussion}

\section{Appendix}
\renewcommand{\bibname}{Global bibliography}
\bibliography{mwecitations}
\end{document}

The output looks very strange:

enter image description here

It seems like the sections aren't being recognized, or I've entered the environment argument incorrectly. What am I doing wrong?

Michael A
  • 1,525
  • 2
  • 11
  • 16

1 Answers1

2

You have defined the environment to have one mandatory argument so the syntax should be

\begin{thediscussion}{goossens93}

not

\begin{thediscussion}[goossens93]

as it is, you are passing the argument [ to the environment (which will be an unknown citation) and then typesetting goosens93] as text not in an argument at all.

David Carlisle
  • 757,742
  • If I fix the arguments to the environment, they're recognized correctly, but the section headers still do not appear in the table of contents. The "? goossens93" disappears, as it should, but otherwise the output from my original code is still incorrect. If I replace \section* with \section in the environment definition, the headers do appear in the table of contents, but with section numbers, which I was trying to avoid in the first place. – Michael A Sep 05 '17 at 13:40
  • @MichaelA by default unnumbered sections do not appear in the tables of contents in the standard classes. But that seems to be a separate issue (and probably a duplicate) – David Carlisle Sep 05 '17 at 13:46
  • I wasn't aware of that, but thank you! That answers that question! – Michael A Sep 05 '17 at 13:47
  • @MichaelA eg first hit for a search for unnumbered section in table of contnts is https://tex.stackexchange.com/questions/212437/how-to-make-unnumbered-sections-aligned-in-table-of-contents – David Carlisle Sep 05 '17 at 13:47