如何使用 natbib 引文包在 rmarkdown 的附录之前放置参考文献?

How to put references before appendix in rmarkdown with natbib citation package?

我想在 rmarkdown latex 文档的 appendix 部分之前插入 references 部分。我试图将我的引文包从 natbib 更改为 biblatex,但它对我来说看起来太复杂了,需要我进行大量修改。我想知道是否有一种方法可以在不对当前 YAML header 进行太多更改的情况下这样做。或者有其他方法吗?

---
title: "Paper"   
thanks: 
author: |
  | \normalfont Joe
output: 
  pdf_document:
    number_sections: true
    citation_package: natbib
    fig_caption: true
    fig_height: 4.5
    fig_width: 8
link-citations: yes
toc: false
bibliography: /Users/references02.bib
biblio-style: apalike    
in_header: preamble.tex
keep_tex: yes
fontsize: 11pt
linestretch: 1.3
subparagraph: true
number_sections: true
geometry: margin=1in
header-includes:
- \usepackage{amsmath}
- \usepackage{amsthm}
- \numberwithin{equation}{section}
- \usepackage{makecell}
- \usepackage{geometry}
- \usepackage{graphicx}
- \usepackage{tikz}
- \usepackage{verbatim}
- \usepackage{chronosys}
- \usepackage{stackengine}
- \usepackage{booktabs, colortbl, xcolor}
- \usepackage{babel}
- \usetikzlibrary{arrows.meta,calc}
- \usepackage[font=small]{caption}
- \usepackage{adjustbox}
- \usepackage{tabularx}
- \usepackage{pgfplots}
- \usepackage[makeroom]{cancel}
- \usetikzlibrary{arrows,decorations.markings}
- \usetikzlibrary{intersections}
- \usepackage[nottoc]{tocbibind}
- \usepackage{filecontents}
- \newtheorem{prop}{Proposition}
- \newtheorem{definition}{Definition}
- \newtheorem{algorithem}{Algorithm}
- \usepackage[T1]{fontenc}
- \usepackage[toc,page]{appendix}
- \usepackage{tabularx,ragged2e,booktabs,caption}
- \newenvironment{rcases}
  {\left.\begin{aligned}}
  {\end{aligned}\right\rbrace}
- \renewcommand{\refname}{References}
- \UseRawInputEncoding
- \usepackage[utf8]{inputenc}
- \usepackage{hyperref}
- \hypersetup{
     colorlinks=true,
     linkcolor=black,
     filecolor=blue,
     citecolor = blue,      
     urlcolor=blue,
     }
