rmarkdown pdf输出中的动态标头 [英] Dynamic headers in rmarkdown pdf output

查看:111
本文介绍了rmarkdown pdf输出中的动态标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用我认为是Rmarkdown/Knitr,YAML,LaTeX和Pandoc的组合来创建报告(我不完全了解我的代码的哪一部分与什么有关,因为我不精通除R).

I'm creating reports using what I think is a combination of Rmarkdown/Knitr, YAML, LaTeX and Pandoc (I don't fully understand which parts of my code pertain to what because I'm not well versed in anything except R).

我想知道如何添加动态"标头,其中标头的内容可以从我读入的变量(例如,导入到R会话的数据帧中的值)中调用.

I want to know how to add a "dynamic" header, where the contents of the header can be called from variables I read in, for eg., a value from a dataframe I import into the R session.

具体来说,我想为每个报告添加一个唯一的ID#,并在该报告的每一页上打印(不必在标题中),并添加一个唯一的ID#对于我生成的每个新报告,而不必每次创建新报告时都在标题部分中手动更改此信息.

Specifically, I want to add, say, a unique ID# for every report, to be printed on every page of the report (not necessarily in the header), with a new unique ID# for every new report I generate, without having to manually change this information in the header section each time I make a new report.

这是我当前的标题:

header-includes: 
   \usepackage{fancyhdr} 
   \usepackage{graphicx}
   \usepackage{eurosym} 
   \usepackage{booktabs} 
   \pagestyle{fancy} 
   \fancyhf{} 
   \addtolength{\headheight}{1.0cm}
   \rfoot{Page \thepage} 
   \usepackage{setspace}
   \setlength{\topsep}{0pt}
   \fancypagestyle{plain}{\pagestyle{fancy}}
   \renewcommand{\footrulewidth}{0.4pt}
   \iffalse
   \fi
   \rhead{\fontsize{28}{12}\selectfont My Report} 
   \lhead{\includegraphics[width=6cm]{path/to/my/png.png}} 
    \cfoot{some information about footer goes here }
    \usepackage{floatrow}
    \floatsetup[table]{capposition=top, objectset=centering}
    \setlength\parindent{0 pt}\setlength{\parskip}{0.0pt plus 0.0pt}
output: 
  pdf_document: 
    keep_tex: yes
    latex_engine: xelatex
geometry: "left=2cm,right=2cm,top=2.5cm,bottom=3cm"
mainfont: Calibri
fontsize: 12pt

推荐答案

eipi10对我的问题的评论(具体来说,他对Rmarkdown/Rstudio网页的链接)和这篇文章对我终于有用:

A combination of eipi10 's comment to my question (specifically, his link to the Rmarkdown/Rstudio webpage) and this post is what finally worked for me:

https://stackoverflow.com/a/35044316/3276842

这篇关于rmarkdown pdf输出中的动态标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