如何在 R Markdown 中的两个单独的 headers 下插入两个单独的参考书目(不在 body 文本中引用它们)?
How to insert two separate bibliographies (without citing them in the body text) under two separate headers in R Markdown?
考虑以下 R Markdown 代码:
---
title: 'John Doe'
output: pdf_document
bibliography: [bib1.bib, bib2.bib]
nocite: '@*'
csl: vancouver.csl
---
# Peer-reviewed publications
# Other publications
bib1.bib代码:
@article{article1,
Author = {Doe, John},
Title = {{Article 1 name}},
Journal = {{Journal 1 name}},
Year = {{2021}},
Volume = {{1}},
Pages = {{1-2}},
}
@article{article2,
Author = {Doe, John},
Title = {{Article 2 name}},
Journal = {{Journal 2 name}},
Year = {{2020}},
Volume = {{1}},
Pages = {{1-2}},
}
bib2.bib代码:
@article{article3,
Author = {Doe, John},
Title = {{Article 3 name}},
Journal = {{Journal 3 name}},
Year = {{2021}},
Volume = {{1}},
Pages = {{1-2}},
}
编织输出:
但是,我更愿意关注以下输出:
请注意,我 不 想要 in-text 引用,而是列出整个参考书目,这就是为什么我通过添加 "nocite: ' @*'" 添加到代码中,但我无法得到我想要的结果。
对了,我这里用的是csl风格vancouver.csl(请看:https://www.zotero.org/styles?q=vancouver)
非常感谢任何帮助。
您可以使用 biblatex 拆分参考书目:
---
title: 'John Doe'
output:
pdf_document:
keep_tex: true
csl: vancouver.csl
header-includes:
- \include{preamble.tex}
---
与 preamble.tex
:
\usepackage[style=vancouver]{biblatex}
\addbibresource{bib1.bib}
\addbibresource{bib2.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite]{
\perdatasource{bib1.bib}
\step[fieldset=keywords, fieldvalue={,peer}, append]
}
}
}
\AtEndDocument{\nocite{*}
\printbibliography[keyword={peer},title={Peer-reviewed publications}]
\DeclareFieldFormat{labelnumber}{%
\ifinteger{#1}
{\number\numexpr#1-2\relax}
{#1}}
\printbibliography[notkeyword={peer},title={Other publications}]}
然后用
编译生成的filename.tex
文件
pdflatex filename
biber filename
pdflatex filename
考虑以下 R Markdown 代码:
---
title: 'John Doe'
output: pdf_document
bibliography: [bib1.bib, bib2.bib]
nocite: '@*'
csl: vancouver.csl
---
# Peer-reviewed publications
# Other publications
bib1.bib代码:
@article{article1,
Author = {Doe, John},
Title = {{Article 1 name}},
Journal = {{Journal 1 name}},
Year = {{2021}},
Volume = {{1}},
Pages = {{1-2}},
}
@article{article2,
Author = {Doe, John},
Title = {{Article 2 name}},
Journal = {{Journal 2 name}},
Year = {{2020}},
Volume = {{1}},
Pages = {{1-2}},
}
bib2.bib代码:
@article{article3,
Author = {Doe, John},
Title = {{Article 3 name}},
Journal = {{Journal 3 name}},
Year = {{2021}},
Volume = {{1}},
Pages = {{1-2}},
}
编织输出:
但是,我更愿意关注以下输出:
请注意,我 不 想要 in-text 引用,而是列出整个参考书目,这就是为什么我通过添加 "nocite: ' @*'" 添加到代码中,但我无法得到我想要的结果。
对了,我这里用的是csl风格vancouver.csl(请看:https://www.zotero.org/styles?q=vancouver)
非常感谢任何帮助。
您可以使用 biblatex 拆分参考书目:
---
title: 'John Doe'
output:
pdf_document:
keep_tex: true
csl: vancouver.csl
header-includes:
- \include{preamble.tex}
---
与 preamble.tex
:
\usepackage[style=vancouver]{biblatex}
\addbibresource{bib1.bib}
\addbibresource{bib2.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite]{
\perdatasource{bib1.bib}
\step[fieldset=keywords, fieldvalue={,peer}, append]
}
}
}
\AtEndDocument{\nocite{*}
\printbibliography[keyword={peer},title={Peer-reviewed publications}]
\DeclareFieldFormat{labelnumber}{%
\ifinteger{#1}
{\number\numexpr#1-2\relax}
{#1}}
\printbibliography[notkeyword={peer},title={Other publications}]}
然后用
编译生成的filename.tex
文件
pdflatex filename
biber filename
pdflatex filename