Bookown' bibliography multiple languages

亡梦爱人 提交于 2020-01-05 07:04:23

问题


I need to put two reference sections. References are equal, but in first section it must be in russian and in english in the second section (see png example). What shall I do to create bibliography references in multiple languages with R+Bookdown+Zotero/Juris-M?


回答1:


Partial solution for LaTeX/PDF output.

  • I started with a clone of bookdown-start
  • In index.Rmd and _output.yml I removed the bibliography specific things
  • In index.Rmd I defined a main font with Cyrillic characters
  • In _output.yml I specified a after_body include for the bibliography
  • I added the LaTeX code from LaTeX solution to 01-Introduction.Rmd, preamble.tex and biblio.tex as well as the two *.bib files

Here the relevant 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}

Unfortunately when I use build book, the second bibliography is ignored, brobably because bibtex is not called on the additional en.aux file. I used to be able to configure RStudio to use latexmk via setting RSTUDIO_PDFLATEX, but this is no longer working for me. Workaround:

  • Use keep_tex: yes
  • Copy the *.bib files to the output directories
  • manually call latexmk -xelatex ... in the output directory

Result:




回答2:


I would use the multiple-bibliographies.lua filter. Currently I used in linux with success, having installed:

sudo apt install pandoc-citeproc

In your bookdown folder (you can test cloning bookdown-demo), modify your index.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"
---

At the final chapter, add:

# English references {-}

::: {#refs_english}
:::

# Russian references {-}

::: {#refs_russian}
:::

Note: this will produce an html, but also a .docx in the folder _book.



来源:https://stackoverflow.com/questions/50866392/bookown-bibliography-multiple-languages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!