Using a YAML header argument in knitr

萝らか妹 提交于 2019-12-03 08:13:42

You can use the rmarkdown::yaml_front_matter() function:

---
title: "Introduction to R"
subtitle: "Reading and saving data in R"
date: '`r format(Sys.Date())`'
output:
  beamer_presentation:
    fonttheme: professionalfonts
    highlight: tango
    includes:
      in_header: "../../templatefiles/beamer_header.tex"
    template: "../../templatefiles/beamer_template.tex"
    incremental: no
    keep_tex: yes
    slide_level: 3
    theme: Warsaw
    toc: yes
fontsize: 10pt
fontenc: T1
to_print: TRUE
knit: (function(inputFile, encoding) { rmarkdown::render(inputFile, encoding = encoding, 
       output_file = file.path(ifelse(rmarkdown::yaml_front_matter(inputFile)$to_print,
                                      gsub("\\..*","_handout.pdf", inputFile), 
                                      gsub("\\..*", ".pdf", inputFile)))) })
---
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!