Rmarkdown: knit PDF to look exactly like HTML

Viewed 2240

When declaring output format in YAML section of my Rmarkdown document, is there a way to make sure it knits to PDF, but looks like a knitted HTML?

Nothing about knitted PDF looks the same: the font is some flavor of serif (assume I can change that), blockquotes and code chunks look different.

I like knitted HTML and the look, but is there a way to generate a PDF looking exactly the same?

As an example, just a simple default sample code:

---
title: "Untitled"
output:
  html_document: default
  pdf_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

> This is a quote

This is a link: <http://rmarkdown.rstudio.com>

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

Here are 2 samples how 2 outputs look out of the box

HTML

PDF

0 Answers
Related