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 (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...