title: Package inputenc - Unicode character not set up for use with LaTeX - knitting to pdf wih xelatex fails in RStuio
body: <p>I have an exotic problem with RMarkdown and knitting a pdf. Knitting html and word documents works fine. I'm running RStudio Version 1.2.5033 and TeX 3.14159265 (TeX Live 2019 Gentoo Linux).</p>
  
  <p>I have a file, which among other things recodes user input data. Some user has (God knows how) entered '2⁸' into the data file, and I need to recode this to 2. There are several other SO questions on this topic - for example <a href="https://stackoverflow.com/questions/35715986/package-inputenc-error-error-pandoc-document-conversion-failed-with-error-43?rq=1">Package inputenc Error &amp; Error: pandoc document conversion failed with error 43</a> and <a href="https://stackoverflow.com/questions/32794157/package-inputenc-error-unicode-char-u8-in-rstudio">Package inputenc Error: Unicode char \u8 in RStudio</a>.</p>
  
  <p>The standard advice, to deal with the limits of pdflatex's implementation of Unicode, is to use xelatex, which I'm doing, but it still does not work.</p>
  
  <p>So, first effort - using pdflatex - crashes when knitting a pdf with the message</p>
  
  <pre><code>'! Package inputenc Error: Unicode character ⁸ (U+2078) (inputenc) not set up for use with LaTeX.'
  </code></pre>
  
  <p>Replacing this with xelatex by</p>
  
  <pre><code>output: pdf_document:
      latex_engine: xelatex
  </code></pre>
  
  <p>will produce a pdf, but all the ⁸ are blank. This is not the case when knitting to HTML or Word, and in fact the pdf produced by saving the Word document as a pdf in LibreOffice looks fine, with all the 2⁸ correctly rendered.</p>
  
  <p>The output is 
  [output of running R deleted]</p>
  
  <pre><code>/usr/bin/pandoc +RTS -K512m -RTS LatexTest.utf8.md --to latex 
  --from markdown+autolink_bare_uris+tex_math_single_backslash --output LatexTest.tex
  --self-contained --highlight-style tango --latex-engine xelatex --variable graphics
  --variable 'geometry:margin=1in' --include-in-header
  /tmp/RtmpdLZWBq/rmarkdown-str18dc3dcea436.html 
  
  output file: LatexTest.knit.md
  
  
  Output created: LatexTest.pdf
  Warning message:
  Package xcolor Warning: Incompatible color definition on input line 129.
  Package xcolor Warning: Incompatible color definition on input line 133.
  Package xcolor Warning: Incompatible color definition on input line 133.
  Package xcolor Warning: Incompatible color definition on input line 139.
  Package xcolor Warning: Incompatible color definition on input line 143.
  Package xcolor Warning: Incompatible color definition on input line 143.
  Package xcolor Warning: Incompatible color definition on input line 149.
  Package xcolor Warning: Incompatible color definition on input line 154.
  Package xcolor Warning: Incompatible color definition on input line 154.
  Package xcolor Warning: Incompatible color definition on input line 160.
  Package xcolor Warning: Incompatible color definition on input line 164.
  Package xcolor Warning: Incompatible color definition on input line 164. 
  </code></pre>
  
  <p>The test file, which produces these errors is attached. When running this it claims to be using the xelatex engine.</p>
  
  <pre><code>---
  title: "Latex test"
  author: "Anthony Staines"
  date: "13/04/2020"
  output:
    pdf_document:
      latex_engine: xelatex
    html_document: default
  ---
  ```{r setup, include=FALSE}
  library(knitr)
  library(kableExtra)
  library(tidyverse)
  knitr::opts_chunk$set(echo = TRUE)
  
  cat('2⁸')
  print('2⁸')
  
  Test = ('2⁸')
  cat(Test)
  print(Test)
  
  ## 2⁸
   2⁸
   2⁸
   2⁸
  </code></pre>
  
  <p>Any suggestions? The Latex advice is to add the offending character to the Latex file, which would suit me fine, but I don't know how to give arbitrary Latex commands in Markdown or YAML. In any event, I wonder if this is a bug. It should just work with xelatex.</p>