Hmisc latex cell background color

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Hmisc latex cell background color

Dieter Menne
Dear latex/R-Sweavers,

Using the codel below, I can color text in individual cells for latex
output.
Is there a similar way to get a background shading? My attempts failed
because I did not get the closing brace at the right place with Hmisc/latex.

library(Hmisc)

x <- as.data.frame(diag(rnorm(3),nrow=3))
cellTex <- matrix(rep("", NROW(x) * NCOL(x)), nrow=NROW(x))
cellTex[2,2] <- "\color{red}"
ct <- latex(x, cellTexCmds = cellTex,numeric.dollar=FALSE)
ct$style <- "color"
dvi(ct)


Dieter

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Hmisc latex cell background color

David Whiting
Hi Dieter,

The nearest I got to was to be able to colour row. Take a look at Table
10 here:

http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatReport/latexFineControl.pdf

I used the latex package colotbl (see the definition of \shadeRow in
section 1). I didn't play any further with this. It might be possible
that colortbl has further commands ora mechanism for colouring
individual cells.

Dave


Dieter Menne wrote:

> Dear latex/R-Sweavers,
>
> Using the codel below, I can color text in individual cells for latex
> output.
> Is there a similar way to get a background shading? My attempts failed
> because I did not get the closing brace at the right place with Hmisc/latex.
>
> library(Hmisc)
>
> x <- as.data.frame(diag(rnorm(3),nrow=3))
> cellTex <- matrix(rep("", NROW(x) * NCOL(x)), nrow=NROW(x))
> cellTex[2,2] <- "\color{red}"
> ct <- latex(x, cellTexCmds = cellTex,numeric.dollar=FALSE)
> ct$style <- "color"
> dvi(ct)
>
>
> Dieter
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

--
David Whiting
School of Clinical Medical Sciences, The Medical School
University of Newcastle upon Tyne, NE2 4HH, UK.

"In God we trust, all others must bring data"  W. Edwards Deming

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Hmisc latex cell background color

Dieter Menne
David Whiting <david.whiting <at> ncl.ac.uk> writes:

> The nearest I got to was to be able to colour row. Take a look at Table
> 10 here:
>
>
http://biostat.mc.vanderbilt.edu/twiki/pub/Main/StatReport/latexFineControl.pdf
>

After some private emailing with David and downloading the latest version of
the docs, I found the new command \cellcolor in colortbl, which makes coloring
of single cells painless.

Deter

library(Hmisc)

x <- as.data.frame(diag(rnorm(3),nrow=3))
cellTex <- matrix(rep("", NROW(x) * NCOL(x)), nrow=NROW(x))
cellTex[2,2] <- "\cellcolor{red}"
ct <- latex(x, cellTexCmds = cellTex,numeric.dollar=FALSE)
ct$style <- "colortbl" # this forces load of colortbl (not documented?)
dvi(ct)

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html