I would like to know if it's possible to create a custom div class in a Quarto document with a beamer output format. I have tried with adding a custom environment with include-in-header: preamble.tex
, and using ::: {.name_of_environment}
, but it does not work. I expected a similar behavior as when one creates a custom class in css for Quarto html files.
Here's a minimal example. I know I can use shrink
here, but this question applies to other situations as well, where creating a new class/environment in a Quarto beamer document would prove useful.
test.qmd:
---
format:
beamer:
include-in-header: preamble.tex
theme: metropolis
---
## Test slide
<!--- This is too big. I would like the slide to shrink -->
This is a test slide with some content. It has a few points:
- Point one
- Point two
- Point three
- Point four
- Point five
- Point six
- Point seven
- Point eight
And some more content to fill the slide.
The slide also has a note:
::: {.callout-note appearance="minimal"}
This is a note that provides additional information about the test slide.
:::
## Test slide {.customshrink}
<!--- This is too big. I would like the slide to shrink using a custom shrink function defined in preamble.tex -->
This is a test slide with some content. It has a few points:
- Point one
- Point two
- Point three
- Point four
- Point five
- Point six
- Point seven
- Point eight
And some more content to fill the slide.
The slide also has a note:
::: {.callout-note appearance="minimal"}
This is a note that provides additional information about the test slide.
:::
preamble.tex:
\newenvironment{customshrink}
{
\scriptsize%
\setlength{\parskip}{0pt}%
\setlength{\itemsep}{1pt}%
\setlength{\topsep}{0pt}%
}
{
% nothing needed here
}
You could use a custom frame option instead:
---
format:
beamer:
theme: moloch
pdf-engine: lualatex
header-includes:
- \makeatletter
- \providebool{customshrink}
- \define@key{beamerframe}{customshrink}[true]{%
- \booltrue{customshrink}
- \begingroup
- \scriptsize%
- \setlength{\parskip}{0pt}%
- \setlength{\itemsep}{1pt}%
- \setlength{\topsep}{0pt}}
- \pretocmd{\beamer@reseteecodes}{%
- \ifbool{customshrink}{
- \endgroup
- \boolfalse{customshrink}}{}}{}{}
- \makeatother
---
## Test slide {frameoptions="customshrink"}
<!--- This is too big. I would like the slide to shrink -->
This is a test slide with some content. It has a few points:
- Point one
- Point two
- Point three
- Point four
- Point five
- Point six
- Point seven
- Point eight
And some more content to fill the slide.
The slide also has a note:
::: {.callout-note appearance="minimal"}
This is a note that provides additional information about the test slide.
:::
## Test slide
<!--- This is too big. I would like the slide to shrink using a custom shrink function defined in preamble.tex -->
This is a test slide with some content. It has a few points:
- Point one
- Point two
- Point three
- Point four
- Point five
- Point six
- Point seven
- Point eight
And some more content to fill the slide.
The slide also has a note:
::: {.callout-note appearance="minimal"}
This is a note that provides additional information about the test slide.
:::