Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latex output #139

Open
tgrrr opened this issue Oct 29, 2020 · 0 comments
Open

latex output #139

tgrrr opened this issue Oct 29, 2020 · 0 comments

Comments

@tgrrr
Copy link

tgrrr commented Oct 29, 2020

Big fan, great package.

I'm trying to output my formattable tables using latex. I've tested using pandoc, xelatex, etc. But All I get is a 1 inch wide column with no background.

Screen Shot 2020-10-30 at 1 21 09 am

It works fine with HTML output

Screen Shot 2020-10-30 at 1 22 19 am

Code for reference:

---
title: "Formattable example"
output:
  pdf_document
---

```{r}
library(formattable)
customGreen0 = "#DeF7E9"
customGreen = "#71CA97"

PropertyNo <- c(1:5)
Area <- c(600,800,1500,2500,250)
Bedrooms  <- c(2, 3, 2, 5, 3)
Bathrooms<- c(2, 1, 1, 4, 2)
CarParks <- c(1, 2, 1, 4, 1)
PropertyType <- c(1, 0, 0, 0, 1)

prediction_df = data.frame(PropertyNo, Area, Bedrooms, Bathrooms, CarParks, PropertyType)

formattable(prediction_df, list(
	`PropertyType` = formatter("span",
		style = x ~ style(color = ifelse(x, "grey", "black")),
		x ~ icontext(ifelse(x, "house-door", ""), ifelse(x, "Unit", "House"))),
	`Bedrooms`= color_tile(customGreen0, customGreen),
	`Bathrooms`= color_tile(customGreen0, customGreen),
	`CarParks`= color_tile(customGreen0, customGreen)
))

Version:

Latest (2.0.1) from CRAN
MacOS: Mojave
R: 4.0.2

Tested with knitting in RStudio and terminal. Ie.

Rscript -e 'rmarkdown::render("notebooks/formattable-demo.Rmd")';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant