The pagedreport
package offers a set of custom RMarkdown templates to make attractive PDF reports. These templates can also be customized to match your organization’s branding, including colors, fonts, and a logo. All customization takes place in the YAML header of the template, meaning you never have to mess with HTML or CSS. Everything you need to do in order to make beautiful reports happens right in R.
As an example, here is the YAML header for a special Christmas template made with pagedreport::paged_hazelnuts
.
---
title: "Annual North"
subtitle: "Christmas activity report"
author: "Santa Claus"
date: "December 2020"
output:
pagedreport::paged_hazelnuts:
front_img: "https://images.pexels.com/photos/717988/pexels-photo-717988.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260"
back_img: "https://images.pexels.com/photos/3303615/pexels-photo-3303615.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
logo: "https://www.flaticon.com/svg/static/icons/svg/268/268225.svg"
img_to_dark: TRUE
logo_to_white: TRUE
knit: pagedown::chrome_print
toc-title: "Table of Contents"
main-color: "#E40A2D"
secondary-color: "#00873E"
google-font: TRUE
main-font: "Raleway"
header-font: "Mountains of Christmas"
---
The YAML has four main sections
The first section (title
, subtitle
, author
and date
) includes arguments that will be familiar to all RMarkdown users.
The second sections selects the template to use and relevant arguments. All arguments related to images (e.g. images on the front and back cover) and logo are in this section
The third section is knit: pagedown::chrome_print
, which is how we get our PDF output.
The last section provides several arguments to customize colors and fonts.
For all three templates, you can change the colors and the fonts using main-color
, secondary-color
, which do what they say on the tin.
The google-font
argument, if set to TRUE, enables you to use any font from Google Fonts (if you set google-font
to FALSE, you can also use fonts you have on your local computer). The main-font
argument sets the font for elements such as paragraph text. The header-font
argument sets the font for headers.
The three templates have also have unique arguments, outlined below.
paged_windmill
Here you can use a logo and a cover image with the logo
and front_img
arguments of the paged_windmill
function.
If you want to darken the image, use img_to_dark: TRUE
. This will help make the text on top of it easier to read.
You can also add logo_to_white: TRUE
to transform your logo into a white version. This is helpful if the cover image is dark and you want to make sure your logo is visible. Please note this only works if your logo is in SVG format.
paged_grid
This template uses a logo using the logo
argument, but does not have a cover image so img
is unnecessary.
paged_hazelnuts
This template is the most complex of three. In addition to setting the cover image with front_img
, you can also set an image to go on the back cover the with back_img
argument. This template also has a table of contents included, which can be disabled using the toc
argument under output.
You can see more results in the gallery issue on Github.