![删除 xtable 中所有 hline 生成的 longtables](https://linux22.com/image/353457/%E5%88%A0%E9%99%A4%20xtable%20%E4%B8%AD%E6%89%80%E6%9C%89%20hline%20%E7%94%9F%E6%88%90%E7%9A%84%20longtables.png)
即使通过设置hline.after = NULL
,R 包生成的 longtablextable
仍然会在表的最末端保留一个 hline。
\documentclass{article}
\usepackage{longtable}
\begin{document}
<<results='asis'>>=
require(xtable)
print(xtable(cars[1:20,], caption = 'NO HLINES'),
tabular.environment = "longtable", include.rownames = F,
caption.placement = "top", include.colnames = FALSE,
hline.after = NULL, floating = FALSE)
@
\end{document}
结果是
\begin{longtable}{rr}
\caption{NO HLINES} \\
4.00 & 2.00 \\
4.00 & 10.00 \\
7.00 & 4.00 \\
7.00 & 22.00 \\
8.00 & 16.00 \\
9.00 & 10.00 \\
10.00 & 18.00 \\
10.00 & 26.00 \\
10.00 & 34.00 \\
11.00 & 17.00 \\
11.00 & 28.00 \\
12.00 & 14.00 \\
12.00 & 20.00 \\
12.00 & 24.00 \\
12.00 & 28.00 \\
13.00 & 26.00 \\
13.00 & 34.00 \\
13.00 & 34.00 \\
13.00 & 46.00 \\
14.00 & 26.00 \\
\hline
\end{longtable}
答案1
booktabs=TRUE
您应该在 print.xtable 调用中添加参数
print(xtable(cars[1:20,], caption = 'NO HLINES'),
tabular.environment = "longtable", include.rownames = F,
caption.placement = "top", include.colnames = FALSE,
booktabs = TRUE,
hline.after = NULL, floating = FALSE)
结果:
\begin{longtable}{rr}
\caption{NO HLINES} \\
4.00 & 2.00 \\
4.00 & 10.00 \\
7.00 & 4.00 \\
7.00 & 22.00 \\
8.00 & 16.00 \\
9.00 & 10.00 \\
10.00 & 18.00 \\
10.00 & 26.00 \\
10.00 & 34.00 \\
11.00 & 17.00 \\
11.00 & 28.00 \\
12.00 & 14.00 \\
12.00 & 20.00 \\
12.00 & 24.00 \\
12.00 & 28.00 \\
13.00 & 26.00 \\
13.00 & 34.00 \\
13.00 & 34.00 \\
13.00 & 46.00 \\
14.00 & 26.00 \\
\end{longtable}