Search code examples
rpdflatexr-markdownpandoc

Problem knitting cv templates in the R package vitae


When I knit any of the CV templates in the R package vitae I get a slightly different error for each one. I've made sure that all the files, including my Rmd file, are in the same directory and I haven't changed the template in any way. When I knit the modern CV template, for example, I get this error message:

! 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

When I choose the awesome CV template, the error message is slightly different:

! Undefined control sequence.
<argument> \fontspec_gset_family:Nnn 
                                     \g__fontspec_mathsf_tl { UprightFont = ...
l.123 ^^I\fi

The rest of the error message is the same as above.

I tried updating all my packages. I reinstalled Rtools, pandoc and ghostcript. I made sure that the environment paths were all there and were pointing to the right directory, following this advice

Both errors seem to indicate that I have a problem with some font or symbol in the Rmd or bib files, but that seems unlikely since I made no changes to the templates, so I'm stumped.

I'm a relatively light user of R Markdown so I'd be grateful for some introductory-level advice.

Here is my session info:

- 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)

The awesome-cv template code should be identical for everyone, but here it is just in case:

---
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", "Sorbonne Université", "Paris, 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}"),
    Year, 
    Desc
  )
```

# Publications

```{r}
library(dplyr)
knitr::write_bib(c("vitae", "tibble"), "packages.bib")

bibliography_entries("packages.bib") %>%
  arrange(desc(author$family), issued)
```

I thought using MikTex might be the source of the problem so I unistalled it and tinytex. I reinstalled tinytex, but that didn't resolve the problem. It did change the error message though:

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

Solution

  • A combination of reinstalling R Studio after uninstalling MikTex, and finally installing the R package tinytex worked.

    I think @samcarter_is_at_topanswers.xyz was right that "the problem was an outdated latex version. utf8 became the default encoding some time ago, but if your tex version was older then such special characters would cause problems. "

    Lessons learned:

    1. The tinytex package is all you need for R Markdown. You can even open tex files in R Studio to edit and compile them to pdf. See how to install it here.

    2. Update MikTex frequently. I assumed that it automatically updated when needed, but that seems not to be true. Windows > MikTex > Update. It's that simple. Remembering to do it is another thing if you decide to use it.

    3. Being able to check that the environment paths are all there and are pointing to the right directory didn't help in this case, but it was good to learn. This link was helpful.