Skip to content

Problem with xtable- rescaling a table

5 messages · Aurélien PHILIPPOT, Ista Zahn, Tal Galili

#
Hi,

It looks like you need scalebox inside the sidewaystable environment. If you 
must use scalebox, one solution is to use floating=FALSE when you call 
print.xtable, and insert the table environment directly in LaTeX, like this:

\begin{sidewaystable}[ht]
\scalebox{0.7}{
<<code1,results=tex,echo=false>>=
print(outfile, include.rownames=F, floating = FALSE)
@ 
}
\end{sidewaystable}

Alternatively, since the size of the table is determined by the size of the 
text in the table, you can just tell LaTeX to use a smaller font, e.g.

<<results=tex,echo=false>>=
print(outfile, include.rownames=F, floating.environment='sidewaystable', size 
= "scriptsize")
@ 

Best,
Ista
On Tuesday, January 31, 2012 11:41:27 PM Aur?lien PHILIPPOT wrote:
3 days later
#
Hi Aurelien,

You just need to put the \caption outside the scalebox command, like this:

 \documentclass[11pt]{report} 
\usepackage{rotating}
 %\usepackage[counterclockwise]{rotating}
\usepackage{graphics}
\usepackage{float}


\pagestyle{empty}


\begin{document}
\begin{sidewaystable}[ht] 
\centering
\scalebox{0.7}{

% latex table generated in R 2.13.1 by xtable 1.6-0 package
% Wed Feb  1 10:29:25 2012
\begin{tabular}{ccc} 
  \hline
  & V1 & V2 \\  
  \hline
 &  &  \\  
  6.91 & 500.00 & 4.00 \\  
  400.00 &  & 400.00 \\  
   \hline
\end{tabular}
}
\caption{Title}
\end{sidewaystable} 
\end{document}

Best,
Ista
On Wednesday, February 01, 2012 10:37:47 AM Aur?lien PHILIPPOT wrote:
Thanks Ista.
Your suggestion works.
When I make the option floating=F, the caption no longer appears in the Tex 
code generated by xtable. If I had \caption {Title} in the code, it does not 
seem to work. 
 \documentclass[11pt]{report} 
\usepackage{rotating}
 %\usepackage[counterclockwise]{rotating}
\usepackage{graphics}
\usepackage{float}


\pagestyle{empty}


\begin{document}
\begin{sidewaystable}[ht] 
\scalebox{0.7}{


% latex table generated in R 2.13.1 by xtable 1.6-0 package
% Wed Feb  1 10:29:25 2012
\begin{tabular}{ccc} 
  \hline
  & V1 & V2 \\  
  \hline
 &  &  \\  
  6.91 & 500.00 & 4.00 \\  
  400.00 &  & 400.00 \\  
   \hline
\end{tabular}
\caption{Title}
}
\end{sidewaystable} 
\end{document}


So, I am faced with a dilemma. If I use the code from my previous email, I 
could have the landscape and the title work, but if I incorporate scalebox in 
Latex it does not work. If I use the floating=F solution, I can rescale and 
landscape, but I have troubles having a caption. That's weird.


Best,
Aurelien






2012/2/1 Ista Zahn <istazahn at gmail.com>
Hi,

It looks like you need scalebox inside the sidewaystable environment. If you
must use scalebox, one solution is to use floating=FALSE when you call
print.xtable, and insert the table environment directly in LaTeX, like this:

\begin{sidewaystable}[ht]
\scalebox{0.7}{
<<code1,results=tex,echo=false>>=
print(outfile, include.rownames=F, floating = FALSE)
@
}
\end{sidewaystable}

Alternatively, since the size of the table is determined by the size of the
text in the table, you can just tell LaTeX to use a smaller font, e.g.

<<results=tex,echo=false>>=
print(outfile, include.rownames=F, floating.environment='sidewaystable', size
= "scriptsize")
@

