Search code examples
rstudior-markdownknitrbeamer

an encoding issue while generating beamer slides in rmarkdown


I am testing to generate Beamer presentations using Rmarkdown in Rstudio. Everything works fine, but an error below appears and fail to generate Beamer slides when a few Korean words are added into the code. Generating html(ioslides, slidy) works fine with the Korean words, but only converting to Beamer presentation encounters the error.
I searched some posts and tested suggested solutions, but none of them worked; Neither saving the file with UTF-8 encoding nor adding the code below works.

latex_engine: xelatex

My OS is Windows 10 which is set to Korean. Any comments would be appreciated.

---
title: "Habits"
author: "John Doe"
date: "March 22, 2005"
output:
  beamer_presentation: default
encoding: UTF-8
---

# 오전 

## Getting up

- Turn off alarm
- Get out of bed

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS 1-example.utf8.md --to beamer --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output 1-example.tex --highlight-style tango --latex-engine pdflatex --self-contained output file: 1-example.knit.md

! Package inputenc Error: Unicode character 오 (U+C624) (inputenc)
not set up for use with LaTeX.

Error: Failed to compile 1-example.tex. See 1-example.log for more info. In addition: Warning message: In grepl("==> Fatal error occurred", x[i], fixed = TRUE) : input string 1 is invalid in this locale Execution halted


Solution

  • latex_engine is an argument of beamer_presentation (see Section 3.3.7.1 of the R Markdown book).

    ---
    title: "Habits"
    author: "John Doe"
    date: "March 22, 2005"
    header-includes:
      - \usepackage{kotex-utf}
    output:
      beamer_presentation:
        latex_engine: xelatex
    ---
    
    # 오전 
    
    ## Getting up
    
    - Turn off alarm
    - Get out of bed
    

    The encoding option in your example is not meaningful to either Pandoc ro rmarkdown.