问题描述
当我在 R 包 vitae 中编织任何 CV 模板时,每个模板都会出现略微不同的错误。我已经确保所有文件,包括我的 Rmd 文件,都在同一个目录中,我没有以任何方式更改模板。例如,当我编写现代简历模板时,我收到以下错误消息:
! Package inputenc Error: Unicode character € (U+20AC)
(inputenc) not set up for use with LaTeX.
Try other LaTeX engines instead (e.g.,xelatex) if you are using pdflatex. See https://bookdown.org/yihui/rmarkdown-cookbook/latex-unicode.html
Error: LaTeX Failed to compile MWillox.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See MWillox.log for more info.
In addition: Warning messages:
1: In has_crop_tools() :
Tool(s) not installed or not in PATH: ghostcript
-> As a result,figure cropping will be disabled.
2: package 'tibble' was built under R version 4.0.5
3: package 'dplyr' was built under R version 4.0.5
Execution halted
当我选择很棒的简历模板时,错误信息略有不同:
! Undefined control sequence.
<argument> \fontspec_gset_family:Nnn
\g__fontspec_mathsf_tl { UprightFont = ...
l.123 ^^I\fi
其余的错误信息与上面相同。
我尝试更新我的所有软件包。我重新安装了 Rtools、pandoc 和 ghostcript。我确保环境路径都在那里并且指向正确的目录,按照这个 advice
这两个错误似乎都表明我在 Rmd 或 bib 文件中的某些字体或符号有问题,但这似乎不太可能,因为我没有对模板进行任何更改,所以我很难过。
我是 R Markdown 的相对较轻的用户,因此如果您能提供一些介绍性的建议,我将不胜感激。
这是我的会话信息:
- Session info ----------------------------------------------------------------------------------------------------------------------------------------
setting value
version R version 4.0.2 (2020-06-22)
os Windows 10 x64
system x86_64,mingw32
ui RStudio
language (EN)
collate English_Canada.1252
ctype English_Canada.1252
tz America/New_York
date 2021-05-02
- Packages --------------------------------------------------------------------------------------------------------------------------------------------
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.2)
cli 2.5.0 2021-04-26 [1] CRAN (R 4.0.5)
Crayon 1.4.1 2021-02-08 [1] CRAN (R 4.0.5)
DBI 1.1.1 2021-01-15 [1] CRAN (R 4.0.5)
digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.5)
dplyr 1.0.5 2021-03-05 [1] CRAN (R 4.0.5)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.0.2)
evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.2)
fansi 0.4.2 2021-01-15 [1] CRAN (R 4.0.5)
generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.5)
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.5)
htmltools 0.5.1.1 2021-01-22 [1] CRAN (R 4.0.5)
knitr 1.33 2021-04-24 [1] CRAN (R 4.0.5)
lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.0.4)
magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.5)
pillar 1.6.0 2021-04-13 [1] CRAN (R 4.0.5)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2)
purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.2)
R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.5)
rlang 0.4.11 2021-04-30 [1] CRAN (R 4.0.2)
rmarkdown 2.7 2021-02-19 [1] CRAN (R 4.0.5)
rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.0.5)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.2)
tibble 3.1.1 2021-04-18 [1] CRAN (R 4.0.5)
tidyselect 1.1.1 2021-04-30 [1] CRAN (R 4.0.2)
utf8 1.2.1 2021-03-12 [1] CRAN (R 4.0.5)
vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.0.2)
vitae * 0.4.2 2021-02-17 [1] CRAN (R 4.0.5)
withr 2.4.2 2021-04-18 [1] CRAN (R 4.0.5)
xfun 0.22 2021-03-11 [1] CRAN (R 4.0.4)
yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0)
awesome-cv 模板代码对每个人都应该是相同的,但这里是为了以防万一:
---
name: Marie
surname: Curie
position: "Professor"
address: "School of Physics & Chemistry,Ãcole normale Supérieure"
phone: +1 22 3333 4444
www: mariecurie.com
email: "Marie.Curie@ens.fr"
twitter: mariecurie
github: mariecurie
linkedin: mariecurie
date: "`r format(Sys.time(),'%B %Y')`"
output: vitae::awesomecv
---
```{r setup,include=FALSE}
knitr::opts_chunk$set(echo = FALSE,warning = FALSE,message = FALSE)
library(vitae)
```
# Some stuff about me
* I poisoned myself doing research.
* I was the first woman to win a Nobel prize
* I was the first person and only woman to win a Nobel prize in two different sciences.
# Education
```{r}
library(tibble)
tribble(
~ Degree,~ Year,~ Institution,~ Where,"Informal studies","1889-91","Flying University","Warsaw,Poland","Master of Physics","1893","Sorbonne Université","Paris,France","Master of Mathematics","1894",France"
) %>%
detailed_entries(Degree,Year,Institution,Where)
```
# Nobel Prizes
```{r}
tribble(
~Year,~Type,~Desc,1903,"Physics","Awarded for her work on radioactivity with Pierre Curie and Henri Becquerel",1911,"Chemistry","Awarded for the discovery of radium and polonium"
) %>%
brief_entries(
glue::glue("Nobel Prize in {Type}"),Desc
)
```
# Publications
```{r}
library(dplyr)
knitr::write_bib(c("vitae","tibble"),"packages.bib")
bibliography_entries("packages.bib") %>%
arrange(desc(author$family),issued)
```
我认为使用 MikTex 可能是问题的根源,所以我卸载了它和 tinytex。我重新安装了tinytex,但这并没有解决问题。不过,它确实更改了错误消息:
output file: Awesome.knit.md
Error running filter C:\Users\micha\AppData\Local\Temp\Rtmp65nI7U/multiple-bibliographies.lua:
[string "C:\Users\micha\AppData\Local\Temp\Rtmp65nI7U/..."]:34: attempt to compare string with table
stack traceback:
[string "C:\Users\micha\AppData\Local\Temp\Rtmp65nI7U/..."]:34: in function <[string "C:\Users\micha\AppData\Local\Temp\Rtmp65nI7U/..."]:32>
[string "C:\Users\micha\AppData\Local\Temp\Rtmp65nI7U/..."]:32: in main chunk
Error: pandoc document conversion Failed with error 83
In addition: Warning messages:
1: Detected pandoc version 2.7.2,which may cause issues with bibliography_entries().
Please update pandoc if you have any issues knitting bibliographies (this can be done by updating RStudio).
2: In has_crop_tools() :
Tool(s) not installed or not in PATH: pdfcrop,ghostcript
-> As a result,figure cropping will be disabled.
3: package 'tibble' was built under R version 4.0.5
4: package 'dplyr' was built under R version 4.0.5
Execution halted
解决方法
卸载 MikTex 后重新安装 R Studio,最后安装 R 包 tinytex 的组合工作。
我认为@samcarter_is_at_topanswers.xyz 是正确的,“问题是过时的乳胶版本。utf8 前一段时间成为默认编码,但如果您的 tex 版本较旧,那么此类特殊字符会导致问题。”
经验教训: