如何在文中以数字形式引用参考文献?并加上方括号?

如何在文中以数字形式引用参考文献?并加上方括号?

在 references.bib 中

@ARTICLE{2,
 AUTHOR={A. Gama  and Lazarevic Aleksandar and Latecki Longin Jan},
 TITLE={Machine Learning techniques},
 PUBLISHER={IEEE},
 ADDRESS={},
 YEAR={2007}
 }

@BOOK{3,
 AUTHOR={D.Hawkins},
 TITLE={Identification of Outliers},
 PUBLISHER={Springer},
 ADDRESS={},
 YEAR={1980}
 }

在另一个文件中:report.tex

\documentclass[a4paper,11pt,oneside]{book}

%%-------------------------------------
%% Page margin settings - % half inch margin all sides (recommended)
%%-------------------------------------
\usepackage[margin=1.2in]{geometry} 

%%-------------------------------------
%% Font settings - % CM San or Ariel (recommended)
%%-------------------------------------
% Switch the following two line off: to revert back to default LaTex font (NOT recommended)
\usepackage{amsfonts}
\renewcommand*\familydefault{\sfdefault}

%%-------------------------------------
%% Math/Definition/Theorem/Algorithm packages settings 
%%-------------------------------------
\usepackage[cmex10]{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\newtheorem{mydef}{Definition}
\newtheorem{mytherm}{Theorem}

%%-------------------------------------
%% Algorithms/Code Listing environment settings  - 
%% Please do not change these settings
%%-------------------------------------
\usepackage{algorithm}
\usepackage{algpseudocode}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0.1}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codeblue}{rgb}{0.10,0.00,1.00}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{1.0,1.0,1.0}

\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{codeblue},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                        
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2,
    frame=none
}
\lstset{style=mystyle}

%%-------------------------------------
%% Graphics/Figures environment settings
%%-------------------------------------
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{caption}
\usepackage{lipsum}

%%-------------------------------------
%% Table environment settings
%%-------------------------------------
\usepackage{multirow}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{booktabs}

%\usepackage{longtable,booktabs}

%%-------------------------------------
%% List of Abbreviations settings
%%-------------------------------------
\usepackage{enumitem}
\newlist{abbrv}{itemize}{1}
\setlist[abbrv,1]{label=,labelwidth=1in,align=parleft,itemsep=0.1\baselineskip,leftmargin=!}

\usepackage{setspace}
\linespread{1.3}
%% \usepackage{setspace}
%%\doublespacing
%%-------------------------------------
%% Bibliography/References settings   - Harvard Style was used in this report
%%-------------------------------------
%\usepackage[hidelinks]{hyperref}
\usepackage{hyperref,url}
%\usepackage[comma,authoryear]{natbib}
\usepackage{numbers}

\renewcommand{\bibname}{References} % DO NOT remove or switch of 

%%-------------------------------------
%% Appendix settings     
%%-------------------------------------
\usepackage[toc]{appendix}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                     SETTING ENDS                                            %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

 \mainmatter
    % Read for preparation of document in LaTex 
    % Lamport, L. (1986), LATEX: A Document Preparation System, Addison-Wesley.
    
    \input{chapters/introduction.tex}
    \input{chapters/literature.tex}% https://guides.library.bloomu.edu/litreview
    \input{chapters/methodology.tex}
    \input{chapters/results.tex}
    \input{chapters/discussion.tex}
    \input{chapters/conclusions.tex}
    \input{chapters/reflection.tex}
    

    
    % -------------------------------------------------------------------
    % Bibliography/References  -  Harvard Style was used in this report
    % -------------------------------------------------------------------
    %\bibliographystyle{unsrt} % Harvard Style 
    
    %\bibliography{references}  %  Patashnik, O. (1988), BibTEXing. Documentation for general BibTEX users.
    %\bibliographystyle{agsm}
    %\bibliographystyle{abbrv-fr}
    \bibliographystyle{plainnat}
    \bibliography{references}
    
    % -------------------------------------------------------------------
    % Appendices
    % -------------------------------------------------------------------
    
    \begin{appendices}
        \input{chapters/appendix_A.tex}
        \input{chapters/appendix_B.tex}
    \end{appendices}
    
\end{document}

I have here this text 

In view of this, this is considered a very popular method \citep{2,3}.

我希望它如下:

鉴于此,这被认为是一种非常流行的方法[2,3]。

而不是这个:鉴于此,这被认为是一种非常流行的方法(A. Gama 和 Lazarevic Aleksandar:2007 和 Hawkins:1980)

它给了我一堆错误:

The compiler cannot find the file you want to include. Make sure that you have uploaded the file and specified the file location correctly.
Learn more
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Emergency stop.
<read *> 

This compile didn’t produce a PDF. This can happen if:
There is an unrecoverable LaTeX error. If there are LaTeX errors shown below or in the raw logs, please try to fix them and compile again.
The document environment contains no content. If it’s empty, please add some content and compile again.
This project contains a file called output.pdf. If that file exists, please rename it and compile again.

并且没有名为 numbers.sty 的包,而且我是 overleaf,所以我从未安装过文件

谢谢 -

相关内容