Re: [R] Sweave, xtable and font size

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Wed, 07 May 2008 19:53:44 -0400

On 07/05/2008 7:34 PM, Peter Jepsen wrote:
> Hi,
>
> I'm using Sweave with xtable to generate Latex tables. My problem is that some of the tables are too wide, and I would like to use the tiny font for these tables, but not for the others nor for the text. I can't work out how to accomplish that.
>
> The Latex code below does what I want it to, but I have to insert the "\tiny{" and the closing "}" by hand. It originated from these commands in my .Rnw-file:
>
> <<yearmale, results=tex>>=
> yearmale <- with(chol, table(year,male))
> yearmale <- rowpct(yearmale) <<yearmale, results=tex>>=
> print(xtable(yearmale,caption="My caption"))
> $

See ?print.xtable. You can use

print(xtable(yearmale,caption="My caption"), size="\\tiny")

Duncan Murdoch

>
> LATEX CODE:
>
> \begin{table}[ht]
> \begin{center}
> \tiny{
> \begin{tabular}{rlll}
> \hline
> & Kvinder & Mænd & Total \\
> \hline
> 1998 & 1335 (75\%) & 437 (25\%) & 1772 (100\%) \\
> 1999 & 1232 (74\%) & 425 (26\%) & 1657 (100\%) \\
> 2000 & 1427 (74\%) & 502 (26\%) & 1929 (100\%) \\
> 2001 & 1407 (74\%) & 493 (26\%) & 1900 (100\%) \\
> 2002 & 1493 (71\%) & 611 (29\%) & 2104 (100\%) \\
> 2003 & 1684 (75\%) & 566 (25\%) & 2250 (100\%) \\
> 2004 & 1565 (73\%) & 567 (27\%) & 2132 (100\%) \\
> 2005 & 1629 (74\%) & 586 (26\%) & 2215 (100\%) \\
> 2006 & 1448 (72\%) & 553 (28\%) & 2001 (100\%) \\
> 2007 & 1582 (73\%) & 590 (27\%) & 2172 (100\%) \\
> Total & 14802 (74\%) & 5330 (26\%) & 20132 (100\%) \\
> \hline
> \end{tabular}
> }
> \caption{My caption}
> \end{center}
> \end{table}
>
>
> Can anybody help me? Thank you in advance.
>
> Best regards,
> Peter.
>
> ______________________________________________
> 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. Received on Wed 07 May 2008 - 23:56:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 08 May 2008 - 01:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive