[Tex/LaTex] Math mode in document title with R Markdown


I was trying to put $\LaTeX$ in the document title but can't find a way to do so. I suppose that this is because I can't use latex packages with the document title. Does anyone know how to solve this?

Here's what I have:

title: "Welcome to $\LaTeX$ Workshop"
  citation_package: natbib
  number_sections: yes
  link-citations: yes
bibliography: sample.bib
classoption: twocolumn
  - \usepackage{lscape}
  - \usepackage[english]{babel}
  - \usepackage{multicol}
  - \setlength{\columnsep}{1cm}
  - \setlength{\parindent}{1cm} # paragraph indentation
  - \setlength{\parskip}{8pt} # paragraph spacing
  - \usepackage{setspace}
  - \doublespacing

The error I'm getting looks like this:

! Package inputenc Error: Unicode char 
(inputenc)                not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.

l.96 \maketitle

Try running pandoc with --latex-engine=xelatex.
pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
Execution halted

Thanks in advance!

Best Answer

enter image description here

You need to escape the backslash using

title: "Welcome to \\LaTeX{} Workshop"

Or you can use a work-around:

title: "Welcome to LaTeX Workshop"
  - \title{Welcome to \LaTeX{} Workshop}

The above approach removes all formatting from the title and resets it via the traditional way using \title after pandoc's \title insertion. This effectively overwrites it without the processing used by pandoc.