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?
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.] .
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With