title: How to force Tikz in RMarkdown document to show cyrillic text?
body: <p>Below is my experimental RMarkdown document (named <em>tikz-cyrillic.Rmd</em>):</p>
  
  <pre><code>---
  title: "TikZ cyrillic test"
  output:
    pdf_document:
      keep_tex: yes
      latex_engine: xelatex
      dev: tikz
    html_document: default
    word_document: default
  ---
  
  ```{r,engine='tikz', fig.ext = if (knitr:::is_latex_output()) 'pdf' else 'svg'}
  \begin{tikzpicture}
  \path (0,0) node
  (x) {Hello World!}
  (3,1) node[circle,draw](y) {$\int_1^2 x \mathrm d x$};
  \draw[-&gt;,blue]
  (x) -- (y);
  \draw[-&gt;,red]
  (x) -| node[near start,below] {мир!} (y);
  \draw[-&gt;,orange] (x) .. controls +(up:1cm) and +(left:1cm) .. node[above,sloped] {Привет} (y);
  \end{tikzpicture}
  ```
  </code></pre>
  
  <p>It is based on example <a href="http://ctan.altspu.ru/graphics/pgf/base/doc/pgfmanual.pdf" rel="noreferrer">from 17.11 of pgfmanual.pdf</a>.</p>
  
  <p>Gummi using <em>TeXLive with XeTeX</em> with simple preamble </p>
  
  <pre><code>\usepackage[main=russian,english]{babel}
  \usepackage{fontspec}
  \setmainfont[Ligatures={TeX,Historic}]{Times New Roman}
  </code></pre>
  
  <p>gives me the following output:</p>
  
  <p><a href="https://i.stack.imgur.com/uhvC5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uhvC5.png" alt="Gummi output"></a></p>
  
  <p>You can test it <a href="https://www.overleaf.com/18355262mgjnkvvhvnby" rel="noreferrer">in OverLeaf</a>.</p>
  
  <p>But in RStudio I can't understand where should I enter preamble for TikZ device, so I have wrong output (HTML as example):</p>
  
  <p><a href="https://i.stack.imgur.com/3BerJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3BerJ.png" alt="RStudio HTML-output"></a></p>
  
  <p>What should I change in RMarkdown document to get correct output in TikZ diagram?</p>
  
  <p>I need the same image appearance for HTML, PDF and Word document (docx).</p>
  
  <p>Note: I'm using Gummi and RStudio 1.1.456 on Ubuntu 16.04 LTS with TeXLive 2015 if it matters.</p>