![当节文本是环境的参数时,为什么我的新环境无法正确显示节?](https://linux22.com/image/361306/%E5%BD%93%E8%8A%82%E6%96%87%E6%9C%AC%E6%98%AF%E7%8E%AF%E5%A2%83%E7%9A%84%E5%8F%82%E6%95%B0%E6%97%B6%EF%BC%8C%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E7%9A%84%E6%96%B0%E7%8E%AF%E5%A2%83%E6%97%A0%E6%B3%95%E6%AD%A3%E7%A1%AE%E6%98%BE%E7%A4%BA%E8%8A%82%EF%BC%9F.png)
目标是拥有一个可以获取引用关键字并将其显示在节标题中的环境,除其他事项外。为了 MWE,我大大简化了环境。代码如下:
\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}
输出看起来很奇怪:
似乎这些部分无法被识别,或者我输入的环境参数不正确。我做错了什么?
答案1
您已将环境定义为具有一个强制参数,因此语法应该是
\begin{thediscussion}{goossens93}
不是
\begin{thediscussion}[goossens93]
事实上,您正在将参数传递[
给环境(这将是一个未知的引用),然后将其排版goosens93]
为根本不在参数中的文本。