我正在写一篇带有papaja
包(RMarkdown 变体)的文章,其中包含一些日文字符。我想shorttitle
用日语写如下:
title : "ここは日本語もOK: You have a Japanese title"
shorttitle : "日本語が書けません: A Japanese short title causes an error"
但是,这些字符会导致 Pandoc 错误,即使我使用 UTF-8 编码编写和保存我的文件: pandoc.exe: Cannot decode byte '\x93': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream Error: pandoc document conversion failed with error 1 Execution halted
。在这个阶段,既没有tex
生成文件也没有生成 PDF。
尽管如此,当我从短标题中删除 CJK 字符并在正文中包含其他 CJK 字符时,如下所示,我能够同时获得 tex 和 PDF 文件。
title : "ここは日本語もOK: You have a Japanese title"
shorttitle : "A Japanese short title causes an error"
那么,我该如何解决这个问题呢?或者,至少,问题的原因在哪里?
MWE
---
title : "ここは日本語もOK: You have a Japanese title"
shorttitle : "日本語が書けません: A Japanese short title causes an error"
author:
- name : "First Author"
affiliation : "1"
corresponding : yes # Define only one corresponding author
address : "Postal address"
email : "my@email.com"
affiliation:
- id : "1"
institution : "Hoge-Huga-University"
bibliography : ["r-references.bib"]
floatsintext : no
figurelist : no
tablelist : no
footnotelist : no
linenumbers : no
mask : no
draft : no
CJKmainfont: MS Mincho
#CJKsansfont: MS Gothic
documentclass : "apa6"
classoption : "doc"
output :
papaja::apa6_pdf:
number_sections: true
latex_engine: xelatex
keep_tex: true
toc: false
fig_caption: TRUE
dev: cairo_pdf
csl-hanging-indent: true
---
```{r setup, include = FALSE}
library("papaja")
r_refs("r-references.bib")
```
```{r analysis-preferences}
# Seed for random number generation
set.seed(42)
knitr::opts_chunk$set(cache.extra = knitr::rand_seed)
```
# 日本語desu・yo!
お早う
\textsf{こんにちは}
This is the \texttt{document 書類} for 資料 and I'm \textsf{stuck}...
$$
\log(5) = 1.609438
$$
# Methods
We report how we determined our sample size, all data exclusions (if any), all manipulations, and all measures in the study. <!-- 21-word solution (Simmons, Nelson & Simonsohn, 2012; retrieved from http://ssrn.com/abstract=2160588) -->
## Participants
## Material
## Procedure
## Data analysis
We used `r cite_r("r-references.bib")` for all our analyses.
# Results
# Discussion
\newpage
# References
\begingroup
\setlength{\parindent}{-0.5in}
\setlength{\leftskip}{0.5in}
<div id="refs" custom-style="Bibliography"></div>
\endgroup
会话信息
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=Japanese_Japan.932 LC_CTYPE=Japanese_Japan.932
[3] LC_MONETARY=Japanese_Japan.932 LC_NUMERIC=C
[5] LC_TIME=Japanese_Japan.932
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 compiler_4.0.2 RColorBrewer_1.1-2
[4] prettyunits_1.1.1 remotes_2.2.0 tools_4.0.2
[7] extrafont_0.17 digest_0.6.25 packrat_0.5.0
[10] pkgbuild_1.1.0 jsonlite_1.7.0 evaluate_0.14
[13] rlang_0.4.7 cli_2.0.2 rstudioapi_0.11
[16] curl_4.3 yaml_2.2.1 parallel_4.0.2
[19] xfun_0.16 Rttf2pt1_1.3.8 withr_2.2.0
[22] DiagrammeR_1.0.6.1 knitr_1.29 htmlwidgets_1.5.1
[25] rprojroot_1.3-2 glue_1.4.1 R6_2.4.1
[28] DiagrammeRsvg_0.1 processx_3.4.3 fansi_0.4.1
[31] rmarkdown_2.3 papaja_0.1.0.9997 callr_3.4.3
[34] extrafontdb_1.0 magrittr_1.5 backports_1.1.8
[37] ps_1.3.4 htmltools_0.5.0 assertthat_0.2.1
[40] rsvg_2.1 V8_3.2.0 visNetwork_2.0.9
[43] crayon_1.3.4
潘多克版
> rmarkdown::pandoc_version()
[1] ‘2.9.2.1’