Bonjour a tous ,
qqn peut m'aider pour trouver comment on peut faire des header et footer dans nos rapport dans chaque page avec rmarkdown automatiquement ?
merci d'avance
cdt
fmch
Modérateur : Groupe des modérateurs
Code : Tout sélectionner
---
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
---
Code : Tout sélectionner
---
title: "Titre"
date: '`r format(Sys.Date(), "%B %d, %Y")`'
author: auteur
---
https://stackoverflow.com/questions/23449319/yaml-current-date-in-rmarkdown a écrit :One workaround is to use the brew package and write your YAML front matter as a brew template.
---
title: "Sample Document"
output:
html_document:
toc: true
theme: united
date: <%= format(Sys.time(), "%d %B, %Y") %>
author: baptiste
---
You can now use a brew_n_render function that would preprocess the doc using brew and then run in through rmarkdown.
brew_n_render <- function(input, ...){
output_file <- gsub("\\.[R|r]md$", ".html", input)
brew::brew(input, 'temp.Rmd'); on.exit(unlink('temp.Rmd'))
rmarkdown::render('temp.Rmd', output_file = output_file)
}
To make this work with the KnitHTML button in RStudio, you can write a custom output format that will automatically use brew as the preprocessor. Using brew to preprocess ensures that the knitr code chunks in your document are untouched during the preprocessing stage. Ideally, the rmarkdown package should expose the metadata in its API and allow users to run it through a custom function.
Retourner vers « Questions en cours »
Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 1 invité