如何使用动态路径在rmarkDown中包括一个乘法PDF?

发布于 2025-02-09 16:37:17 字数 532 浏览 1 评论 0原文

我能够使用“ \ includepdf”在我的rmarkDown输出中弄清楚如何在我的rmarkDown输出中加入多页PDF文档,但是我需要能够根据数据中的条件将通往不同PDF的路径更改。我希望能够根据我事先设置在块中的对象(例如“测试”)调用PDF文件路径。有什么想法吗? 谢谢!

---
title: "Personnel Reports"
output:
  pdf_document
header-includes:
  - \usepackage{pdfpages}
---

This works:

\includepdf[pages=-,pagecommand={}]{Person1_report.pdf}

```{r global_options, include=FALSE}
test <- "Person2_report.pdf"
```' 
This doesn't work: 
\includepdf[pages=-,pagecommand={}]{test}

I was able to figure out how to include a multi-page PDF document in my RMarkdown output using "\includepdf", but I need to be able to change the path to different PDFs based on conditions in the data. I'd like to be able to call the PDF file path based on an object I set in a chunk beforehand (e.g. "test"). Any ideas?
Thanks!

---
title: "Personnel Reports"
output:
  pdf_document
header-includes:
  - \usepackage{pdfpages}
---

This works:

\includepdf[pages=-,pagecommand={}]{Person1_report.pdf}

```{r global_options, include=FALSE}
test <- "Person2_report.pdf"
```' 
This doesn't work: 
\includepdf[pages=-,pagecommand={}]{test}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清音悠歌 2025-02-16 16:37:17
---
title: "Personnel Reports"
output:
  pdf_document:
    keep_tex: true
header-includes:
  - \usepackage{pdfpages}
---

```{r global_options, include=FALSE}
test <- "example-image-duck.pdf"
```

\includepdf[pages=-,pagecommand={}]{`r test`}
---
title: "Personnel Reports"
output:
  pdf_document:
    keep_tex: true
header-includes:
  - \usepackage{pdfpages}
---

```{r global_options, include=FALSE}
test <- "example-image-duck.pdf"
```

\includepdf[pages=-,pagecommand={}]{`r test`}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文