LaTeX Error: Invalid UTF-8 byte sequence in R Sweave

702 Views Asked by At

I'm new using Sweave in R. All guides I've seen begin trying to compile to PDF the simplest document (code below):

\documentclass[10pt, a4paper]{article}

\title{My title}
\author{Some text with accent, e.g. í}

\begin{document}
\SweaveOpts{concordance=TRUE}

\maketitle

\end{document}

The problem is that this doesn't work directly for me. I receive the following error message:

Error: LaTeX failed to compile C:/Users/V1/Desktop/Projects/Projects2/teste.tex. 
See https://yihui.org/tinytex/r/#debugging for debugging tips.
Execução interrompida
failed

Error: teste.tex:12: LaTeX Error: Invalid UTF-8 byte sequence (�\endtabular).
Error: teste.tex:  ==> Fatal error occurred, no output PDF file produced!

The issue appears to be encoding related. I've tried % \usepackage[utf8]{inputenc}without success. The solution that worked was use % \UseRawInputEncoding at the beginning.

My questions are: why did this happen? Is it safe to continue builduing the document? What am I supposed to do to obtain the desired result without putting this line code at the beginning? Thanks in advance!

0

There are 0 best solutions below