【发布时间】:2021-05-17 07:47:57
【问题描述】:
尝试创建包含booktabs 表的pdf 时出现错误。如果我删除表格代码,则可以毫无问题地创建 pdf。
RStudio: 最新版本
R: 最新版本
tinytex:最新版本
以下是我的Rmd 文件:
---
title: "table"
author: "Author"
date: "2/13/2021"
output:
pdf_document:
latex_engine: xelatex
html_document:
df_print: paged
includes:
in_header: preamble.tex
---
Something here
\begin{table}[h]
\centering
\caption{Descriptive Statistics}
\label{tab:descriptiveStatistics}
{
\begin{tabular}{lr}
\toprule
& Weight \\
\cmidrule[0.4pt]{1-2}
Valid & 13 \\
Missing & 0 \\
Mean & 170.769 \\
Std. Deviation & 29.255 \\
Minimum & 140.000 \\
Maximum & 235.000 \\
\bottomrule
\end{tabular}
}
\end{table}
以下是我的preamble.tex 文件:
\usepackage{booktabs}
\usepackage{makecell}
我得到的错误如下:
output file: test.knit.md
! Undefined control sequence.
l.81 \toprule
Error: LaTeX failed to compile test.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test.log for more info.
In addition: Warning message:
In has_crop_tools() :
Tool(s) not installed or not in PATH: pdfcrop, ghostcript
-> As a result, figure cropping will be disabled.
Execution halted
【问题讨论】:
-
LaTeX 中表格的另一种解决方案是:haozhu233.github.io/kableExtra/awesome_table_in_pdf.pdf
-
感谢您的建议。然而,我正在写一本关于如何用JASP 教授统计数据的书。 JASP 允许将表格复制为 LaTex(需要 booktabs 包),其格式如上所示。因此,使用上述格式对我来说耗时更少。
标签: r latex rstudio tex tinytex