2

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
  }
2
  • 1
    You shouldn't use the metropolis theme. It is more or less incompatible with the current beamer version and just held together with a lot of duck tape. Have a look at the moloch theme instead. Commented Jul 3 at 10:11
  • This is a great suggestion, thanks! Because the moloch theme has a lower paragraph spacing default, this saves my problem! But I'm still interested to know if there is possibility to create custom environment and use Quarto/Pandoc divs to render them Commented Jul 3 at 10:19

1 Answer 1

1

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.
:::

enter image description here

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

This looks great! Where can I find documentation on how this works? This looks a bit cryptic to me.
@Maël As \define@key is an internal beamer macros, this isn't documented anywhere.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.