我读了很多关于如何将表格调整到页面宽度的 TEX 问题/答案,但搞不清楚如何在我的环境中应用它(使用 xtable/sweave)。我尝试过的所有方法(使用 adjustbox、tabu)都不起作用。我的 \hbox 在第 18-41 行对齐时非常糟糕(太宽了 262.58336pt)。
这是我的代码和数据:
\documentclass{article}
\usepackage[hmargin=2.5cm,vmargin=3.5cm]{geometry}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{lscape}
\usepackage{float}
\usepackage{adjustbox}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<echo=F>>=
load("Table_wratio_scaled_elasmo_nospatialtemporal.Rdata")
require(xtable)
finalx <- xtable(final2,label="bigtable",caption="List of ...")
@
\begin{landscape}
<<Final table, echo=F,results=tex>>=
print(finalx,tabular.environment="longtable", caption.placement="top",
size="\\small", table.placement="", floating=FALSE)
@
\end{landscape}
\end{document}
xtable 的输出如下:
% latex table generated in R 3.0.2 by xtable 1.7-1 package
% Thu Oct 17 08:53:16 2013
{\small
\begin{longtable}{rlrrrrrrrrrrr}
\caption{List of all fishery and mean weight (mt) of elasmobranch category captured in observed Canadian fisheries} \\
\hline
& fishery & Obs\_tspp & Obs\_Selachii & Obs\_Batoid & wratio\_Selachii & wratio\_Batoid & Obs\_Sets & log\_tspp & scaled\_Selachii & scaled\_Batoid & Obs\_proxie & scaled\_Elasmo \\
\hline
1 & Total & 118025.04 & 390.78 & 493.10 & & & 37270.00 & 670446.67 & 3425.09 & 3273.37 & & 6698.46 \\
2 & SWORDFISH-Line & 84.85 & 81.00 & 0.07 & 0.96 & 0.97 & 62.00 & 919.91 & 892.72 & 0.62 & 9.22 & 893.34 \\
3 & HALIBUT(ATL)-Line & 261.41 & 17.80 & 66.86 & 0.07 & 0.07 & 953.00 & 1793.35 & 126.37 & 498.40 & 14.58 & 624.77 \\
4 & COD(ATL)-Line & 398.41 & 8.51 & 24.58 & 0.02 & 0.01 & 616.00 & 6360.91 & 130.13 & 394.79 & 6.26 & 524.92 \\
....
58 & CUSK-Line & 2.11 & 0.04 & 0.17 & 0.02 & 0.02 & 16.00 & & & & & \\
\hline
\hline
\label{bigtable}
\end{longtable}
答案1
您的数据可以轻松地放在页面上,但您的标题却不行,因此您需要重新措辞、旋转或缩短它们。
例如这很合适,但可能不是您想要的:
& \rotatebox{90}{fishery} & \rotatebox{90}{Obs\_tspp} & \rotatebox{90}{Obs\_Selachii} & \rotatebox{90}{Obs\_Batoid} & \rotatebox{90}{wratio\_Selachii} & \rotatebox{90}{wratio\_Batoid} & \rotatebox{90}{Obs\_Sets} & \rotatebox{90}{log\_tspp} & \rotatebox{90}{scaled\_Selachii} & \rotatebox{90}{scaled\_Batoid} & \rotatebox{90}{Obs\_proxie} & \rotatebox{90}{scaled\_Elasmo} \\
答案2
也可以这样做
\usepackage{rotating}
\usepackage{pdflscape}
\begin{landscape}
\begin{sidewaystable}
INSERT TABLE
\end{sidewaystable}
\end{landscape}