How to end a header 3 box in rmarkdown beamer madrid presentation?
Asked Answered
I

2

11

When using the Madrid beamer theme (and some others) the Header 3 is rendered as a box covering the whole section, but in markdown the header is only specified at the start. How can I specify the end of the section?

In the example below, I want the second sentence to be inside the box, but the third to be back on the white background.

Example:

---
title: "Example"
output: 
  beamer_presentation:
    colortheme: beaver
    theme: Madrid
---

## Slide with Box

Hello, I'm not in the box

### This is a box
And this text is in the box!


I don't want to be in the box, but I am.

Output

enter image description here

Inauspicious answered 9/12, 2014 at 13:2 Comment(1)
@zx8754 that doesn't work for me.Hundredweight
T
9

This works for me:

## Slide with block 2

Hello, I'm not in the block.

\begin{block}{This is a block}
  And this text is in the block!
\end{block}


Hi, I'm not in the block either!
Tman answered 9/12, 2014 at 13:21 Comment(2)
Clever - switching down to the LaTeX directly, the markdown then ignores the LaTeX and passes it through. PerfectInauspicious
It still works for me, can you be more specific on how it does not work? (OS, R version, RStudio version etc)Tman
T
5

With newer versions of Pandoc (I have 2.2.3.2), you can use fenced divs to enclose a block. Did not work for me previously with 1.6.

Thus, this would work:

## Slide with Box

Hello, I'm not in the box

::: {.block}
### This is a box
And this text is in the box!
:::

I don't want to be in the box, and I am not.

::: {.block} and ::: delimit the block. See https://github.com/jgm/pandoc/issues/2957

An advantage with respect to using \begin{block} and \end{block} is that you get to use markdown within the block.

Tribute answered 29/8, 2018 at 13:6 Comment(1)
This solution has the advantage, that you can use markdown within the block. text makes the word "text" bold. This does not work with plain LaTexPaderewski

© 2022 - 2024 — McMap. All rights reserved.