[R] width and alignment of Latex table columns
Duncan Mackay
mackay at northnet.com.au
Thu Feb 9 13:25:24 CET 2012
Hi
Here is an example with something at hand if you use Sweave.
Using Sweave you can embed the R in a chunk and properly format the
headers and sometimes the table.
the D{.}{.}{4.0} requires the use of \usepackage{dcolumn}
\begin{table}[h]
\caption[DNO and \rdate]%
{DNO and \rdate with row totals}%
\label{tab:CW2}%
\centering
\begin{tabular}{p{1.0in} *{7}{D{.}{.}{4.0}} }
\toprule
\addlinespace[3pt]
% Header
\multicolumn{1}{Measurement} \\
\addlinespace[3pt]
\midrule
\addlinespace[5pt]
%Table2
<<Table2, keep.source=FALSE, results=tex, echo=FALSE>>=
xx <- addmargins(xx,2)
print(
xtable(xx,
digits = rep(0,8)
),
type = "latex",
floating = FALSE,
tabular.environment = "tabular",
include.rownames = TRUE,
include.colnames = FALSE,
only.contents = TRUE,
hline.after = NULL
) ## xtable
@ % Table2 end
\addlinespace[5pt]
\bottomrule
\end{tabular}
\end{table}
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email: home mackay at northnet.com.au
At 22:07 9/02/2012, you wrote:
>Hi,
>
>You can set the width of the columns the same way you would in any
>other LaTeX
>table, e.g., by setting align to p{width}.
>http://www.giss.nasa.gov/tools/latex/ltx-68.html has a good summary of LaTeX
>tables that you may find helpful.
>
>Best,
>Ista
>
>On Thursday, February 09, 2012 10:08:32 AM n.vialma at libero.it wrote:
> > Dear all,
> > I'm using xtable package in order to produce Latex table. There is a way to
> > specify not only the alignment but also the width of table colums??
> > Thanks for your attention.
> >
> > ______________________________________________
> > 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.
More information about the R-help
mailing list