KableExtra Conditional Formatting offset by one row??

i'm trying to use kableextra for conditional formatting however when i run it in r or knit to html, it works out fine. but when i knit it to pdf it seems like offset by one row.. not sure what's going on.. please help~

---
title: "VehClass GWP"
output: pdf_document
# output: html_document
---

```{r, include = FALSE}
library(tidyverse)
library(kableExtra)
library(lubridate)
library(rmarkdown)
library(knitr)
library(tinytex)

summary = data.frame(VEHCLS = c("GA", "GC", "GV"),
                     GWP_2020 = c(100, 50, 75),
                     GWP_2021 = c(150, 100, 200))
summary %>%
  kbl(.,
      align = c("l", rep("r", 2)),
      booktabs = T,
      col.names = NULL) %>%
  kable_styling(bootstrap_options = c("striped", "bordered", "condensed"),
                latex_options = "hold_position",
                font_size = 10) %>%
  column_spec(2, background = ifelse(summary[, 2] < 75, "red", "white")) %>%
  # # add column headers
  add_header_above(c("VehClass", "2020", "2021")) %>%
  add_header_above(c("", "GWP" = 2))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.