我想让longtable
单词跨越多页,继续在表格的右下角,并且其标题只出现在使用 的表格列表中的一个knitr
。以下是我的 MWE.Rnw
格式。任何帮助都将不胜感激。提前感谢您的帮助。
\documentclass{article}
\usepackage{longtable}
\begin{document}
\listoftables
<< label=LongTable, results='asis', echo = FALSE >>=
library(xtable)
set.seed(12345)
MatrixData <- matrix(rnorm(1000), ncol = 10)
print(
xtable(
x = MatrixData
, caption = "Example of longtable spanning several pages"
, label = "tab:MatrixData"
, align = c("l|", rep("r", ncol(MatrixData)))
, digits = c(rep(3, ncol(MatrixData)+1))
)
, table.placement = "H"
, caption.placement = "top"
, include.rownames = TRUE
, include.colnames = TRUE
, size = "small"
, tabular.environment = 'longtable'
, floating = FALSE
, add.to.row = list(pos = list(0),command = "\\hline \\endhead ")
)
@
\end{document}
输出
答案1
我认为这会起到作用:
\documentclass{article}
\usepackage{longtable}
\begin{document}
\listoftables
<< label=LongTable, results='asis', echo = FALSE >>=
library(xtable)
set.seed(12345)
MatrixData <- matrix(rnorm(1000), ncol = 10)
print(
xtable(
x = MatrixData
, caption = "Example of longtable spanning several pages"
#, label = "tab:MatrixData"
, align = c("l|", rep("r", ncol(MatrixData)))
, digits = c(rep(3, ncol(MatrixData)+1))
)
, table.placement = "H"
, caption.placement = "top"
, include.rownames = TRUE
, include.colnames = TRUE
, size = "small"
, tabular.environment = 'longtable'
, floating = FALSE
, add.to.row = list(pos = list(0),command =
paste("\\hline \\endfirsthead" , # First caption
"\\caption[]{Example of longtable spanning several pages} \\label{tab:MatrixData} \\\\ \\hline", # Additional captions
paste("&", 1:ncol(MatrixData),collapse=" "), # Column names
"\\\\ \\hline ",
"\\endhead",
"\\hline \\multicolumn{11}{r}{\\textit{Continued}} \\
\\endfoot
\\endlastfoot",collapse=" ")))
@
\end{document}