You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将flextable渲染至Beamer演示文稿时出现编译错误求助

flextable渲染至Beamer演示文稿时出现LaTeX编译错误

问题概况

我在用flextable生成的表格渲染到Beamer演示文稿时遇到问题:代码在Word、PDF、PPTX、HTML等格式下均可正常运行,仅Beamer格式出错;除flextable外,文本、图片、kable生成的表格都能正常编译到Beamer中。该问题在flextable的项目讨论中有相关提及。

可复现的示例代码

---
output:
  beamer_presentation: default
  pdf_document: default
  powerpoint_presentation: default
  ioslides_presentation: default
  word_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(flextable)

Slide

example_ft <-
  iris |> head() |> 
  flextable()
example_ft
## 已尝试的调试操作
- 重新安装/更新R
- 重新安装/更新R Studio
- 重新安装/更新所有包
- 重启R会话
- 按照错误提示的LaTeX调试指南操作

我在三台电脑(2台Mac Pro、1台Dell)测试该Rmd文件,均出现相同错误。

## 错误输出
> processing file: test2.Rmd
> 
> /usr/local/bin/pandoc +RTS -K512m -RTS test2.knit.md --to beamer --from markdown+autolink_bare_uris+tex_math_single_backslash --output test2.tex --lua-filter /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --highlight-style tango --pdf-engine pdflatex --embed-resources --standalone
> output file: test2.knit.md
> 
> ! Undefined control sequence.
>  \Oldarrayrulewidth
> 
> Error: LaTeX failed to compile test2.tex. 可参考LaTeX编译错误排查指南,查看test2.log获取更多信息。
> Execution halted

## 会话信息
```r
sessionInfo()
# R version 4.3.1 (2023-06-16)
# Platform: aarch64-apple-darwin20 (64-bit)
# Running under: macOS Monterey 12.3
# 
# Matrix products: default
# BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
# LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
# 
# locale:
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
# 
# time zone: Asia/Tokyo
# tzcode source: internal
# 
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base
# 
# other attached packages:
# [1] gtsummary_1.7.1       kableExtra_1.3.4.9000 lubridate_1.9.2       forcats_1.0.0         stringr_1.5.0
# [6] dplyr_1.1.2           purrr_1.0.1           readr_2.1.4           tidyr_1.3.0           tibble_3.2.1
# [11] ggplot2_3.4.2         tidyverse_2.0.0       flextable_0.9.2
# 
# loaded via a namespace (and not attached):
# [1] tidyselect_1.2.0        viridisLite_0.4.2       fastmap_1.1.1           xaringan_0.28           fontquiver_0.2.1
# [6] broom.helpers_1.13.0    promises_1.2.0.1        digest_0.6.33           timechange_0.2.0        mime_0.12
# [11] lifecycle_1.0.3         ellipsis_0.3.2          gfonts_0.2.0            processx_3.8.2          magrittr_2.0.3
# [16] compiler_4.3.1          sass_0.4.6              rlang_1.1.1             tools_4.3.1             gt_0.9.0
# [21] utf8_1.2.3              yaml_2.3.7              data.table_1.14.8       knitr_1.43              askpass_1.1
# [26] prettyunits_1.1.1       htmlwidgets_1.6.2       pkgbuild_1.4.2          curl_5.0.1              xml2_1.3.5
# [31] rsconnect_0.8.29        pkgload_1.3.2.1         httpcode_0.3.0          miniUI_0.1.1.1          withr_2.5.0
# [36] grid_4.3.1              fansi_1.0.4             urlchecker_1.0.1        profvis_0.3.8           gdtools_0.3.3
# [41] xtable_1.8-4            colorspace_2.1-0        scales_1.2.1            crul_1.4.0              tinytex_0.45
# [46] cli_3.6.1               rmarkdown_2.23          crayon_1.5.2            ragg_1.2.5              generics_0.1.3
# [51] remotes_2.4.2           rstudioapi_0.15.0       httr_1.4.6              tzdb_0.4.0              sessioninfo_1.2.2
# [56] cachem_1.0.8            rvest_1.0.3             vctrs_0.6.3             devtools_2.4.5          webshot_0.5.5
# [61] jsonlite_1.8.7          fontBitstreamVera_0.1.1 xaringanthemer_0.4.2    callr_3.7.3             hms_1.1.3
# [66] systemfonts_1.0.4       jquerylib_0.1.4         glue_1.6.2              ps_1.7.5                DT_0.28
# [71] stringi_1.7.12          gtable_0.3.3            later_1.3.1             munsell_0.5.0           pillar_1.9.0
# [76] htmltools_0.5.5         openssl_2.0.6           R6_2.5.1                textshaping_0.3.6       evaluate_0.21
# [81] shiny_1.7.4.1           memoise_2.0.1           bslib_0.5.0             fontLibera

我再次尝试上述调试步骤后问题仍未解决,希望能得到该问题的解决方案。


内容的提问来源于stack exchange,提问作者papa_phuong

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 09:35:14