How to arrange HTML Widgets inside of a RMarkdown Document (PDF, HTML)
<p>I'm working in a <a href="http://rmarkdown.rstudio.com/r_notebooks.html" rel="noreferrer">R notebook</a> and would like use it to create two ouptuts: an HTML document and PDF document.</p>

<p>My analysis includes leaflet maps (html widgets), which is <strong>causing problems when I knit the notebook to a PDF document</strong>. Thanks to the <a href="https://github.com/wch/webshot" rel="noreferrer"><code>webshot</code></a> function now included in the <code>knitr</code> package, "knitr will try to generate static screenshots for HTML widgets automatically using the webshot package" (<a href="https://github.com/yihui/knitr/blob/master/NEWS.md" rel="noreferrer">https://github.com/yihui/knitr/blob/master/NEWS.md</a>).</p>

<p>This works fine when my output is a series of leaflet maps stacked on top of each other, but I would like to group the maps together in a more concise row arrangement (see image below).</p>

<p><a href="https://i.stack.imgur.com/Mh1CO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Mh1CO.png" alt="screenshot"></a></p>

<p>Here's a reproducible example of my R notebook: <a href="https://gist.github.com/tiernanmartin/0fd957e0a22cfa533886c35b8a2e9e0d" rel="noreferrer">gist</a></p>

<p>Unfortunately, when I try to knit this to a PDF document I get the following error message:</p>

<pre><code>Error: Functions that produce HTML output found in document targeting latex output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:

  always_allow_html: yes

Note however that the HTML output will not be visible in non-HTML formats.
</code></pre>

<p>How can I get this single-row arrangement in a PDF document?</p>