2012-03-30 49 views
3

我正在用sweave寫報告。我必須把-在一個很寬的表:R-LaTeX Wide table

來自R

dim(myData) 
> 50 60 

的R代碼裏面我寫生成乳膠表:

print(xtable(myData, caption="my wide table", label="tab:myTab", digits=3), 
     tabular.environment="longtable", caption.placement="top", 
    ## floating.environment="sidewaystable", ## a trial 
     size="\\tiny", table.placement="", floating=FALSE) 

的問題是,該表對於頁面的維度來說太寬了,那麼,有沒有辦法在不同的頁面中分割表格,比如LaTeX longtable環境,但是,寬度是?

我希望我能解釋我的問題。

問候

裏卡多

+0

可以通過縮放表格來適應頁面寬度,這可能有助於與下面的景觀選項結合使用。請參閱http://tex.stackexchange.com/questions/10863/is-there-a-way-to-slightly-shrink-a-table-including-font-size-to-fit-within-th和http:/ /tex.stackexchange.com/questions/35987/scaling-a-table-to-fit-an-entire-page – PaulHurleyuk 2012-03-31 09:22:36

+0

我已經使用過,但我有太多的行和列。 – Riccardo 2012-04-02 14:24:50

回答

0

您可以通過子集化您的數據手工創建多個表

表1(假設前三欄應該是在這兩個

print(xtable(myData[,c(1:3,4:25)], caption="my wide table", label="tab:myTab", digits=3), 
     tabular.environment="longtable", caption.placement="top", 
     size="\\tiny", table.placement="", floating=FALSE) 

表2

print(xtable(myData[,c(1:3,25:50)], caption="my wide table", label="tab:myTab", digits=3), 
     tabular.environment="longtable", caption.placement="top", 
     size="\\tiny", table.placement="", floating=FALSE) 
+0

最後,我用你建議的方式:將寬表分成較小的表。我希望找到一些R/LaTeX技巧來適應不同的頁面...... :( – Riccardo 2012-04-02 14:37:25

1

如果你能適應列到在橫向模式下一個頁面,該longtable環境會照顧四溢行的你,包括正確的字幕。

如果無法重新排列表格以適合當前的橫向頁面,則可以始終使頁面變大(請參閱geometry程序包)。

既然你在使用Sweave,我建議你看看我的previous TeX.SX answer on the same subject,它定義了longtable標題,它的行爲是正確的。

+0

我無法將列或行整合到一個頁面中。我讀了你的鏈接,我發現它非常有趣! – Riccardo 2012-04-02 14:26:48

+0

好吧,如果沒有辦法按照原樣填充表格內容,那麼您將不得不重新考慮表格的佈局。很高興你找到了我的Sweave代碼。 – chepec 2012-04-03 05:14:12

+0

剛剛注意到你在子集答案的評論。不要忘記接受這個答案。祝你好運。 – chepec 2012-04-03 05:17:21

1

另一個有用的方法是使用resizebox函數來縮放表格以適合頁面寬度,我發現這比使用\small或的鈍器工具好得多:

\begin{table}[t] 
    \resizebox{\textwidth}{!}{% 
    \centering 
    \begin{tabular}{lllll} 
     % Some stuff 
    \end{tabular}}%Closing bracket 
    %Don't scale the caption! 
    \caption{A table caption.}\label{T1.1} 
\end{table} 

我懷疑你的表仍然有兩個被分裂,但resizebox可以與@PaulHurleyuk答案結合使用。

相關問題