R-LaTeX wide table

I am writing a report with sweave. I need to put a very wide table:

from R

dim(myData)
> 50 60

      

The R code I wrote to create the LaTex table:

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)

      

The problem is that the table is too wide for the page size, so is there a way to split the table across different pages, for example in LaTeX longtable environment, but in width?

Hope I was able to explain my problem.

Hello

Riccardo

+3


source to share


3 answers


You can create multiple tables manually by multiplying your data

Table 1 (assuming the first three columns should be as in

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)

      



table 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


source


If you can put columns on one page in landscape mode, the longtable environment will take care of the overflowing rows for you, including the correct subtitles.

If there is no way to reconfigure the table to fit your current terrain page, you could always make the page larger (see package geometry

).



Since you are using Sweave, I suggest you take a look at my previous answer by TeX.SX on the same question , which defines a longtable header in such a way that it behaves correctly.

+1


source


Another useful approach is to use a function resizebox

to scale the table to fit the width of the page. I find this to be much better than using a blunt tool \small

or \tiny

:

\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}

      

I suspect your table still needs to be split in two, but resizebox

can be used to pair with @ PaulHurleyuk's answer.

+1


source







All Articles