0

I have been using RMarkdown via R Studio to render PDF for a while but suddenly it failed to render PDF with the following error. Instead of PDF, it render a .tex file which I'm unsure why.

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Question-10.2-and-3---RMD --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output Question-10.2-and-3---RMD.tex --lua-filter "C:\Users\hangt\OneDrive\Documents\R\win-library\4.1\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\hangt\OneDrive\Documents\R\win-library\4.1\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --variable "geometry:margin=1in" 
! Package inputenc Error: Unicode character € (U+0080)
(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 Question-10.2-and-3---RMD.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See Question-10.2-and-3---RMD.log for more info.
Execution halted

Sorry if the way I describe the issue is vague.

Thanks.

4
  • Welcome to TeX.SE! Can you please show the resulting TeX code?
    – Mensch
    Oct 14, 2021 at 23:59
  • Sorry for my beginner question. How should I show the resulting TeX code? what is the best way to do it? Oct 15, 2021 at 0:07
  • Copy the TeX code and paste it into your question, but delete personal informations!
    – Mensch
    Oct 15, 2021 at 0:20
  • 1
    It looks like your Rmarkdown file contains the euro symbol, which LaTeX cannot understand. Try loading the textcomp package, or see tex.stackexchange.com/a/9868/24974
    – erik
    Oct 15, 2021 at 1:24

1 Answer 1

0

Welcome to TeX.SE. Your document has a Euro symbol, which can not be compiled by pdflatex. There are several possible ways to fix this. Assuming you are writing an Rmarkdown document, you can add any one of these to the document header:

  1. \usepackage{eurosym}
  2. \usepackage{textcomp}
  3. \DeclareUnicodeCharacter{20AC}{\euro}

Alternatively, you can compile your .Rmd file with xelatex in RStudio by going to Tools > Global Options > Sweave and in Typeset LaTeX into PDF using: choose XeLaTeX.

Here is a MWE that uses the eurosym package, which can be compiled with pdflatex.

---
title: "TeX.SE"
output: pdf_document
header-includes: 
  - \usepackage{eurosym}
---

The book is 10 \euro.

The book is \euro 10.

The book is \EUR{10}.

enter image description here

2
  • Thank you very much. I tried to change from pdflatex to XeLaTex but the document still couldn't be compiled. I have not tried changing the header yet so I just removed the symbols which were just erroneous symbols. The issue cleared up now. Thanks Oct 15, 2021 at 15:15
  • @Grace_radetsk XeLaTeX should allow compiling the file with a U+0080, but most probably will show only empty space or just a box, since many fonts have not a glyph for U+00080. However, the U+20AC (€), that moreover is available in some keyboards, today will not produce problems even with pdflatex and the default font. The only disadvantage is that is not the official euro symbol, but you can force to type \euro instead of U+20AC, as showed in the answer, i.e., without using that command in the text.
    – Fran
    Oct 16, 2021 at 9:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .