Hi Charles,
Thanks for your answer! I am still struggling with two problems with
respect to the example I gave in my message. I have 2 approaches, but each
of them has its limitations, and there are things I cannot do so far with
each of them
1.If I use the following stable command:
print(outfile,floating=F, include.rownames=F, caption="title",
caption.placement="bottom")
then, no title appears in the latex code generated by R, which I copy below:
% latex table generated in R 2.13.1 by xtable 1.6-0 package
% Sat Feb 4 11:56:13 2012
\begin{tabular}{ccc}
\hline
& V1 & V2 \\
\hline
& & \\
6.91 & 500.00 & 4.00 \\
400.00 & & 400.00 \\
\hline
\end{tabular}
But, I found how to add the title in my latex editor.
If I use the following code, it works fine:
\documentclass[11pt]{report}
\usepackage{rotating}
% \usepackage[counterclockwise]{rotating}
\usepackage{graphics}
\usepackage{float}
\usepackage{capt-of}
\pagestyle{empty}
\begin{document}
%\begin{center}
\begin {sidewaystable}{ % rotate the table
\caption{Table Title}
%\centering
\scalebox{0.70} { %resize
% latex table generated in R 2.13.1 by xtable 1.6-0 package
% Sat Feb 4 11:50:29 2012
\begin{tabular}{ccc}
\hline
& V1 & V2 \\
\hline
& & \\
6.91 & 500.00 & 4.00 \\
400.00 & & 400.00 \\
\hline
\end{tabular}
\notes: note
}
}
\end{sidewaystable}
%\end{center}
\end{document}
However, if I use this solution, I could not find a way to write a
note below the table. I found a way to write one note but I can't
rotate it and place it below the table
2. The second approach, relies on the following R code:
print(outfile, include.rownames=F,
floating.environment='sidewaystable', floating=T,
caption.placement="bottom")
This solution could be the best, because it incorporates the sideways
command and the title. But then, I was unable to rescale it, when I use
scalebox (see below). It generates error messages.
documentclass[11pt]{report}
\usepackage{rotating}
% \usepackage[counterclockwise]{rotating}
\usepackage{graphics}
\usepackage{float}
\usepackage{capt-of}
\pagestyle{empty}
\begin{document}
\scalebox[0.7]{
% latex table generated in R 2.13.1 by xtable 1.6-0 package
% Sat Feb 4 12:02:09 2012
\begin{sidewaystable}[ht]
\begin{center}
\begin{tabular}{ccc}
\hline
& V1 & V2 \\
\hline
& & \\
6.91 & 500.00 & 4.00 \\
400.00 & & 400.00 \\
\hline
\end{tabular}
\caption{Title}
\end{center}
\end{sidewaystable}
}
%\end{center}
\end{document}
So, I have 2 approaches, but none of them brings me what I want so far.
Thanks for any suggestion,
Best,
Aurelien
2012/2/3 Charles Roosen <croosen@mango-solutions.com>
> Hi,
>
> I'm the maintainer for "xtable" and I'm putting some
enhancements in at
> the moment. I could add in a scalebox argument.
>
> Would this go outside or inside the "center" block?
>
> > > \begin{sidewaystable}[ht]
> > >
> > > \begin{center}
> > >
> > > \begin{tabular}{ccc}
>
> Secondly, what combination of arguments is giving you LaTeX with no
> caption?
>
> Thanks,
> Charlie Roosen
>
> -----Original Message-----
> From: r-help-bounces@r-project.org [mailto:r-help-bounces@r-project.org]
> On Behalf Of Aurélien PHILIPPOT
> Sent: 01 February 2012 19:38
> To: Ista Zahn; R-help@r-project.org
> Subject: Re: [R] Problem with xtable- rescaling a table
>
> 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@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:
> > > Dear R users,
> > > I am new to Latex and I am using the R package xtable to generate
> tables.
> > > I want to produce a table that is very long. in the landscape
> > > format,
> > but
> > > I would need to rescale the table so that it fits in the page.
> > > xtable enables me to have the landscape format, but I cannot
rescale
> > > it, and
> > there
> > > seems to be a problem, if I use scalebox in Latex on my output
> > > produced with stable and the option sidewaystable. Do you know
any
> > > way to achieve this result with xtable or another R package?
> > >
> > > Let's look at the following example:
> > > In R, I use the following code
> > >
> > > ##############
> > > outfile<- matrix(nrow=3, ncol=3)
> > > outfile[2,1]<- 6.912
> > > outfile[3,1]<- 400
> > > outfile[2,2]<- 8.9722
> > > outfile[2,2]<- 500
> > > outfile[2,3]<- 4.00
> > > outfile[3,3]<- 400
> > >
> > >
> > >
> > > library(xtable)
> > > outfile<- data.frame(outfile)
> > > colnames(outfile)<- c(" ","V1",
"V2")
> > >
> > > outfile<- xtable(outfile, caption= "Title",
include.rownames=F,
> > > align=rep("c", 4), digit=2) print(outfile,
include.rownames=F,
> > > floating.environment='sidewaystable')
> > > ################
> > >
> > > I was wondering if it is possible to rescale in Latex when the
code
> > > was generated through xtable. Indeed, when I run the latex table
> > > obtained
> > from
> > > xtable, and use scale box, it does not work (and the problem
comes
> > > from scalebox, which works otherwise).
> > >
> > > \documentclass[11pt]{report}
> > >
> > > \usepackage{rotating}
> > >
> > > %\usepackage[counterclockwise]{rotating}
> > >
> > > \usepackage{graphics}
> > >
> > > \usepackage{float}
> > >
> > >
> > > \pagestyle{empty}
> > >
> > >
> > > \begin{document}
> > >
> > > \scalebox{0.70} { %resize
> > >
> > >
> > > % latex table generated in R 2.13.1 by xtable 1.6-0 package
> > >
> > > % Tue Jan 31 23:26:10 2012
> > >
> > > \begin{sidewaystable}[ht]
> > >
> > > \begin{center}
> > >
> > > \begin{tabular}{ccc}
> > >
> > > \hline
> > >
> > > & V1 & V2 \\
> > >
> > > \hline
> > >
> > > & & \\
> > >
> > > 6.91 & 500.00 & 4.00 \\
> > >
> > > 400.00 & & 400.00 \\
> > >
> > > \hline
> > >
> > > \end{tabular}
> > >
> > > \caption{Title}
> > >
> > > \end{center}
> > >
> > > \end{sidewaystable}
> > >
> > >
> > > }
> > >
> > > \end{document}
> > >
> > >
> > >
> > > Thanks a lot for any advice.
> > >
> > >
> > > Best,
> > >
> > > Aurelien
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help@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@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.
> >
>
> [[alternative HTML version deleted]]
>
> LEGAL NOTICE
> This message is intended for the use of the named recipient(s) only and
> may contain confidential and / or privileged information. If you are not
> the intended recipient, please contact the sender and delete this message.
> Any unauthorised use of the information contained in this message is
> prohibited.
> Mango Business Solutions Limited is registered in England under No.
> 4560258 with its registered office at Suite 3, Middlesex House, Rutherford
> Close, Stevenage, Herts, SG1 2EF, UK.
>
> PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS EMAIL
[[alternative HTML version deleted]]