Edit:
Desired result can almost be reached, when overriding pagestyle "plain" and using documentclass article.
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[RO,RE]{Header}
\fancyfoot[RO,RE]{\thepage}
}
The problem I am facing no is that the headsep (space between header and table) is greater on the first page. This seems to be because of \maketitle. When removing
$if(title)$
\maketitle
$endif$
from the (default) pandoc template everything works as expected. Imho the same result should also be reachable (without editing the template) but using "title: false" in the yaml-header in my .rmd file. But the "\maketitle" command seems to be there anyways when looking at the generated .tex. Why is that?
Original Question:
I'm trying to turn off the titlepage when creating a pdf using knitr. The document contains a longtable with repeated headers.
I'm expecting a pdf, where all pages have header and footer Information (and headsep) as specified. In the running example below page 1 behaves differently. Attempt to disable titlepage was not successfull.
test.Rmd
---
author: "Fabian"
output: pdf_document
documentclass: report
classoption: notitlepage
params:
testParam: !r data.frame(a = 1:100, b = 2:101)
header-includes:
\usepackage{longtable}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{colorlinks = false}
\usepackage{geometry}
\geometry{a4paper, landscape, left = 13mm, right = 14mm, top = 5mm, bottom = 13mm, includeheadfoot}
\headsep = 5mm
\usepackage{graphicx}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO,RE]{Header}
\fancyfoot[RO,RE]{\thepage}
---
```{r setup, include = F}
library(data.table)
```
\centering
\begin{longtable}{ll}
\hline
```{r createLatexheader, eval = T, echo = F, results = "asis"}
header <- names(data)
latexHaeder <- paste0(paste0(header, collapse = " & "), " \\\\ \n")
cat(latexHaeder)
```
\hline
\endhead
```{r createLatexdata, eval = T, echo = F, results = "asis"}
data <- params$testParam
setDT(data)
data[, ID := .I]
latexData <- data[, .(LATEX = paste0(.SD, collapse = " & ")), by = ID]$LATEX
latexData <- paste0(paste0(latexData, collapse = " \\\\ \n"), " \\\\ \n")
cat(latexData)
```
\end{longtable}
To turn \maketitle
into a no-op, add the following to your header-includes
:
\AtBeginDocument{\let\maketitle\relax}
Even if \maketitle
is executed, this redefinition (delayed until \begin{document}
) will do nothing.
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