rticles icon indicating copy to clipboard operation
rticles copied to clipboard

MDPI does not compile with the xelatex and lualatex engines (Undefined control sequence)

Open kayaulai opened this issue 3 years ago • 2 comments

The MDPI option does not compile with the xelatex and lualatex engines. This makes it difficult to use Chinese characters or other UTF8 characters since those are not supported by pdflatex.

Example:

---
title: "Title"
output:
 rticles::mdpi_article:
  latex_engine: xelatex
---

Hello world!

Creates the error:

! Undefined control sequence.
\set@color ->\pdfcolorstack 
                            \@pdfcolorstack push{\current@color }\aftergroup...
l.1462 \color{black}

Error: LaTeX failed to compile [filename].tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See paper_v6.log for more info.
Execution halted

xfun::session_info():

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000), RStudio 2022.7.1.554

Locale:
  LC_COLLATE=Chinese (Traditional)_Hong Kong SAR.utf8  LC_CTYPE=Chinese (Traditional)_Hong Kong SAR.utf8    LC_MONETARY=Chinese (Traditional)_Hong Kong SAR.utf8 LC_NUMERIC=C                                        
  LC_TIME=Chinese (Traditional)_Hong Kong SAR.utf8    

Package version:
  base64enc_0.1.3  bslib_0.4.0      cachem_1.0.6     digest_0.6.29    evaluate_0.15    fastmap_1.1.0    fs_1.5.2         glue_1.6.2       graphics_4.2.0   grDevices_4.2.0  highr_0.9        htmltools_0.5.3  jquerylib_0.1.4 
  jsonlite_1.8.0   knitr_1.39.6     magrittr_2.0.3   memoise_2.0.1    methods_4.2.0    R6_2.5.1         rappdirs_0.3.3   rlang_1.0.4      rmarkdown_2.14.3 sass_0.4.2       stats_4.2.0      stringi_1.7.8    stringr_1.4.0   
  tinytex_0.40     tools_4.2.0      utils_4.2.0      xfun_0.31        yaml_2.3.5      

Pandoc version: 2.18

paper_v6.log


By filing an issue to this repo, I promise that

  • [x] I have fully read the issue guide at https://yihui.name/issue/.
  • [x] I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rticles'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/rticles').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • [x] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

kayaulai avatar Aug 07 '22 21:08 kayaulai

I believe the issue comes from the mdpi.cls - do we know if this is compatible with xelalex or lualatex in the first place ?

The rticles format is based on template found it: https://www.mdpi.com/authors/latex

I think our template hardcode some config that we could remove https://github.com/rstudio/rticles/blob/43b93aa773484564beb2332cd14b83af40f5571a/inst/rmarkdown/templates/mdpi/resources/template.tex#L5 and

https://github.com/rstudio/rticles/blob/main/inst/rmarkdown/templates/mdpi/resources/template.tex#L40-L43

But even if we remove that, we get another issue with xelatex

Warning: Package inputenc Warning: inputenc package ignored with utf8 based engines.
Warning: Package epstopdf Warning: Drivers other than `pdftex' and `luatex' are not supported.

However, it seems to compile.

Just pinging @dleutnant as he is the contributor of this template.

cderv avatar Aug 23 '22 16:08 cderv

Also there is one PR to update the template in https://github.com/rstudio/rticles/pull/381 which is missing contribution.

Maybe this template needs a greater rewrite. If anyone wants to jump in ! Thanks

cderv avatar Aug 23 '22 16:08 cderv

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

github-actions[bot] avatar Oct 23 '23 03:10 github-actions[bot]