如何解决CJK短标题导致Papaja RMarkdown错误
我正在写带有papaja
包(RMarkdown变体)的文章,其中包含一些日语字符。我想将其shorttitle
用日语写成:
title : "ここは日本語もOK: You have a Japanese title"
shorttitle : "日本語が書けません: A Japanese short title causes an error"
但是,即使我使用UTF-8编码写入并保存文件,这些字符也会导致Pandoc错误: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
Pandoc版本
> rmarkdown::pandoc_version()
[1] ‘2.9.2.1’
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。