简体   繁体   English

为xtable生成的乳胶表的列着色

[英]Color the column of a latex table produced by xtable

How can I use the R xtable package to produce a table with a colored column? 如何使用R xtable包生成带有彩色列的表? This post shows how to color a row, but I can't figure out how to do the same for columns. 这篇文章展示了如何为一行着色,但我无法弄清楚如何为列做同样的事情。

Here is a code snipped that should clarify it. 这是一个应该澄清它的代码剪切。 The key is to define a new column type. 关键是定义新的列类型。 In this example Iused "a" for the name of the new column and assigned a medium gray to it: 在这个例子中,我使用了“a”作为新列的名称,并为其分配了一个中等灰度:

\usepackage{xcolor, colortbl}
\definecolor{Gray}{gray}{0.85}
\newcolumntype{a}{>{\columncolor{Gray}}c}


<<xtable1, results=tex, echo=F>>=
xtab<-xtable(d, caption="...", label="tab.myData")
align(xtab) <- c('l', 'c', 'a')
print(xtab, floating=F, include.rownames = F)
@

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM