Rmarkdow - How can I create a .pdf file with different name from .Rmd ?

How can I create a .pdf file with different name from .Rmd ?

---
title: "Title"
subtitle: "Sub"
author: "Me"
date: "`r format(Sys.time(), '%d %B, %Y')`"

output:
  pdf_document: 
    toc: true
    number_sections: true
    latex_engine: xelatex

header-includes:
  - \usepackage[portuges]{babel}
  - \usepackage{setspace}  \singlespacing
indent: false 
mainfont: Arial
monofont: Arial
fontsize: 12pt
geometry: "left=3cm,right=3cm,top=2cm,bottom=2cm"

abstract: \singlespacing BLABLABLA.
keyword: "BLABLA."

---

I think you use the knit button to create the pdf-file. In that case you get normally the same name as the Rmd file. The most simple way to create b.pdf from a.Rmd is to use:

rmarkdown::render('a.Rmd', output_file = 'b', envir = new.env())

However it is possibile to specify what will happen when you click the knit button by adding the statement
knit: (function (...) { your_knit_function(...) })
to your YAML statements.

See for an example the function HOQCutil::my_knit in my HOQCutil package on GitHub. You can install the package to try it or just copy the functions in the R-file and deleting from them everything in it that you don't need.

1 Like

Ok, thank you very much!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.