
Moving parts:
- The input code
- The options given to
pandoc
for conversion, via tex
to pdf
- The use of a UTF-8 font that supports the Greek and math symbols, which may have to be specified
Even in the tex file used to generate the image, there's a slight misstatement about direct Unicode. What was actually entered was ȃ ≅Ŷ, but the rendering dropped the ≅symbol.
I think you have two additional unpalatable choices in addition to the one you identified, which isn't actually that bad given that stringr
handles Unicode pretty well:
-
Run your Rmd files from the command line and call knitr
with your own pandoc
flags, which basically means reverse engineering from a tex
that outputs what you want.
-
Edit the tex
files, but no one is that masochistic.
Here's the tex
file I used:
% Input to XeLaTeX is full Unicode, so Unicode characters can be typed directly into the source.
\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{amssymb}
\newfontfamily\unicodefont{Lucida Grande}
\title{Greek unicode in R Markdown}
\author{Richard Careaga}
%\date{}
\begin{document}
\maketitle
we get the coefficients (*β*~*i*~) raw (in your example)
we get the coefficients (\emph{β}\textsubscript{\emph{i}}) after plain pandoc conversion
or we get ($\beta \thicksim i$) in native tex, with XeLaTeX engine, but not pdflatexmk
Here is some direct Unicode: ȃ ≅Ŷ in the tex file
\end{document}
Oh, one other thing. \tilde positions atop the preceding character, you need \thicksim for a standalone.