Quarto chunk output is misplaced from the header ll Rstudio-Quarto

40 views Asked by At

I'm using quarto to generate a pdf, All of my chunks consist of two object, flextable and an gglot, my chunks looks as follow:

Header 1

Header 2

#| layout-ncol: 2

flextable(db) %>%
        fontsize(size=5,part = "all") %>%
        theme_vanilla() %>%
        align(align = "center",part="all") %>%
  width(width = 18,unit="mm") %>% height(height = .8,unit="mm") %>% 
  padding(padding = 2,part="all") %>% 
  line_spacing(space = .5,part = "body") 

ggplot(db,aes(x=ymd,y=cons)) +
  geom_line(size=2.5,position = position_jitter(width = 1,seed=123),color="#06334B")+
  geom_point(color="#06334B",size=5)+  theme(axis.text.x=element_text(angle=-90,size =22),plot.title = element_text(hjust=.5,size=35),strip.text.x = element_blank(),axis.text.y = element_text(size=20),text = element_text(size=30))

Header 3

#| layout-ncol: 2

flextable(db) %>%
        fontsize(size=5,part = "all") %>%
        theme_vanilla() %>%
        align(align = "center",part="all") %>%
  width(width = 18,unit="mm") %>% height(height = .8,unit="mm") %>% 
  padding(padding = 2,part="all") %>% 
  line_spacing(space = .5,part = "body") 

ggplot(db,aes(x=ymd,y=cons)) +
  geom_line(size=2.5,position = position_jitter(width = 1,seed=123),color="#06334B")+
  geom_point(color="#06334B",size=5)+  theme(axis.text.x=element_text(angle=-90,size =22),plot.title = element_text(hjust=.5,size=35),strip.text.x = element_blank(),axis.text.y = element_text(size=20),text = element_text(size=30))

Header 4

#| layout-ncol: 2

flextable(db) %>%
        fontsize(size=5,part = "all") %>%
        theme_vanilla() %>%
        align(align = "center",part="all") %>%
  width(width = 18,unit="mm") %>% height(height = .8,unit="mm") %>% 
  padding(padding = 2,part="all") %>% 
  line_spacing(space = .5,part = "body") 

ggplot(db,aes(x=ymd,y=cons)) +
  geom_line(size=2.5,position = position_jitter(width = 1,seed=123),color="#06334B")+
  geom_point(color="#06334B",size=5)+  theme(axis.text.x=element_text(angle=-90,size =22),plot.title = element_text(hjust=.5,size=35),strip.text.x = element_blank(),axis.text.y = element_text(size=20),text = element_text(size=30))

The first chunk works perfectly, the output is properly showing after ##Header2, but for the next ones, all the following headers, ##Header3 ,..., ##Header n , are showing before all chunks outputs

A long time ago I had a similar problem using kable, and I'd fix it with kableExtra using "HOLD_position" argument, I'm wondering if exist something like that for flextable or if my problem is for different reason as was it for kable table.

0

There are 0 answers