如何编织包含 gt 表的 pdf? [英] How do I knit a pdf containing gt tables?

查看:51
本文介绍了如何编织包含 gt 表的 pdf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 R Markdown 编写一份报告,并使用 gt 包制作了一些表格.但是,当我尝试编织到 pdf 或 html 文件时,出现此错误:

I'm writing up a report in R Markdown and I made some tables using the gt package. However, when I attempt to knit to a pdf or html file, I get this error:

!LaTeX 错误:此处没有行结束.

! LaTeX Error: There's no line here to end.

错误:LaTeX 无法编译 final_report.tex.请参阅 https://yihui.org/tinytex/r/#debugging 了解调试技巧.有关详细信息,请参阅 final_report.log.

Error: LaTeX failed to compile final_report.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See final_report.log for more info.

有趣的是,我能够编织到 Word 文档.我确实做了一些实验以确保它是导致它的表,只是为了确定.如果有人需要查看特定代码来帮助让我知道!提前致谢!

Interestingly, I'm able to knit to a Word document. I did do some experimenting to make sure it was the tables that were causing it, just to be sure. If anyone needs to see specific code to help let me know! Thank you in advance!

推荐答案

有趣的是,我发现如果 tab_header() 命令中没有指定副标题,它就不会编成 pdf.不过现在可以用了!示例:

Interestingly, I figured out that it won't knit to pdf if a subtitle is not specified in the tab_header() command. Works now, though! Example:

data %>%
   gt() %>%
   tab_header(title = md("Title"),
              subtitle = md("Subtitle")) # Must be present to knit to pdf

这篇关于如何编织包含 gt 表的 pdf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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