Reputation: 79
I have a PDF design with cool colors that I want to use for my R Markdown output.
I asked Chat GPT and is still not working.
In the YAML header I have
---
title: "My Report"
author: "Truancer"
date: "`r Sys.Date()`"
output:
pdf_document:
includes:
in_header: "template.tex"
---
In the template.text I have:
\usepackage{pdfpages}
\usepackage{everypage}
\AfterEndEnvironment{longtable}{\clearpage}
\AtBeginDocument{
\AddEverypageHook{
\includepdf[pages=-, angle=0, scale=1, offset=0 0]{datamex.pdf}
}
}
And the output error is giving me is:
! Misplaced \noalign.
\newpage ->\noalign
{\break }
l.230 \end{longtable}
Error: LaTeX failed to compile beneficios_financieros_2.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See beneficios_financieros_2.log for more info.
Ejecución interrumpida
This is the PDF I want to use for the R Markdown output:
Any idea of how to solve this?
Upvotes: 0
Views: 33
Reputation: 8886
The background package seems up to the task.
Notes
header-includes
is a good choice.firstpage=false
.---
title: "Example of Using LaTeX background Package"
output: pdf_document
date: "2025-02-13"
header-includes: |
\usepackage[firstpage=true]{background}
\backgroundsetup{
scale=1,
angle=0,
opacity=1,
contents={
\includegraphics[width=\paperwidth,height=\paperheight]{datamex.pdf}
}
}
---
Reprex files hosted with on GitHub
Upvotes: 0