Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a footer for every page using R markdown

I'm writing a document in R Markdown and I'd like it to include a footer on every page when I knit a PDF document. Does anyone have any idea on how to do this?

like image 710
n8sty Avatar asked Aug 15 '14 15:08

n8sty


People also ask

How do you add a footnote in R Markdown?

To create a footnote in R Markdown, you use the carrot ^ followed immediately by square brackets []. Put the text inside of the [] and it'll print that at the bottom of the page. Code for a footnote will look like this: ^[This sentence will be printed as a footnote.] .

How do I put a footer on every page in LaTeX?

To get a separate footer line for each chapter, you should omit the command \fancyfoot[RE,LO]{Message of the day} from the preamble and, instead, issue the command \fancyfoot[RE,LO]{Message for Chapter xx} immediately after the respective \chapter command.

How do I add a header in RMarkdown?

We can insert headings and subheadings in R Markdown using the pound sign # . There are six heading/subheading sizes in R Markdown. The number of pound signs before your line of text determines the heading size, 1 being the largest heading and 6 being the smallest.

How do I add page numbers in R Markdown?

Page numbering is straightforward. You can use \pagenumbering{gobble} for pages without numbering, \pagenumbering{roman} for roman page numbering and \pagenumbering{arabic} for normal page numbering. Just include the argument wherever you want the have the page numbering changed.


1 Answers

Yes, this question has been asked and answered here: Adding headers and footers using Pandoc. You just need to sneak a little LaTeX into the YAML header of your markdown document.

This markdown header does the trick:

--- title: "Test" author: "Author Name" header-includes: - \usepackage{fancyhdr} - \pagestyle{fancy} - \fancyhead[CO,CE]{This is fancy header} - \fancyfoot[CO,CE]{And this is a fancy footer} - \fancyfoot[LE,RO]{\thepage} output: pdf_document --- 

Works for me with an Rmd file in RStudio Version 0.98.1030 for Windows.

like image 127
Ben Avatar answered Sep 26 '22 14:09

Ben