quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.92k stars 322 forks source link

quarto-1.4.80-macos unable to recognize the content of the "block" in div when compiling beamer. #5617

Open williamlorder opened 1 year ago

williamlorder commented 1 year ago

Bug description

A very frustrating problem, which did not exist in my previous version.

I want to input the Block block in beamer as follows in QMD:

:: {.block} content :::

So that it can be displayed as a block in be after compilation. This was successfully done in previous versions, but cannot be achieved in the latest(quarto-1.4.80-macos). After compilation, only content is displayed instead of the block.

Has this feature been removed from new version or is it just a bug?

Checklist

mcanouil commented 1 year ago

Thanks for the report!

Could you share a small "working" (reproducible) example to work with, i.e., a complete Quarto document or a Git repository? Thanks.

You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````).

````qmd
---
title: "Reproducible Quarto Document"
format: html
---

This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.

```{r}
plot(cars)

The end.

williamlorder commented 1 year ago

Sure, mcanouil ! Here is a simple reproduction example

---
title: "XXXX"
author: 
  - "XXX"
institute: "XXXX"
date: "2023/5/22"
format:
  beamer:
    aspectratio: 1610 
    navigation: horizontal #
    theme: "Boadilla"
    colortheme: "beaver"
    # fonttheme: "structurebold"
    # fontfamily: "arev"
    toc: true
    # number-sections: true
    # documentclass: ctexbeamer
    colorlinks: true 
    slide-level: 2
    # toc: true   
pdf-engine: xelatex
# bibliography: "/Users/zekai/References.bib"
---

# Section 1

## Subsection 1

:::{.block}
BLOCK EXAMPLE
:::

What I expect is

截屏2023-05-21 21 47 22

(I used latex syntax to generate the block like

\begin{block}
BLOCK EXAMPLE
\end{block}

is worked(use tex syntax in quarto). But failed when use div syntax which is valid for a certain version(I can't quite remember it, maybe some version from the previous year)

)

It came with the following screenshot:

截屏2023-05-21 21 44 48
dragonstyle commented 1 year ago

I'm not aware of any versions of Quarto natively behaving the way you describe - there is an extension you can install which adds support for this behavior:

https://github.com/quarto-ext/latex-environment

HTH!

cderv commented 1 year ago

@williamlorder the block fenced div is an "undocumented" Pandoc feature, but it requires to set a Block title using a nested header - here level 3 ###

Try this

---
title: "XXXX"
author: 
  - "XXX"
institute: "XXXX"
date: "2023/5/22"
format:
  beamer:
    aspectratio: 1610 
    navigation: horizontal #
    theme: "Boadilla"
    colortheme: "beaver"
    toc: true
    colorlinks: true 
    slide-level: 2
pdf-engine: xelatex
---

# Section 1

## Subsection 1

:::{.block}
### Block title
BLOCK EXAMPLE
:::

I say undocumented because https://github.com/jgm/pandoc/issues/7937 has the detail only

it is a behavior not clear from their doc at https://pandoc.org/MANUAL.html#structuring-the-slide-show

Headings below the slide level in the hierarchy create headings within a slide. (In beamer, a “block” will be created. If the heading has the class example, an exampleblock environment will be used; if it has the class alert, an alertblock will be used; otherwise a regular block will be used.)

This means that any title below slide level will create a block.

So this is Pandoc behavior mainly, and I believe it still works with Quarto.

A very frustrating problem, which did not exist in my previous version.

Were you using block in fenced div without having a title inside ?

dragonstyle commented 1 year ago

the block fenced div is an "undocumented" Pandoc feature

TIL :)

mcanouil commented 1 year ago

There are a lot of undocumented "features" in Pandoc[^1]. 😅

[^1]: are they really features or unintended behaviours. 😏

williamlorder commented 1 year ago

@williamlorder the block fenced div is an "undocumented" Pandoc feature, but it requires to set a Block title using a nested header - here level 3 ###

Try this

---
title: "XXXX"
author: 
  - "XXX"
institute: "XXXX"
date: "2023/5/22"
format:
  beamer:
    aspectratio: 1610 
    navigation: horizontal #
    theme: "Boadilla"
    colortheme: "beaver"
    toc: true
    colorlinks: true 
    slide-level: 2
pdf-engine: xelatex
---

# Section 1

## Subsection 1

:::{.block}
### Block title
BLOCK EXAMPLE
:::

I say undocumented because jgm/pandoc#7937 has the detail only

it is a behavior not clear from their doc at https://pandoc.org/MANUAL.html#structuring-the-slide-show

Headings below the slide level in the hierarchy create headings within a slide. (In beamer, a “block” will be created. If the heading has the class example, an exampleblock environment will be used; if it has the class alert, an alertblock will be used; otherwise a regular block will be used.)

This means that any title below slide level will create a block.

So this is Pandoc behavior mainly, and I believe it still works with Quarto.

A very frustrating problem, which did not exist in my previous version.

Were you using block in fenced div without having a title inside ?

You are right, After using ### title you mentioned,it works!

The documentation of Pandoc is a mess. It's hard to find anything of reference value.

williamlorder commented 1 year ago

Can this section added to Quarto's Beamer documentation? I believe the Block feature is important for Beamer presentation.I've summarized various Blocks are presented in pandoc below.

:::{.block}
### Simple block
:::

:::{.alert}
### Alert block

:::

:::{.example}
### Example block

:::

Thanks!

cderv commented 1 year ago

Yes we could add it to https://quarto.org/docs/presentations/beamer.html probably.

Though another usage following Pandoc's doc

Headings below the slide level in the hierarchy create headings within a slide. (In beamer, a “block” will be created. If the heading has the class example, an exampleblock environment will be used; if it has the class alert, an alertblock will be used; otherwise a regular block will be used.

would be to write it like this

---
title: Test
format: beamer
keep-tex: true
slide-level: 2
---

## Slide

### Simple block

Content

### Alert block {.alert}

Content

### Example block {.example}

Content

Just adding for reference when we document it

allenmanning commented 1 year ago

@cwickham For consideration to add to our documentation.

cderv commented 1 year ago

@tarleb do you know what is exactly the pandoc supported feature for this, specific to beamer ?

https://github.com/jgm/pandoc/issues/7937 is still open and it would nice to have this documented better in Pandoc so that if we document we rely on Pandoc's expected behavior and not possible side effect.

For example, I believe this related to this part in the doc: https://pandoc.org/MANUAL.html#frame-attributes-in-beamer and maybe example should be added there ?

Just to confirm if / when block syntax is to be used compared to slide attributes uses classes on headers.

Thanks !

cwickham commented 4 months ago

@cderv I have added your example to the Beamer docs with https://github.com/quarto-dev/quarto-web/pull/1206

I didn't add the ::: {.block} example since we don't have confirmation this is stable/intended behavior. I'll leave this issue open, but move it to Future for that case.