title: Converting Rmarkdown to PDF without RStudio
body: <p>I would like to convert a <code>*.Rmd</code> to document to PDF <strong><em>without</em></strong> <a href="/questions/tagged/rstudio" class="post-tag" title="show questions tagged &#39;rstudio&#39;" rel="tag">rstudio</a> being available. </p>
  
  <h1>Current approach</h1>
  
  <p>Current approach follows the following steps:</p>
  
  <ol>
  <li><code>*.Rmd</code> document is passed to <code>knitr</code>: <strong><code>knit(input = "report.Rmd"))</code></strong></li>
  <li><p>Obtained md is converted via pandoc:</p>
  
  <pre><code># Convert
  pandoc --smart --to latex \
         --latex-engine pdflatex \
         -s report.md \
         -o report.PDF
  </code></pre></li>
  </ol>
  
  <h2>Problems</h2>
  
  <p>This results in the following problems, the top section of the <em>Rmarkdown</em> document:</p>
  
  <pre><code>---
  title:  "Report Title"
  author: "Person"
  output: pdf_document
  classoption: landscape
  ---
  </code></pre>
  
  <p>and shows as:</p>
  
  <p><a href="https://i.stack.imgur.com/EodQF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EodQF.png" alt="top document section"></a></p>
  
  <p>all text is centered, whereas I would like for it to be left-aligned:</p>
  
  <p><a href="https://i.stack.imgur.com/wBYdy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wBYdy.png" alt="no-left aligned"></a></p>
  
  <h1>Possible approach</h1>
  
  <p>I would like to make use of the <a href="https://cran.r-project.org/web/packages/rmarkdown/rmarkdown.pdf" rel="nofollow noreferrer"><strong><code>rmarkdown::render</code></strong></a>; however, despite setting <code>RSTUDIO_PANDOC</code> (as discussed <a href="https://stackoverflow.com/a/35936806/1655567">here</a>), the command fails on <code>pandoc</code> not being available.</p>
  
  <h1>Desired outcome</h1>
  
  <p>I don't care much whether the utilised mechanism makes use of the <code>rmarkdown::render</code>, what I want to achieve is:</p>
  
  <ul>
  <li>Landscape page layout across all pages</li>
  <li>Left-aligned text</li>
  <li>Ability to exercise minimum control over the document by controlling default fonts</li>
  </ul>
  
  <hr>
  
  <ul>
  <li><em>Ideally, I would like to do as much as in the <code>*.Rmd</code> file as possible without the need to add parameters to the <code>pandoc</code> command.</em></li>
  </ul>
  
  <h1>Updates, following comments</h1>
  
  <ul>
  <li>I'm working on Linux and pandoc is installed, I can execute <code>pandoc</code> command pass files and generate exports with no problems. It only doesn't work with the <code>rmarkdown::render</code> package.</li>
  <li>Concerning the hooks and <code>*.Rmd</code> files, this is what I'm trying to understand as I see that that the first section of my <code>*.Rmd</code> file is ignored. The current process looks as follows:
  
  <ul>
  <li><strong><code>*.Rmd</code></strong> (not much in it, just title section and dummy text and code that renders but wrongly justified) <strong>></strong> </li>
  <li><strong><code>*.R</code></strong> file running one line <code>knit(input = "report.Rmd"))</code> <strong>></strong></li>
  <li><strong><code>*.sh</code></strong> file running <code>pandoc</code> command and generating PDF</li>
  </ul></li>
  </ul>
  
  <h2>Concerning:</h2>
  
  <blockquote>
    <p>if all that is in place, it is indeed just a call to
    <code>rmarkdown::render(...)</code></p>
  </blockquote>
  
  <p>The <code>rmarkdown::render(...)</code> fails:
  <code>Error: pandoc version 1.12.3 is required and was not found ...</code>
  However:</p>
  
  <pre><code>&gt;&gt; rmarkdown::pandoc_available()
  [1] TRUE
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>$ pandoc -v
  pandoc 1.9.4.1 (...)
  </code></pre>
  
  <p>The <code>RSTUDIO_PANDOC</code> points to pandoc.</p>