title: pandoc: Error producing PDF
body: <p><strong>Goal</strong>
  Implementing a PDF function (a button on the webpage) that produces a PDF containing plots created by R that are shown on the webpage with markdown/knitr as shown in this tutorial: <a href="http://rprogramming.net/create-html-or-pdf-files-with-r-knitr-miktex-and-pandoc/" rel="nofollow noreferrer">http://rprogramming.net/create-html-or-pdf-files-with-r-knitr-miktex-and-pandoc/</a> </p>
  
  <p><strong>Setup</strong></p>
  
  <ul>
  <li>Ubuntu server</li>
  <li>Installed MiKTeX for Ubuntu:</li>
  </ul>
  
  <blockquote>
    <p>sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys
    D6BC243565B2087BC3F897C9277A7293F59E4889</p>
    
    <p>echo "deb <a href="http://miktex.org/download/ubuntu" rel="nofollow noreferrer">http://miktex.org/download/ubuntu</a> xenial universe" | sudo
    tee /etc/apt/sources.list.d/miktex.list</p>
    
    <p>sudo apt-get update</p>
    
    <p>sudo apt-get install miktex</p>
  </blockquote>
  
  <ul>
  <li>Installed Pandoc</li>
  </ul>
  
  <p><strong>R-code</strong></p>
  
  <pre><code># Set working directory
  setwd("/var/www/html/test_Knitr")
  
  # Create .md, .html, and .pdf files
  print("Debug1: packages loaded")
  
  setwd("/var/www/html/DATA/test")
  knit("/var/www/html/test_Knitr/reporting_style.Rmd")
  print("Debug2: knit succesfull")
  
  setwd("/var/www/html/DATA/test")
  print("Debug3: setwd successfull")
  
  markdownToHTML('/var/www/html/DATA/test/reporting_style.md', '/var/www/html/DATA/test/reporting_style.html', options=c("use_xhml"))
  print("Debug4: markdownToHTML succesfull")
  
  system("pandoc -s /var/www/html/DATA/test/reporting_style.html -o /var/www/html/DATA/test/reporting_style.pdf")
  print("Debug5: pandoc succesfull")
  </code></pre>
  
  <p><strong>reporting_style.Rmd</strong></p>
  
  <pre><code>---
  title: "Reporting template"
  output: html_document
  ---
  
  
  ## R Markdown
  
  This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. 
  </code></pre>
  
  <p><strong>Problem</strong>
  The function runs perfectly until it reaches the last part <code>system("pandoc.."</code>
  Here I receive an error message:</p>
  
  <pre><code>Sorry, but pdflatex did not succeed.
  
  You may want to visit the MiKTeX project page, if you need help.
  terminate called after throwing an instance of 'MiKTeX::Core::MiKTeXException'
    what():  MiKTeX encountered an internal error.
  
  pandoc: Error producing PDF
  </code></pre>
  
  <p><strong>Question</strong>
  I have been looking all over the internet, not able to find a solution for this error. </p>