<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/creating-pretty-documents-with-the-prettydoc-package/"></div></div><div><a data-url="https://www.r-bloggers.com/creating-pretty-documents-with-the-prettydoc-package/" data-counturl="https://www.r-bloggers.com/creating-pretty-documents-with-the-prettydoc-package/" data-count="horizontal" data-text="Creating Pretty Documents with the prettydoc Package" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://statr.me/2016/08/creating-pretty-documents-with-the-prettydoc-package/"> Yixuan's Blog - R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<blockquote>
<p>Have you ever tried to find a lightweight yet nice theme for the R Markdown<br>
documents, like <a target="_blank" href="http://yixuan.cos.name/prettydoc/cayman.html">this page</a>?</p>
</blockquote>
<h1>Themes for R Markdown</h1>
<p>With the powerful <a target="_blank" href="http://rmarkdown.rstudio.com/index.html">rmarkdown</a><br>
package, we could easily create nice HTML document<br>
by adding some meta information in the header, for example</p>
<div>
<pre><code><span>---</span>
<span>title</span><span>:</span> <span>Nineteen Years Later</span>
<span>author</span><span>:</span> <span>Harry Potter</span>
<span>date</span><span>:</span> <span>July 31, 2016</span>
<span>output</span><span>:</span>
  <span>rmarkdown::html_document</span><span>:</span>
    <span>theme</span><span>:</span> <span>lumen</span>
<span>---</span>
</code></pre>
</div>
<p>The <a target="_blank" href="http://rmarkdown.rstudio.com/html_document_format.html">html_document</a><br>
engine uses the <a target="_blank" href="http://bootswatch.com/">Bootswatch</a><br>
theme library to support different styles of the document.<br>
This is a quick and easy way to tune the appearance of your document, yet with<br>
the price of a large file size (> 700KB) since the whole<br>
<a target="_blank" href="http://getbootstrap.com/">Bootstrap</a> library needs to be packed in.</p>
<p>For package vignettes, we can use the<br>
<a target="_blank" href="http://rmarkdown.rstudio.com/package_vignette_format.html">html_vignette</a><br>
engine to generate a more lightweight HTML file that is meant to minimize the<br>
package size, but the output HTML is less stylish than the <code>html_document</code> ones.</p>
<p>So can we do <strong>BOTH</strong>, a lightweight yet nice-looking theme for R Markdown?</p>
<h1>The prettydoc Engine</h1>
<p>The answer is YES! (At least towards that direction)</p>
<p>The <a target="_blank" href="https://github.com/yixuan/prettydoc/">prettydoc</a> package<br>
(available on <a target="_blank" href="http://cran.r-project.org/package=prettydoc">CRAN</a>)<br>
provides an alternative engine, <code>html_pretty</code>,<br>
to knit your R Markdown document into pretty HTML pages.<br>
Its usage is extremely easy: simply replace the<br>
<code>rmarkdown::html_document</code> or <code>rmarkdown::html_vignette</code> output engine by<br>
<code>prettydoc::html_pretty</code> in your R Markdown header, and use one of the built-in<br>
themes and syntax highlighters. For example</p>
<div>
<pre><code><span>---</span>
<span>title</span><span>:</span> <span>Nineteen Years Later</span>
<span>author</span><span>:</span> <span>Harry Potter</span>
<span>date</span><span>:</span> <span>July 31, 2016</span>
<span>output</span><span>:</span>
  <span>prettydoc::html_pretty</span><span>:</span>
    <span>theme</span><span>:</span> <span>cayman</span>
    <span>highlight</span><span>:</span> <span>github</span>
<span>---</span>
</code></pre>
</div>
<p>You can also create documents from <strong>prettydoc</strong> templates in RStudio (after<br>
installing the package).</p>
<p><strong>Step 1:</strong> Click the “New File” button and choose “R Markdown”.</p>
<div align="center">
<img alt="Step 1" src="https://i0.wp.com/yixuan.cos.name/prettydoc/images/step1.png?w=456" data-recalc-dims="1">
</div>
<p><strong>Step 2:</strong> In the “From Template” tab, choose one of the built-in templates.</p>
<div align="center">
<img alt="Step 2" src="https://i2.wp.com/yixuan.cos.name/prettydoc/images/step2.png?w=456" data-recalc-dims="1">
</div>
<h1>Options and Themes</h1>
<p>The options for the <code>html_pretty</code> engine are fully compatible with the default<br>
<code>html_document</code><br>
(see the <a target="_blank" href="http://rmarkdown.rstudio.com/html_document_format.html">documentation</a>)<br>
with two exceptions:</p>
<ol>
<li>The <code>theme</code> option can take value from <code>cayman</code>, <code>tactile</code> and<br>
<code>architect</code>. More themes will be added in the future. The themes contained in<br>
<strong>prettydoc</strong> are much inspired by and modified from<br>
various <a target="_blank" href="https://github.com/blog/1081-instantly-beautiful-project-pages">Github page themes</a>.</li>
<li>The <code>highlight</code> options takes value from <code>github</code> and <code>vignette</code>.</li>
</ol>
<h1>Gallery</h1>
<p>Here are some screenshots of the HTML pages generated by <strong>prettydoc</strong> with<br>
different themes and syntax highlighters.</p>
<div align="center">
<h2>Cayman <a target="_blank" href="http://yixuan.cos.name/prettydoc/cayman.html">(demo page)</a></h2>
<p> <a target="_blank" href="http://yixuan.cos.name/prettydoc/cayman.html"><br>
<img alt="Cayman Theme" src="https://i1.wp.com/yixuan.cos.name/prettydoc/images/cayman.png?w=456" data-recalc-dims="1"><br>
</a>
</div>
<div align="center">
<h2>Tactile <a target="_blank" href="http://yixuan.cos.name/prettydoc/tactile.html">(demo page)</a></h2>
<p> <a target="_blank" href="http://yixuan.cos.name/prettydoc/tactile.html"><br>
<img alt="Tactile Theme" src="https://i0.wp.com/yixuan.cos.name/prettydoc/images/tactile.png?w=456" data-recalc-dims="1"><br>
</a>
</div>
<div align="center">
<h2>Architect <a target="_blank" href="http://yixuan.cos.name/prettydoc/architect.html">(demo page)</a></h2>
<p> <a target="_blank" href="http://yixuan.cos.name/prettydoc/architect.html"><br>
<img alt="Architect Theme" src="https://i1.wp.com/yixuan.cos.name/prettydoc/images/architect.png?w=456" data-recalc-dims="1"><br>
</a>
</div>
<p>If you think this package is helpful, feel free to leave comments or<br>
request features in the <a target="_blank" href="https://github.com/yixuan/prettydoc/">Github repository</a>.<br>
Contribution and pull requests are always welcome.</p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/creating-pretty-documents-with-the-prettydoc-package/"></div></div><div><a data-url="https://www.r-bloggers.com/creating-pretty-documents-with-the-prettydoc-package/" data-counturl="https://www.r-bloggers.com/creating-pretty-documents-with-the-prettydoc-package/" data-count="vertical" data-text="Creating Pretty Documents with the prettydoc Package" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://statr.me/2016/08/creating-pretty-documents-with-the-prettydoc-package/"> Yixuan's Blog - R</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/4Zx1cJZBt4M"></a></div>