r - Bookown' 参考书目多种语言
问题描述
我需要放两个参考部分。参考文献是相同的,但在第一部分它必须是俄文,第二部分是英文(参见 png 示例)。我应该如何使用 R+Bookdown+Zotero/Juris-M 创建多种语言的参考书目?
解决方案
LaTeX/PDF 输出的部分解决方案。
- 我从bookdown-start的克隆开始
- 在
index.Rmd
和_output.yml
我删除了参考书目特定的东西 - 在
index.Rmd
我用西里尔字符定义了一个主要字体 - 在我为参考书目
_output.yml
指定了一个包含after_body
- 我将LaTeX 解决方案中的 LaTeX 代码添加到
01-Introduction.Rmd
,preamble.tex
以及biblio.tex
这两个*.bib
文件
这里是相关的 git diff:
diff --git a/01-Introduction.Rmd b/01-Introduction.Rmd
index b94150e..372258d 100644
--- a/01-Introduction.Rmd
+++ b/01-Introduction.Rmd
@@ -2,3 +2,12 @@
This is the first real chapter.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
+eiusmod \mycite{book1} tempor incididunt ut labore et dolore magna
+aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
+laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
+in reprehenderit \mycite{book1, article1} in voluptate velit esse
+cillum \mycite{article1} dolore eu fugiat nulla pariatur. Excepteur sint
+occaecat cupidatat non proident, sunt in culpa qui officia deserunt
+mollit anim id est laborum.
+
diff --git a/_output.yml b/_output.yml
index 112cf5b..a04dcf9 100644
--- a/_output.yml
+++ b/_output.yml
@@ -11,7 +11,8 @@ bookdown::gitbook:
bookdown::pdf_book:
includes:
in_header: preamble.tex
+ after_body: biblio.tex
latex_engine: xelatex
- citation_package: natbib
+ keep_tex: yes
bookdown::epub_book:
stylesheet: style.css
diff --git a/biblio.tex b/biblio.tex
new file mode 100644
index 0000000..ea1eab8
--- /dev/null
+++ b/biblio.tex
@@ -0,0 +1,7 @@
+\chapter{Combined References}
+\bibliographystyle{ugost2008}
+\renewcommand{\bibsection}{\section{Список литературы}}
+\bibliography{biblio_ru}{}
+\bibliographystyleen{ugost2008}
+\renewcommand{\bibsection}{\section{References}}
+\bibliographyen{biblio_en}{}
diff --git a/index.Rmd b/index.Rmd
index ece36fe..e3bba35 100644
--- a/index.Rmd
+++ b/index.Rmd
@@ -4,8 +4,7 @@ author: "Sean Kross"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
-bibliography: [book.bib]
-biblio-style: apalike
+mainfont: Noto Serif
link-citations: yes
github-repo: seankross/bookdown-start
url: 'http\://seankross.com/bookdown-start/'
diff --git a/preamble.tex b/preamble.tex
index dfd2e14..c522818 100644
--- a/preamble.tex
+++ b/preamble.tex
@@ -1 +1,8 @@
\usepackage{booktabs}
+
+\usepackage[resetlabels]{multibib}
+\newcites{en}{english}
+\newcommand{\mycite}[1]{\cite{#1}\nociteen{#1}}
+
+\usepackage[square,numbers,sort&compress]{natbib}
+\renewcommand{\bibnumfmt}[1]{#1.\hfill}
不幸的是,当我使用时build book
,第二个参考书目被忽略了,因为bibtex
没有在附加en.aux
文件上调用。我曾经能够latexmk
通过设置配置 RStudio 以使用RSTUDIO_PDFLATEX
,但这不再适合我。解决方法:
- 利用
keep_tex: yes
- 将
*.bib
文件复制到输出目录 latexmk -xelatex ...
在输出目录中手动调用
结果:
推荐阅读
- javascript - 在 Javascript 中使用 PHP 变量
- report - 在 qweb 报告中打印静态图像
- iis - config.json 文件的奇怪行为
- youtrack - 你可以在同一个数据库上使用多个 YouTrack 实例吗?
- azure - SQL Azure Serverless 配置问题
- r - 更改 tbl_regression/tbl_uvregression 和 tbl_summary 中的默认变量值显示?#gtsummary
- elasticsearch - 如何在elasticsearch中做两个嵌套对象聚合?
- excel - 模糊字符串匹配 Excel
- scala - 从细化中获取正在细化的类
- ios - 在单击事件后更改 UiButton ImageView.alpha 中,如何保留以前的 alpha?