I’ve decided to output reports in html (using parametrization in Quarto) and then export those separate reports as pdfs. It seems like there just aren’t the same capacities with table packages, creating pdfs, and Quarto.
Essentially, I’m trying to mostly reproduce the screen shot below. The second screen shot is where I am at now. I’ve then created a min repo example to try and identify what isn’t working.
To create the first screen shot in Quarto, it seems that it will be best to create two columns using CSS and the grid system. This seems to allow more control (for instance, in the first screen shot, I could put writing on right side for completion). It also does seem to provide a more sleek looking document.
However, as you can see in the second screen shot (where I have applied #| layout-ncol = 2
, it does not appear to be working. Min repo example comes out a bit differently, but overall, similar issues (there just aren’t two columns at all). In the doc I created (second screen shot) there don’t appear to be two columns (tables are crossing the mid-section of the doc to the right and left). Second, the tables are no longer the same size (despite that I put %>%as_raw_html()
. I’ve read Quarto docs on creating columns (.html#grid-customization; .html); #| layout-ncol = 2
does not appear to be working. Maybe the answer is to dig deeper into css grid system; in that case, I’m not really sure how something like below would translate into knitr with Quarto. It seems like Quarto in r uses #| instead?
::: {layout="[ 40, 60 ]"}
::: {#first-column}
# Some code
Some text that should be laid out below the code
:::
::: {#second-column}
![](elephant.png)
:::
::::
Second, it does seem that if I use a two column layout, I could more easily create the layout at the bottom of the pdf (first screen shot) where “Screening and Referral Tracking” isn’t really a table, but it is organized. I know that a line can be created using ---
however, I can’t figure out how to adjust the color or thickness of the line. I found this () but the code doesn’t seem to make a difference. Or maybe I’m just not translating it for knitr in the correct way? (See min repo).
Third, I’m trying to figure out how to adjust the size of inline code (specifically for the individual statistics). I found this resource: In Quarto, how do I write inline CSS?. I try wrapping the statistic with brackets but that doesn’t work. See min repo example.
Thanks!
PDF I'm trying to recreate:
What output looks like now (you can see how close disability and race are):
Min repo
```
---
title: "min_repo_example_tables"
header-includes: #allows you to add in your own Latex packages
- \usepackage{float} #use the 'float' package
- \floatplacement{figure}{H} #make every figure with caption = h
format:
html:
keep-tex: true
fig-pos: "H"
tbl-pos: "H"
df-print: paged
page-layout: custom
execute:
echo: false
warning: false
error: true
editor: visual
---
```{r}
library(tidyverse)
library(gt)
cyl_mpg = mtcars%>%
group_by(cyl)%>%
summarize(mpg = round(mean(mpg), 2))
cyl_mpg_tab = cyl_mpg%>%
gt()%>%
as_raw_html()
gear_mpg = mtcars%>%
group_by(gear)%>%
summarize(mpg = round(mean(mpg), 2))
gear_mpg_tab = gear_mpg%>%
gt()%>%
as_raw_html()
cyl_mpg_plot <- ggplot(cyl_mpg, aes(x= cyl, y=mpg)) +
geom_bar(stat="identity", width=0.5, fill = "#56B4E9")+
geom_text(aes(label= mpg), vjust=-.3,
position = position_dodge(width=0.9), size=6) +
theme_classic()
gear_mpg_plot <- ggplot(gear_mpg, aes(x= gear, y=mpg)) +
geom_bar(stat="identity", width=0.5, fill = "#56B4E9")+
geom_text(aes(label= mpg), vjust=-.3,
position = position_dodge(width=0.9), size=6) +
theme_classic()
stat = sum(unique(mtcars$carb))
```
---
I would like this `{r} stat` to be bigger than the text
---
```
`\rule{\linewidth}{5cm}`{=tex}
```
```{r}
#| layout-ncol = 2
##| [[20,-1,20], [20, -1, 20], [20, -1, 20]]
cyl_mpg_plot
cyl_mpg_tab
gear_mpg_plot
gear_mpg_tab
#`\rule{\linewidth}{5cm}`{=tex}
cyl_mpg_tab
gear_mpg_tab
```
```