I'd like to customize the citation style when I knit an .Rmd
file with bookdown::pdf_document2
option, specifing biblio-style
in its YAML section.
I saw that using .csl
file rather than .bst
has solved some former questions about formatting citation sections in bookdown
(like this or this).
However, in my case, I have to specify which .bst
file to use in biblio-style
line in the YAML of .Rmd
because there is no .csl
file which satisfies my citation style...
I'm trying to use jecon-unicode.bst to produce my citation sections (I changed the file name as jeconunicode.bst
in my working directory due to the error with the hyphen in the file name). By this file, I can cite the documents published in English in APA style and, simultaneously, I can also cite the documents written in Japanese following the style which some academic societies in Japan recommend. I intend to make the citation sections as shown below:
Suzuki and Tanaka (2032)
鈴木・田中 (2021)
As you can see, "・" separates the multiple author names in in-text citations when a document written in Japanese language.
Suzuki, Ichiro, and Taro Tanaka (2032) “Our First Investigation: This Is Not the First, but This Should Be the Last.” Journal of Something Vol.23, No. 5, pp. 19–176.
鈴木一郎・田中太郎 (2021) 「われらの発見について:変貌を遂げつつある何とかの将来に関する過去・現在・未来」, 『何十華論考』, 第42巻, 第5号, 128–82頁.
In the reference section, jeconunicode.bst will also treat Japanese and English document differently, without creating different reference sections per language (i.e. the reference chapter I want to create is different from this). For instance, in the same bibliography section, 「」『』 are uesd for Japanese document names, while " " and italicization are used to modify English document names.
In order to activate jeconunicode.bst, I wrote Test.Rmd
, inserting myref.bib
in it.
---
title: "Title"
author: "Name"
date: "`r format(Sys.time(), '%Y年 %B %d日')`"
output:
bookdown::pdf_document2:
latex_engine: lualatex
keep_tex: yes
toc: TRUE
toc_depth: 2
number_sections: TRUE
fig_caption: TRUE
dev: cairo_pdf
extra_dependencies: subfig
citation_package: natbib
link-citations: yes
always_allow_html: yes
documentclass: ltjsarticle
header-includes:
- \RequirePackage{luatexja}
- \usepackage{graphicx}
- \usepackage{float}
- \DeclareGraphicsExtensions{.pdf,.PNG}
# You can unset Japanese font specification
# - \usepackage{luatexja-fontspec}
# - \setmainjfont{YuMincho}[UprightFont=YuMincho-Regular,BoldFont=YuMincho-Demibold]
# - \setmainfont{TeX Gyre Termes}
# - \setsansjfont{YuGothic-Medium}[BoldFont=YuGothic-Bold]
# - \setsansfont{TeX Gyre Heros}
- \setlength\parskip{0mm}
- \setlength\parindent{1\Cwd}
- \usepackage[japanese]{babel}
- \captionsjapanese
- \newdimen\bibindent
- \setlength\bibindent{3\Cwd}
bibliography: myref.bib
biblio-style: jconunicode.bst
editor_options:
chunk_output_type: console
---
# 何とかの考察に関する歴史
@ST-jp は、「なんとかとは何とかだ!」[@ST-jp]と述べた。
しかし、@ST-en では一転して、
「Something should be more significant than something!!」[@ST-en]と
主張している。
# 参考文献 {-}
\leftskip=3\Cwd
\setlength\parindent{-3\Cwd}
<div id="refs"></div>
\leftskip=0pt
\setlength\parindent{1\Cwd}
To make jeconunicode.bst recognize which article is written in Japanese, it is necessary to add language = {Ja}
.
@article{ST-jp,
title = {われらの発見について:変貌を遂げつつある何とかの将来に関する過去・現在・未来},
journal = {何十華論考},
volume = 42,
number = 5,
pages = {128 -- 182},
year = {2021},
author = {鈴木, 一郎 and 田中, 太郎},
language = {ja}
}
@article{ST-en,
title = {Our first investigation: this is not the first, but this should be the last},
journal = {Journal of Something},
volume = 23,
number = 5,
pages = {19 -- 176},
year = 2032,
author = {Suzuki, Ichiro and Tanaka, Taro}
}
However, I got only the undesirable result for the present. jeconunicode.bst specified in the biblio-style
option doesn't have any effect on the output and the default citation style is used, although I put .Rmd
, .bst
, and .bib
files in the same directory.
Suzuki and Tanaka (2032)
鈴木 and 田中 (2021)
Suzuki, Ichiro, and Taro Tanaka. 2032. “Our First Investigation: This Is Not the First, but This Should Be the Last.” Journal of Something 23 (5): 19–176.
鈴木, 一郎, and 田中太郎 . 2021. “われらの発見について:変貌を遂げつつある何とかの将来に関する過去・現在・未来.” 何十華論考 42 (5): 128–82.
Is there any nice way to cite Japanese and English (or any languages with Latin alphabet) in harmony as I pointed out above?
I use the bookdown in RStudio as shown below, with TeXLive 2018, under Windows 10:
>devtools::session_info(('bookdown'))
Session info ---------------------------------------------------------------------------------------
setting value
version R version 3.4.3 (2017-11-30)
system x86_64, mingw32
ui RStudio (1.1.453)
language (EN)
collate Japanese_Japan.932
tz Asia/Tokyo
date 2018-08-30
Packages -------------------------------------------------------------------------------------------
package * version date source
backports 1.1.2 2017-12-13 CRAN (R 3.4.3)
base64enc 0.1-3 2015-07-28 CRAN (R 3.4.1)
bookdown 0.7 2018-02-18 CRAN (R 3.4.4)
digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
evaluate 0.10.1 2017-06-24 CRAN (R 3.4.3)
graphics * 3.4.3 2017-12-06 local
grDevices * 3.4.3 2017-12-06 local
highr 0.6 2016-05-09 CRAN (R 3.4.3)
htmltools 0.3.6 2017-04-28 CRAN (R 3.4.3)
jsonlite 1.5 2017-06-01 CRAN (R 3.4.3)
knitr 1.20 2018-02-20 CRAN (R 3.4.4)
magrittr 1.5 2014-11-22 CRAN (R 3.4.3)
markdown 0.8 2017-04-20 CRAN (R 3.4.3)
methods * 3.4.3 2017-12-06 local
mime 0.5 2016-07-07 CRAN (R 3.4.1)
Rcpp 0.12.18 2018-07-23 CRAN (R 3.4.4)
rmarkdown 1.10 2018-06-11 CRAN (R 3.4.4)
rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.4)
stats * 3.4.3 2017-12-06 local
stringi 1.1.6 2017-11-17 CRAN (R 3.4.2)
stringr 1.2.0 2017-02-18 CRAN (R 3.4.3)
tinytex 0.6 2018-07-07 CRAN (R 3.4.4)
tools 3.4.3 2017-12-06 local
utils * 3.4.3 2017-12-06 local
xfun 0.3 2018-07-06 CRAN (R 3.4.4)
yaml 2.1.16 2017-12-12 CRAN (R 3.4.3)
I was not able to reproduce your issue with the following test file:
---
title: "Title"
author: "Name"
date: "`r format(Sys.time(), '%Y年 %B %d日')`"
output:
bookdown::pdf_document2:
latex_engine: lualatex
keep_tex: yes
toc: TRUE
toc_depth: 2
number_sections: TRUE
fig_caption: TRUE
dev: cairo_pdf
extra_dependencies: subfig
citation_package: natbib
link-citations: yes
always_allow_html: yes
documentclass: ltjsarticle
header-includes:
- \RequirePackage{luatexja}
- \usepackage{graphicx}
- \usepackage{float}
- \DeclareGraphicsExtensions{.pdf,.PNG}
- \usepackage{luatexja-fontspec}
- \setmainfont{TeX Gyre Termes}
- \setsansfont{TeX Gyre Heros}
- \setlength\parskip{0mm}
- \setlength\parindent{1\Cwd}
- \usepackage[japanese]{babel}
- \captionsjapanese
- \newdimen\bibindent
- \setlength\bibindent{3\Cwd}
bibliography: myref.bib
biblio-style: jeconunicode
editor_options:
chunk_output_type: console
---
# 何とかの考察に関する歴史
@ST-jp は、「なんとかとは何とかだ!」[@ST-jp]と述べた。
しかし、@ST-en では一転して、
「Something should be more significant than something!!」[@ST-en]と
主張している。
# 参考文献 {-}
\leftskip=3\Cwd
\setlength\parindent{-3\Cwd}
<div id="refs"></div>
\leftskip=0pt
\setlength\parindent{1\Cwd}
Instead of producing the undesired output, my HD was filled with several GB of error messages from bibtex
. Among many others there was:
is.kanji.str$ is an unknown function---line 1643 of file jeconunicode.bst
is.kanji.str$ is an unknown function---line 1644 of file jeconunicode.bst
is.kanji.str$ is an unknown function---line 1645 of file jeconunicode.bst
is.kanji.str$ is an unknown function---line 1646 of file jeconunicode.bst
I figured that I should be using the pbibtex
instead of bibtex
. Indeed, processing the resulting tex
and aux
files manually with pbibtex
and lualatex
worked fine. Since I found no way to configure that, I just created a symbolic link:
ln -s /usr/bin/pbibtex ~/bin/bibtex
This way a call to bibtex
would actually call pbibtex
.
After that the document compiled, even though it took several calls to "Knit" within RStudio to get the references resolved:
To me this looks like the desired output. I cannot explain why you are seeing different results.
> devtools::session_info(('bookdown'))
Session info -----------------------------------------------------------------------------------------
setting value
version R version 3.5.1 (2018-07-02)
system x86_64, linux-gnu
ui RStudio (1.2.830)
language (EN)
collate de_DE.UTF-8
tz Europe/Berlin
date 2018-08-31
Packages ---------------------------------------------------------------------------------------------
package * version date source
backports 1.1.2 2017-12-13 CRAN (R 3.5.0)
base64enc 0.1-3 2015-07-28 CRAN (R 3.5.0)
bookdown 0.7 2018-02-18 CRAN (R 3.5.0)
digest 0.6.16 2018-08-22 CRAN (R 3.5.1)
evaluate 0.11 2018-07-17 CRAN (R 3.5.1)
glue 1.3.0 2018-08-24 Github (tidyverse/glue@4e74901)
graphics * 3.5.1 2018-07-03 local
grDevices * 3.5.1 2018-07-03 local
highr 0.7 2018-06-09 CRAN (R 3.5.0)
htmltools 0.3.6 2017-04-28 CRAN (R 3.5.0)
jsonlite 1.5 2017-06-01 CRAN (R 3.5.0)
knitr 1.20 2018-02-20 CRAN (R 3.5.0)
magrittr 1.5 2014-11-22 CRAN (R 3.5.0)
markdown 0.8 2017-04-20 CRAN (R 3.5.0)
methods * 3.5.1 2018-07-03 local
mime 0.5 2016-07-07 CRAN (R 3.5.0)
Rcpp 0.12.18 2018-07-23 CRAN (R 3.5.1)
rmarkdown 1.10 2018-06-11 CRAN (R 3.5.0)
rprojroot 1.3-2 2018-01-03 CRAN (R 3.5.0)
stats * 3.5.1 2018-07-03 local
stringi 1.2.4 2018-07-20 CRAN (R 3.5.1)
stringr 1.3.1 2018-05-10 CRAN (R 3.5.0)
tinytex 0.8 2018-08-30 CRAN (R 3.5.1)
tools 3.5.1 2018-07-03 local
utils * 3.5.1 2018-07-03 local
xfun 0.3 2018-07-06 CRAN (R 3.5.1)
yaml 2.2.0 2018-07-25 CRAN (R 3.5.1)