【发布时间】:2021-10-11 14:13:36
【问题描述】:
我正在使用 RMarkdown 脚本生成大量报告。我想使用参数向 word-document 输出添加自定义页眉/页脚,例如客户名称。当我从单独的脚本渲染 RMarkdown 时,它会遍历客户端列表并更改数据。我也希望标题更新。
我已经尝试了this question 的答案,但没有成功,并且使用了一个单词参考文档来设置标题。但是使用参考文档,我只能设置一个在参数更改时不更新的静态标题。
标题应该显示:
史蒂夫
2021 年 8 月 6 日
第 X 页,共 3 页
“史蒂夫”在循环时更新为不同的名称。
这是我的 YAML 中的内容:
---
title: "test doc"
author:
- Author 1
- Author 2
date: "`r format(Sys.time(), '%B %d, %Y')`"
output:
word_document:
reference_docx: test1.docx
params:
client: "Steve"
header-includes:
- \usepackage{fancyhdr}
- \usepackage{lipsum}
- \pagestyle{fancy}
- \fancyhead[LE,L0]{"params$client <br> `r format(Sys.time(), '%B %d, %Y')` <br> Page \thepage of 3"}
always_allow_html: true
---
【问题讨论】:
标签: r ms-word r-markdown knitr