title: knitr + LaTeX (Rnw file) compiles in TeXShop but fails with UTF-8 error in RStudio
body: <p>On the same machine the knitr + LaTeX compilation of the Rnw file below fails in RStudio with <code>Invalid UTF-8 byte &quot;97</code> LaTeX error; but compiles with TexShop. Here is the source code:</p>
  <pre><code>\documentclass[nobib,notoc,nofonts]{tufte-book}
  
  \usepackage{authorindex}
  \usepackage[nohints]{minitoc}
  
  \renewcommand{\Rcolor}{\color{black}}
  \renewcommand{\Rbackground}{\color[RGB]{253, 246 ,228}}
  \renewcommand{\Routbackground}{\color[RGB]{228, 246, 253}}
  \renewcommand{\Sweavesize}{\footnotesize}
  \definecolor{stringColor}{RGB}{237, 121, 83}
  \definecolor{commentColor}{RGB}{204, 70, 120}
  \definecolor{linkColor}{RGB}{13, 8, 135}
  \definecolor{keywordColor}{RGB}{93, 1, 166}
  \usepackage{listings}
  \lstset{
      language = R,
      breaklines = TRUE,
      frame = single,
      numbers = left,
      numberstyle = \scriptsize,
      numbersep = 5pt,
      framesep = 1pt,
      rulesepcolor=\color{gray},
      rulecolor=\color{black},
          stepnumber = 2,
      firstnumber = 1,
      stringstyle = \color{stringColor},
      commentstyle = \color{commentColor},
      keywordstyle = \color{keywordColor}
  }
  
  &lt;&lt;setup, include = FALSE, cache = FALSE&gt;&gt;=
  opts_chunk$set(
      fig.path = 'figure/listings-',
      tidy = TRUE,
      tidy.opts = list(
          blank = FALSE,
          collapse = TRUE,
          arrow = TRUE,
          indent = 2,
          width.cutoff = 60,
          tidy_eval = TRUE
      )
  )
  render_listings()
  require(tidyverse)
  @
  
  \begin{document}
  
  &lt;&lt;iq&gt;&gt;=
  iq &lt;- c(129, 112, 114, 126, 104, 112, 101, 99, 93)
  iq
  iq &lt;- as_tibble(iq)
  iq
  @
  &lt;&lt;sess&gt;&gt;=
  sessionInfo()
  @
  \end{document}
  
  </code></pre>
  <p>Note: It's not clear to me why this doesn't compile without the lines</p>
  <blockquote>
  <p>\usepackage{authorindex}</p>
  <p>\usepackage[nohints]{minitoc}</p>
  </blockquote>
  <p>since they seem irrelevant to the issue</p>
  <p>Here is an image of the output from TeXShop:</p>
  <p><a href="https://i.stack.imgur.com/kYhdR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kYhdR.jpg" alt="output of compilation with TeXShop" /></a></p>