Best,
Ista
On Tuesday, January 31, 2012 11:41:27 PM Aur?lien PHILIPPOT wrote:
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
Hi Tal,

Untested, but it should just be a matter of giving tabularx style formatting 
in the align option to xtable(), and then using "tabularx" as the 
tabular.environment argument to print.xtable()

see ?xtable and ?print.xtable for details.

Best,
Ista
On Sunday, February 05, 2012 01:16:38 PM Tal Galili wrote:
Dear Ista,


Do you happen to know of a way to use the {tabularx} LaTeX pacakge, so to have 
it work with xtables?


I would rather have my columns adjust themselves then to rotate my table. 


Thank you in advance,
Tal






----------------Contact 
Details:-------------------------------------------------------
Contact me: Tal.Galili at gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | 
www.r-statistics.com (English)
----------------------------------------------------------------------------------------------
On Sat, Feb 4, 2012 at 10:46 PM, Ista Zahn <istazahn at gmail.com> wrote:
Hi Aurelien,

You just need to put the \caption outside the scalebox command, like this:


 \documentclass[11pt]{report}
\usepackage{rotating}
 %\usepackage[counterclockwise]{rotating}
\usepackage{graphics}
\usepackage{float}


\pagestyle{empty}


\begin{document}
\begin{sidewaystable}[ht]

\centering

\scalebox{0.7}{

% latex table generated in R 2.13.1 by xtable 1.6-0 package
% Wed Feb  1 10:29:25 2012
\begin{tabular}{ccc}
 \hline
 & V1 & V2 \\
 \hline
 &  &  \\
 6.91 & 500.00 & 4.00 \\
 400.00 &  & 400.00 \\
  \hline
\end{tabular}
}
\caption{Title}
\end{sidewaystable}
\end{document}


Best,
Ista
On Wednesday, February 01, 2012 10:37:47 AM Aur?lien PHILIPPOT wrote:
Thanks Ista.
Your suggestion works.
When I make the option floating=F, the caption no longer appears in the Tex
code generated by xtable. If I had \caption {Title} in the code, it does not
seem to work.
 \documentclass[11pt]{report}
\usepackage{rotating}
 %\usepackage[counterclockwise]{rotating}
\usepackage{graphics}
\usepackage{float}


\pagestyle{empty}


\begin{document}
\begin{sidewaystable}[ht]
\scalebox{0.7}{


% latex table generated in R 2.13.1 by xtable 1.6-0 package
% Wed Feb  1 10:29:25 2012
\begin{tabular}{ccc}
 \hline
 & V1 & V2 \\
 \hline
 &  &  \\
 6.91 & 500.00 & 4.00 \\
 400.00 &  & 400.00 \\
  \hline
\end{tabular}
\caption{Title}
}
\end{sidewaystable}
\end{document}


So, I am faced with a dilemma. If I use the code from my previous email, I
could have the landscape and the title work, but if I incorporate scalebox in
Latex it does not work. If I use the floating=F solution, I can rescale and
landscape, but I have troubles having a caption. That's weird.


Best,
Aurelien






2012/2/1 Ista Zahn <istazahn at gmail.com>
Hi,

It looks like you need scalebox inside the sidewaystable environment. If you
must use scalebox, one solution is to use floating=FALSE when you call
print.xtable, and insert the table environment directly in LaTeX, like this:

\begin{sidewaystable}[ht]
\scalebox{0.7}{
<<code1,results=tex,echo=false>>=
print(outfile, include.rownames=F, floating = FALSE)
@
}
\end{sidewaystable}

Alternatively, since the size of the table is determined by the size of the
text in the table, you can just tell LaTeX to use a smaller font, e.g.

<<results=tex,echo=false>>=
print(outfile, include.rownames=F, floating.environment='sidewaystable', size
= "scriptsize")
@

Best,
Ista
On Tuesday, January 31, 2012 11:41:27 PM Aur?lien PHILIPPOT wrote:
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.