我在博士论文中遇到了参考书目连续编号的问题。也就是说,如果第 1 章的参考书目从 [1],...,[3],在第 2 章中它从 [4],...[6] 开始,如下所示。
我在下面提供了我的论文的 MWE。我为每一章使用了多个 .tex 文件。
Thesis.tex 文件 =>
\documentclass[11pt]{report}
\usepackage[a4paper,left=35mm, right=25mm, top=19mm,bottom=23mm]{geometry}
\usepackage{setspace}
\doublespacing
\usepackage[nottoc]{tocbibind}
\usepackage[titletoc]{appendix}
\usepackage{bm}
\usepackage{etoolbox}
\usepackage{multibib}
\usepackage[round, sort, numbers, authoryear, sectionbib]{natbib}
\usepackage[sectionbib]{chapterbib}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{titlesec}
\usepackage{bibentry}
\usepackage{lmodern}
\usepackage{amsthm,amsmath,amsfonts,amssymb,bbm}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{csquotes}
\usepackage[pdfencoding=auto, psdextra]{hyperref}
\hypersetup{colorlinks=true,linkcolor=blue, anchorcolor=red, citecolor=blue, filecolor = red, urlcolor = blue,
pdfauthor=author}
\pdfstringdefDisableCommands{\def\varepsilon{\textepsilon}}
\usepackage{enumerate}
\usepackage{bookmark}
\usepackage{array, booktabs, makecell}
\usepackage{siunitx}
\usepackage{xurl}
\usepackage[misc]{ifsym}
\sisetup{table-number-alignment=center, exponent-product=\cdot}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usepackage{subfig}
\pgfplotsset{compat=1.10}
\usepackage{comment}
\usepackage{xcolor}
\usepackage{listings}
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\newcounter{bibcount}
\makeatletter
\patchcmd{\@lbibitem}{\item[}{\item[\hfil\stepcounter{bibcount}{\thebibcount.}}{}{}
\setlength{\bibhang}{2\parindent}
\renewcommand\NAT@bibsetup%
[1]{\setlength{\leftmargin}{\bibhang}\setlength{\itemindent}{-\parindent}%
\setlength{\itemsep}{\bibsep}\setlength{\parsep}{\z@}}
\lstset{
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}; should come as last argument
basicstyle=\linespread{0.5}, % the size of the fonts that are used for the code
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
breaklines=true, % sets automatic line breaking
captionpos=b, % sets the caption-position to bottom
commentstyle=\color{mygreen}, % comment style
deletekeywords={...}, % if you want to delete keywords from the given language
%escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
%frame=single, % adds a frame around the code
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
keywordstyle=\color{blue}, % keyword style
language=Octave, % the language of the code
morekeywords={*,...}, % if you want to add more keywords to the set
% numbers=left, % where to put the line-numbers; possible values are (none, left, right)
numbersep=5pt, % how far the line-numbers are from the code
numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
showstringspaces=false, % underline spaces within strings only
showtabs=false, % show tabs within strings adding particular underscores
stepnumber=2, % the step between two line-numbers. If it's 1, each line will be numbered
stringstyle=\color{mymauve}, % string literal style
tabsize=2, % sets default tabsize to 2 spaces
title=\lstname % show the filename of files included with \lstinputlisting; also try caption instead of title
}
\lstdefinestyle{customc}{
belowcaptionskip=1\baselineskip,
breaklines=true,
frame=L,
xleftmargin=\parindent,
language=C,
showstringspaces=false,
basicstyle=\footnotesize\ttfamily,
keywordstyle=\bfseries\color{green!40!black},
commentstyle=\itshape\color{purple!40!black},
identifierstyle=\color{blue},
stringstyle=\color{orange},
}
\lstdefinestyle{customasm}{
belowcaptionskip=1\baselineskip,
xleftmargin=\parindent,
language=[x86masm]Assembler,
basicstyle=\footnotesize\ttfamily,
commentstyle=\itshape\color{purple!40!black},
}
\newtheorem{cond}{Condition}{\bfseries}{\itshape}
\numberwithin{cond}{chapter}
\theoremstyle{definition}
\newtheorem{definition}{Definition}
\numberwithin{definition}{chapter}
\newtheorem{remark}{Remark}
\numberwithin{remark}{chapter}
\theoremstyle{plain}
\newtheorem{notation}{Notation}
\newtheorem{proposition}{Proposition}
\newtheorem{assumption}{Assumption}
\numberwithin{assumption}{chapter}
\newtheorem{theorem}{Theorem}
\numberwithin{theorem}{chapter}
\newtheorem{lemma}{Lemma}
\numberwithin{lemma}{chapter}
\newtheorem{corollary}{Corollary}
\newcommand{\lfrac}[2]{\genfrac{}{}{0pt}{}{#1}{#2}}
\newtheorem{Example}{Example}
\numberwithin{Example}{chapter}
\newenvironment{example}{%
\vspace{0.3cm} \pagebreak [2]%
\par%
\refstepcounter{proposition}%
\noindent%
{\bf Example~\theproposition.\ }}{\qed}%
%
\newenvironment{proof1}{%
\vspace{0.3cm} \pagebreak [2]%
\par%
\noindent%
{\it Proof~}}{\qed}%
%
\def\a{\alpha}
\def\be{\beta}
\def\de{\delta}
\def\De{\Delta}
\def\t{{\bf t}}
\def\ga{\gamma}
\def\Ga{\Gamma}
\def\la{\lambda}
\def\La{\Lambda}
\def\ep{\varepsilon}
\def\si{\sigma}
\def\e{\eta}
\def\th{\theta}
\def\o{\omega}
\def\u{{\overline u}}
%\def\O{\Omega}
\def\cov{{\rm Cov}}
\def\diam{{\rm diam}}
\def\dim{{\rm dim}_{_{\rm H}}}
\def\Dim{{\rm dim}_{_{\rm P}}}
\def\adim{{\rm adim}}
\def\aDim{{\rm aDim}}
\def\sp{{\rm supp}}
\def\var{{\rm Var}}
\def\l{{\langle}}
\def\r{\rangle}
\def\F{{\EuScript F}}
\def\In{{\rm 1 \hskip-2.9truept l}}
\def\OCC{{\mathbb{O}}}
\newcommand{\wh}{\widehat}
\newcommand{\wt}{\widetilde}
\def\N{{\mathbb N}}
\def\R{{\mathbb R}}
\def\Q{{\mathbb Q}}
\def\C{{\mathbb C}}
\def\eps{\varepsilon}
\def\Re {{\rm Re}\,}
\def\E{{\mathbb E}}
\def\I{{\cal I}}
\def\P{{\mathbb P}}
\def\Z{{\mathbb Z}}
\def\M{{\EuScript M}}
\def\EN{{\EuScript{E}}}
\def\CAP{{\EuScript{C}}}
\def\sleq{\mathop{\preccurlyeq}}
\def\sgeq{\mathop{\succcurlyeq}}
\def\kto{{\cal K}}
\def\K{{\cal K}_{j_0}}
\def\H{{\cal H}_{l}^q}
\def\V{{\cal V}}
\def\ovl{\overline}
\def\wh{\widehat}
\title{\LARGE{\bf{Working Draft}} \\
{Anomaly Detection}\\
{\large Hello}\\
}
\author{Anonymous}
\date{16.11.2020}
\begin{document}
%\maketitle
\begin{titlepage}
\vspace*{1cm}
\centering
{\Huge\bfseries \bf{Working Draft ...} \\ \huge{Anomaly Detection} \par}
\end{titlepage}
\tableofcontents
\listoffigures
\listoftables
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
This is my abstract.
\chapter*{Acknowledgements}
\addcontentsline{toc}{chapter}{Acknowledgements}
Thank you all.
\include{Introduction}
\include{Definitions}
\end{document}
Next, the Introduction.tex file =>
\chapter{Introduction}\label{Chapter1}
This chapter gives Introduction
\section{Data science}\label{SI:1}
Anomaly detection plays an important role in today's world, see~\cite{Chandola:2009},\cite{Patcha:2007},\cite{Akoglu:2015}.
\bibliographystyle{plainnat}
\bibliography{BibInt}
接下来,Definitions.tex 文件 =>
\chapter{Definitions, notations and auxiliary results }\label{Chapter2}
Anomaly detection plays an important role in today's world, see~\cite{Chandola:2009},\cite{Patcha:2007},\cite{Akoglu:2015}.
\bibliographystyle{plainnat}
\bibliography{BibInt}
最后,.bib 文件 =>
@article{Chandola:2009,
title = {Anomaly detection: A survey},
author = {Chandola, Varun and Banerjee, Arindam and Kumar, Vipin},
journal = {ACM computing surveys (CSUR)},
volume = {41},
number = {3},
pages = {1-58},
year = {2009},
}
@article{Patcha:2007,
title = {An overview of anomaly detection techniques: Existing solutions and latest technological trends},
author = {Patcha, Animesh and Park, Jung-Min},
journal = {Computer networks},
volume = {51},
number = {12},
pages = {3448-3470},
year = {2007}
}
@article{Akoglu:2015,
title = {Graph based anomaly detection and description: a survey},
author = {Akoglu, Leman and Tong, Hanghang and Koutra, Danai},
journal = {Data mining and knowledge discovery},
volume = {29},
number = {3},
pages = {626-688},
year = {2015}
}
我花了很多天试图解决这个问题。我需要每个参考书目都从“1”开始。我非常感谢你在这件事上的帮助。
非常感谢。
答案1
您已经定义了一个bibcount
计数器来显示参考书目中的数字。因此,您可以在每次\include
使用后将此计数器重置为 0 \setcounter{bibcount}{0}
。
梅威瑟:
\documentclass[11pt]{report}
\usepackage{etoolbox}
\usepackage[round, sort, numbers, authoryear, sectionbib]{natbib}
\usepackage[sectionbib]{chapterbib}
\usepackage{bibentry}
\newcounter{bibcount}
\makeatletter
\patchcmd{\@lbibitem}{\item[}{\item[\hfil\stepcounter{bibcount}{\thebibcount.}}{}{}
\setlength{\bibhang}{2\parindent}
\renewcommand\NAT@bibsetup%
[1]{\setlength{\leftmargin}{\bibhang}\setlength{\itemindent}{-\parindent}%
\setlength{\itemsep}{\bibsep}\setlength{\parsep}{\z@}}
\begin{document}
\include{bibIntroduction}
\setcounter{bibcount}{0}
\include{bibDefinitions}
\end{document}
请注意,我将其\usepackage{multibib}
从 MWE 中删除,因为它没有必要(多个参考书目由包处理chapterbib
)。
结果: