gpt4 book ai didi

r - 使用 pandoc 将 html 编织到 Word docx

转载 作者:行者123 更新时间:2023-12-02 15:34:45 25 4
gpt4 key购买 nike

我一直在使用 pandoc 将一些示例 R markdown html 输出保存到 Word。实际上,我这样做只是为了添加一些分页符以便于打印:

system("pandoc -s Exercise1.html -o Exercise1.docx")

虽然输出是可以接受的,但我想知道是否有办法保持 R block 的原始语法突出显示(就像它们在原始编织 HTML 文档中一样)?

此外,我似乎在转换过程中丢失了所有图像,必须手动将它们粘贴到 Word 中。这正常吗?

最佳答案

使用 rmarkdown package (baked into RStudio Version 0.98.682, the current preview release)将 Rmd 转换为 docx 非常简单,docx 文件中包含代码突出显示。

您只需要在 Markdown 文本的顶部包含它:

---
title: "Untitled" # obviously you can change this
output: word_document # specifies docx output
---

不过,这个转换好像还是不支持分页。

关于r - 使用 pandoc 将 html 编织到 Word docx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19889459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com