adjust row height

How to adjust row height in kable, so the table looks not so crowded in pdf output. Thanks in advance!


title: ''
geometry: margin=2cm
output:
pdf_document:
latex_engine: xelatex
urlcolor: blue
classoption: landscape

knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(dev = 'pdf', fig.width = 12, fig.height = 7)
library(tidyverse)
library(kableExtra)
library(data.table)
test <- mtcars
test1 <- setDT(test, keep.rownames = TRUE[]) %>% 
  select(rn,cyl,mpg) %>% filter(cyl==4)

cat("\n\n\\pagebreak\n")
carsub <- test1 %>% 
select(
  "Car Name and Model"=rn, 
  "Cylinders"=cyl, 
  "Mileage Per Gallon"=mpg) 
carsub %>%
  kable(digits=1) %>% column_spec(1, width="11cm",border_left = TRUE) %>% 
                      column_spec(2:4, width="1.8cm") %>%
                      column_spec(5,width="1.8cm",border_right = TRUE)%>%
                      kable_styling("bordered", font_size = 11)

You could put \renewcommand{\arraystretch}{2} in just above your chunk.

See the answer here: https://stackoverflow.com/questions/53794142/increase-line-row-spacing-with-kableextra

1 Like

Perfect! Thank you so much!

This topic was automatically closed 7 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.