Bookown'参考书目多种语言

时间:2018-06-14 21:47:26

标签: r r-markdown bookdown bibliography

我需要放两个参考部分。参考文献是相同的,但在第一部分中,它必须是俄语和第二部分中的英语(参见png示例)。如何使用R + Bookdown + Zotero / Juris-M以多种语言创建参考书目参考? enter image description here

2 个答案:

答案 0 :(得分:0)

LaTeX / PDF输出的部分解决方案。

  • 我开始使用bookdown-start
  • 的克隆
  • index.Rmd_output.yml我删除了参考书目特定的内容
  • index.Rmd我定义了一个带有西里尔字符的主字体
  • _output.yml我为参考书目指定了after_body包含
  • 我将LaTeX solution的LaTeX代码添加到01-Introduction.Rmdpreamble.texbiblio.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 ...

结果:

enter image description here

enter image description here

答案 1 :(得分:0)

我将使用multiple-bibliographies.lua过滤器。目前,我已在Linux上成功使用,并已安装:

sudo apt install pandoc-citeproc

在您的bookdown文件夹中(您可以测试克隆bookdown-demo),修改索引。Rmd:

--- 
title: "book title"
author: "name name"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
always_allow_html: true
output: 
   bookdown::word_document2:
    pandoc_args: --lua-filter=multiple-bibliographies.lua

bibliography_english: [eng.bib]
bibliography_russian: [rus.bib]

documentclass: book
csl: yourCslFileForFormattingCitesOptional.csl
link-citations: yes
description: "text"
---

在最后一章中,添加:

# English references {-}

::: {#refs_english}
:::

# Russian references {-}

::: {#refs_russian}
:::

注意:这会在_book文件夹中生成一个html,但还会生成一个.docx。