Quantcast
Channel: Active questions tagged kable - Stack Overflow
Viewing all articles
Browse latest Browse all 108

How do I remove unwanted white line artifacts from Kbl table?

$
0
0

When I have a black background for cells using kbl I get unwanted white artifacts between the gridlines and the cells (Photo 1). There are also artifacts with gray and white backgrounds(photo 2).This might not be possible to fix because of the conversion between LaTeX and PDF. Depending on the zoom level of the PDF these lines can appear vertically, horizontally, both, or not appear at all(Photo 3).

EDIT: Grzegorz suggested it was a viewer issue which it turned out to be.

I tried setting the entire table to black and then building off of it. That way if the white lines were from the pdf document itself they would be covered by a large black box.

Here's the original code:

kbl(data, align = rep("c", ncol(data))) %>%  kable_styling(font_size = 4, latex_options = c("scale_down", "hold_position")) %>%  column_spec(c(12,13), color = "white",background = "black", include_thead = TRUE, width = "1cm", bold = T) %>%  # column_spec(c(10,11), color = "white", include_thead = TRUE, width = "1cm") %>%  column_spec(c(4,6,8,10,14), background = "lightgray", include_thead = FALSE, width = ".6cm") %>%  column_spec(c(5,7,9,11,15), background = "white", include_thead = FALSE, width = ".6cm") 

Here's my latest attempt to fix it:

kbl(data, align = rep("c", ncol(data))) %>%  kable_styling(font_size = 4, latex_options = c("scale_down", "hold_position")) %>%  column_spec(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14), background = "black", include_thead = FALSE) %>%  column_spec(c(12,13), color = "white",background = "black", include_thead = TRUE, width = "1cm", bold = T) %>%  # column_spec(c(10,11), color = "white", include_thead = TRUE, width = "1cm") %>%  column_spec(c(4,6,8,10,14), background = "lightgray", include_thead = FALSE, width = ".6cm") %>%  column_spec(c(5,7,9,11,15), background = "white", include_thead = FALSE, width = ".6cm")  %>%  column_spec(c(1,2,3), background = "white", include_thead = TRUE) 

This is in an R Markdown file and here is the YAML for that:

---title: | | ![](images/BrandImage.jpg){width=2in} | `r unlist(strsplit(params$fullname,split = '_'))[2]` Forecastparams:  fullname: "placeholder"  vendorNo: "placeholder"output: pdf_document:   latex_engine: xelatexmainfont: Segoe UIclassoption: landscape---

Libraries:

library(tidyverse)library(tinytex)library(glue)library(knitr)library(glue)library(dplyr)library(scales)library(kableExtra)library(readxl)

Viewing all articles
Browse latest Browse all 108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>