cssrr-markdownflextablexaringan

In xaringan, how to change the margin under flextable title?


Let's say I have the following xaringan document:

---
title: "Test"
author: 
  - "me"
date: "2022-06-20"
output:
  xaringan::moon_reader:
    css: [default, ninjutsu]
    seal: false
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---
```{r table, tab.cap="Iris", echo=F, warning=F, message=F}
library(tidyverse)
library(flextable)

iris %>%
  head() %>%
  flextable() %>%
  theme_booktabs()
```

which renders like this:

enter image description here

Now I wish to change the spacing between the flextable title and the table itself. What should I do?

enter image description here


Solution

  • I have no idea where the settings to be changed are defined, but when changing them, the extra space disappears... It needs to be done in css and the properties to set to 0 are 'margin-block-start' and 'margin-block-end'.

    ---
    title: "Test"
    author: 
      - "me"
    date: "2022-06-20"
    output:
      xaringan::moon_reader:
        css: [default, ninjutsu]
        seal: false
        nature:
          highlightStyle: github
          highlightLines: true
          countIncrementalSlides: false
    ---
    
    ```{css}
    p {
      margin-block-start: 0px;
      margin-block-end: 0px;
    }
    ```
    
    
    ```{r table, tab.cap="Iris", echo=F, warning=F, message=F}
    library(tidyverse)
    library(flextable)
    
    iris %>%
      head() %>%
      flextable() %>%
      theme_booktabs()
    ```