0

I want to decrease the height of a table to half of its size. I tried to use the function height and row_height it did not work. If I decrease the font size and set all padding to zero it helps but then when I try to decrease the row height nothing happens. Does anyone knows how to use this function height or row_height?

If you look at the output of the code bellow you can see that there is some space on top of the cells. I want to decrease that space.

If I get the tex code out of this and add manually resizebox it gests closer to what I want but I wanted to know if I could do that using only R markdown.

Thanks!

Here is the code

---
pdf_document: default
title: "Changing Table Height with huxtable Package"
output: 
  pdf_document: 
    keep_tex: yes
---

```{r, echo=FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE)


library(huxtable)

# create a sample table
my_table <- huxtable(
  c("Header 1", "Header 2", "Header 3"),
  c(1, 2, 3),
  c(4, 5, 6)
)
my_table <- set_all_borders(my_table)
my_table <- set_caption(my_table,"Table without changes")
my_table

# decrease the row heights
my_table <- set_all_borders(my_table)
my_table <- set_caption(my_table,"all padding set to zero")
#my_table <- set_row_height(my_table, 1:3, .002)
my_table <- set_all_padding(my_table,1:3,1:3, 0)
my_table

# decrease the font size
my_table <- set_caption(my_table,"Table with smaller font size")
my_table <- set_font_size(my_table,1:3,1:3, 5)
#my_table <- set_row_height(my_table, 1:3, .002)
my_table

```
shafee
  • 15,566
  • 3
  • 19
  • 47

0 Answers0