- \usepackage{subcaption}
- \usepackage[font=small,labelfont=bf]{caption}
- \usepackage{float}
- \usepackage{flafter}
- \floatstyle{plaintop}
- \restylefloat{table}
- \setlength{\parindent}{2em}
- \setlength{\parskip}{0em}
- \usepackage{adjustbox}
- \usepackage[style=english]{csquotes} 
- \usepackage[nameinlink,capitalize,noabbrev]{cleveref}
- \creflabelformat{equation}{#2\textup{(\textcolor{red}{#1})}#3}
- \creflabelformat{figure}{#2\textcolor{red}{#1}#3}
- \creflabelformat{table}{#2\textcolor{red}{#1}#3}
- \creflabelformat{section}{#2\textcolor{red}{#1}#3}
- \usepackage{dcolumn}
- \usepackage{rotating}
- \usepackage{siunitx}
---


blah blah  \cite{ennis2019} \cite{worldbank2017}


\pagebreak
\begin{appendices}

blah blah
\cite{worldbank2017}

\end{appendices}


@article{ennis2019,
    author = {Ennis, Sean F and Gonzaga, Pedro and Pike, Chris},
    title = "{Inequality: A hidden cost of market power}",
    journal = {Oxford Review of Economic Policy},
    volume = {35},
    number = {3},
    pages = {518-549},
    year = {2019},
    month = {07},
    abstract = "{This paper explores the impact of competition on inequality by developing a new model to illustrate how higher profits from market power, and associated higher prices, could influence the distribution of wealth and income. We analyse data from eight OECD countriesâCanada, France, Germany, Korea, Japan, Spain, the United Kingdom, and the United States. In an average country in the sample, market power increases the wealth of the richest 10 per cent by between 12 and 21 per cent for a range of reasonable assumptions about savings behaviour, while it reduces the income of the poorest 20 per cent by 11 per cent or more. The results contribute to the economic literature on the origins of inequality, suggesting that lack of competition may be one source of economic inequality.}",
    issn = {0266-903X},
    doi = {10.1093/oxrep/grz017},
    url = {https://doi.org/10.1093/oxrep/grz017},
    eprint = {https://academic.oup.com/oxrep/article-pdf/35/3/518/28929084/grz017.pdf},
}

@book{worldbank2017,
   author = "World Bank",
   title = "A Step Ahead: Competition Policy for Shared Prosperity and Inclusive Growth",
   year = "2017",
   pages = 245,
   url = "https://www.oecd-ilibrary.org/content/publication/978-1-4648-0945-3",
   doi = "https://doi.org/https://doi.org/10.1596/978-1-4648-0945-3" 
}

您可以在附录周围使用 \AtEndDocument{} 以确保它们出现在最后:

---
title: "Paper"   
thanks: 
author: |
  | \normalfont Joe
output: 
  pdf_document:
    number_sections: true
    citation_package: natbib
    fig_caption: true
    fig_height: 4.5
    fig_width: 8
    keep_tex: true
link-citations: yes
toc: false
bibliography: references02.bib
biblio-style: apalike    
in_header: preamble.tex
keep_tex: yes
fontsize: 11pt
linestretch: 1.3
subparagraph: true
number_sections: true
geometry: margin=1in
header-includes:
- \usepackage{amsmath}
- \usepackage{amsthm}
- \numberwithin{equation}{section}
- \usepackage{makecell}
- \usepackage{geometry}
- \usepackage{graphicx}
- \usepackage{tikz}
- \usepackage{verbatim}
- \usepackage{chronosys}
- \usepackage{stackengine}
- \usepackage{booktabs, colortbl, xcolor}
- \usepackage{babel}
- \usetikzlibrary{arrows.meta,calc}
- \usepackage[font=small]{caption}
- \usepackage{adjustbox}
- \usepackage{tabularx}
- \usepackage{pgfplots}
- \usepackage[makeroom]{cancel}
- \usetikzlibrary{arrows,decorations.markings}
- \usetikzlibrary{intersections}
- \usepackage[nottoc]{tocbibind}
- \usepackage{filecontents}
- \newtheorem{prop}{Proposition}
- \newtheorem{definition}{Definition}
- \newtheorem{algorithem}{Algorithm}
- \usepackage[T1]{fontenc}
- \usepackage[toc,page]{appendix}
- \usepackage{tabularx,ragged2e,booktabs,caption}
- \newenvironment{rcases}
  {\left.\begin{aligned}}
  {\end{aligned}\right\rbrace}
- \renewcommand{\refname}{References}
- \UseRawInputEncoding
- \usepackage[utf8]{inputenc}
- \usepackage{hyperref}
- \hypersetup{
     colorlinks=true,
     linkcolor=black,
     filecolor=blue,
     citecolor = blue,      
     urlcolor=blue,
     }
- \usepackage{subcaption}
- \usepackage[font=small,labelfont=bf]{caption}
- \usepackage{float}
- \usepackage{flafter}
- \floatstyle{plaintop}
- \restylefloat{table}
- \setlength{\parindent}{2em}
- \setlength{\parskip}{0em}
- \usepackage{adjustbox}
- \usepackage[style=english]{csquotes} 
- \usepackage[nameinlink,capitalize,noabbrev]{cleveref}
- \creflabelformat{equation}{#2\textup{(\textcolor{red}{#1})}#3}
- \creflabelformat{figure}{#2\textcolor{red}{#1}#3}
- \creflabelformat{table}{#2\textcolor{red}{#1}#3}
- \creflabelformat{section}{#2\textcolor{red}{#1}#3}
- \usepackage{dcolumn}
- \usepackage{rotating}
- \usepackage{siunitx}
---


blah blah  \cite{ennis2019} \cite{worldbank2017}


\AtEndDocument{\pagebreak
\begin{appendices}

blah blah
\cite{worldbank2017}

\end{appendices}}