多书目书目作为子部分

多书目书目作为子部分

我需要进行此修改的原因是我想要一个通用的“参考书目”部分,其中包含所有创建的参考书目multibib。目前我的代码(缩小到最小的工作示例)如下所示:

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
  @BOOK{Doe2013,
  title = {The concept of anonymity},
  author = {Doe, John},
  publisher = {Void},
  year = {2013}
  }
\end{filecontents*}

\documentclass{article}
\usepackage{multibib}
\newcites{ads}{Advertisments}

\begin{document}
\tableofcontents
\nocite{Doe2013}
\nociteads{Doe2014}
\clearpage
\section*{Bibliography}
\bibliographystyleads{plain}
\bibliographyads{ads}
\renewcommand{\refname}{Books and Articles}
\bibliographystyle{plain}
\bibliography{\jobname}
\end{document}

这(显然)最终会创建三个部分,这不是我想要的,我希望有一个部分(“参考”)和两个子部分(“广告”和“书籍和文章”)。我如何才能获得\bibliography'ish 宏调用\subsection*而不是\section*

附录

以下是一个示例ads.bib

@BOOK{Doe2014,
  title = {The concept of anonymity 2},
  author = {Doe, John},
  publisher = {Void},
  year = {2014}
  }

编辑

我忘了说我想让参考书目自动添加到目录中。

答案1

将其添加到您的示例序言中:

\usepackage{etoolbox}

\ifdefined\chapter
  \newcommand{\refname}{References}
  \patchcmd{\thebibliography}{\chapter*{\bibname}}{%
    \section*{\refname}
    \addcontentsline{toc}{section}{\refname}
    }{}{}
  \newcommand{\bibliographies}{%
    \chapter*{\bibname}
    \addcontentsline{toc}{chapter}{\bibname}
  }
\else
  \newcommand{\bibname}{Bibliography}
  \patchcmd{\thebibliography}{\section*{\refname}}{%
    \subsection*{\refname}
    \addcontentsline{toc}{subsection}{\refname}
    }{}{}
  \newcommand{\bibliographies}{%
    \section*{\bibname}
    \addcontentsline{toc}{section}{\bibname}
  }
\fi

并且\bibliographies(在我的代码片段中定义)就在参考书目开始之前。

正如您所见,我将功能扩展至具有\chapters 的类。

编辑

您不能使用上述解决方案,natbib因为它重新定义了thebibliography环境,因此etoolbox补丁将无法找到他正在寻找的内容。此代码应该可以完成这项工作:

\usepackage{etoolbox}

\makeatletter
\providecommand{\bibname}{Bibliography}
\providecommand{\refname}{References}
\@ifpackageloaded{natbib}
  {\renewcommand{\bibsection}{%
    \@ifundefined{chapter}
    {\subsection*{\refname \markboth{\refname}{\bibname}%
    \addcontentsline{toc}{subsection}{\refname}}
    }
    {\section*{\refname \markboth{\refname}{\bibname}%
    \addcontentsline{toc}{section}{\refname}}
    }
  }}
  {\@ifundefined{chapter}
    {\patchcmd{\thebibliography}{\section*{\refname}}{%
      \subsection*{\refname}
      \addcontentsline{toc}{subsection}{\refname}
      }{}{}
    }
    {\patchcmd{\thebibliography}{\chapter*{\bibname}}{%
      \section*{\refname}
      \addcontentsline{toc}{section}{\refname}
      }{}{}
    }
  }
\@ifundefined{chapter}
  {\newcommand{\bibliographies}{%
  \section*{\bibname}
  \if@FMB@addtotoc\addcontentsline{toc}{section}{\bibname}\fi}}
  {\newcommand{\bibliographies}{%
  \chapter*{\bibname}
  \if@FMB@addtotoc\addcontentsline{toc}{chapter}{\bibname}\fi}}
\makeatother

答案2

这里有一个替代建议:

加载包tocbibind并重新定义本地部分:

\bgroup
\let\section\subsection
\bibliographystyleads{plain}
\bibliographyads{ads}
\renewcommand{\refname}{Books and Articles}
\bibliographystyle{plain}
\bibliography{\jobname}
\egroup

完整代码如下:

% arara: pdflatex
% arara: bibtex
% arara: bibtex: {  files:[ads.aux] }
% arara: pdflatex
% arara: pdflatex
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
  @BOOK{Doe2013,
  title = {The concept of anonymity},
  author = {Doe, John},
  publisher = {Void},
  year = {2013}
  }
\end{filecontents*}
\begin{filecontents*}{ads.bib}
@BOOK{Doe2014,
  title = {The concept of anonymity 2},
  author = {Doe, John},
  publisher = {Void},
  year = {2014}
  }
\end{filecontents*}

\documentclass{article}
\usepackage[]{tocbibind}
\usepackage{multibib}
\newcites{ads}{Advertisments}

\begin{document}
\tableofcontents
\nocite{Doe2013}
\nociteads{Doe2014}
\clearpage
\section*{Bibliography}
\bgroup
\let\section\subsection
\bibliographystyleads{plain}
\bibliographyads{ads}
\renewcommand{\refname}{Books and Articles}
\bibliographystyle{plain}
\bibliography{\jobname}
\egroup
\end{document}

相关内容