-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Improve usage of fenced divs for Theorem and Proof environment #1145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This fixes the use of bookdown special environment that are using block2 knitr engine.
all works well in beamer, but not book documentclass. Here is a minimal example.---
title: "book"
output:
bookdown::pdf_book:
toc: no
latex_engine: xelatex
citation_package: natbib
template: null
link-citations: yes
colorlinks: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## some blocks from book
::: {.theorem data-latex="[Metropolis]"}
[WARNING] data-latex attribute can't be used with one of bookdown custom environment. It has been removed.
:::
::: {.theorem name="Metropolis"}
NO WARNING. theorem is ok.
:::
## Some other blocks
::: {.lemma data-latex="[Metropolis]"}
[WARNING] data-latex attribute can't be used with one of bookdown custom environment. It has been removed.
:::
The output is ok. My session info
|
With ::: {.env #id name="NAME"}
::: with
So you example should be ---
title: "book"
output:
bookdown::pdf_book:
toc: no
latex_engine: xelatex
citation_package: natbib
template: null
link-citations: yes
colorlinks: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## some blocks from book
::: {.theorem name="Metropolis"}
A theorem
:::
## Some other blocks
::: {.lemma name="Metropolis"}
A lemma
::: To be clear, this is the way it is supposed to work without this PR. it works this way for HTML and PDF format. Do you expect the same syntax with I really appreciate your feedback because I have a hard time choosing the correct solution for beamer. |
Yes. I feel better if they stay the same. |
Ok I could change that. However, here are the limitations this will lead to:
So
Is that ok ? |
OK, That's awesome! Thanks for your patience and great work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't review the Lua script carefully. Feel free to merge whenever both you and @XiangyunHuang are happy with the PR. Thanks!
Co-authored-by: Yihui Xie <[email protected]>
@XiangyunHuang let's try that then. I'll push the change for you to test. @yihui this is only a matter of choice with the syntax to use for beamer and related potential limitation if we support the bookdown syntax. If you have an opinion feel free to share. Otherwise I'll merge it as soon as we are ok with @XiangyunHuang About the Lua filter, the changes are mainly to update based on |
@XiangyunHuang if you reinstall new this PR this is the syntax to use ---
title: "book"
output:
bookdown::beamer_presentation2:
toc: no
latex_engine: xelatex
theme: Xiaoshan
citation_package: natbib
template: null
link-citations: yes
colorlinks: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## some blocks from book
::: {.theorem name="Metropolis"}
A theorem
:::
::: {.lemma name="Metropolis"}
A lemma
:::
## Some other blocks
::: {.fact latex="[A fact]"}
Some interesting stuff
:::
::: {.problem latex=true}
A problem
:::
Are we merging this ? 😄 |
@cderv only one small problem, theorem and lemma block have extra blank line. |
For HTML we need to generate a dummy label so that the numbering of environment works even if they won't be reference
I did that because we don't need to insert This should work better for you now I guess. But there would still be the new line inserted if you provided an id to use as a label reference. Is this last change better ? @yihui I added manual test file for visual inspection that everything is ok. I hope it is fine. |
That's totally fine. Thanks! |
@XiangyunHuang just waiting for you confirmation before merging this PR. Hope it is ok for you now. I think so but I prefer to check. Thanks ! |
It's OK. Thanks |
This PR closes #1143
After all I think it is best the bookdown does not interfere with beamer. beamer defines its own theorem env with some not supported by bookdown. So it would be lead to have a specific syntax for some env supported by bookdown and another syntax for other
If we don't process beamer output, this means that the syntax is
The syntax offer by bookdown is there because we want the same type of output for these supported environment for HTML and PDF book. I am not sure that when bookdown is used with beamer, the
gitbook()
format is also one output. is it ?The Lua filter is now easy to change - providing support for beamer with bookdown syntax would mean changing this only
So @yihui this is as we discussed : skip bookdown Lua custom environment processing for beamer usage.
I think you know the pro & cons now.
@XiangyunHuang, the below is what is working now with this PR what are your thought ?
Examples
Changes
do not add \newtheorem in preamble when output is beamer format. This fixes the use of bookdown special environment that are using block2 knitr engine.
Only support specific format - beamer defines its own environment so we don't let bookdown feature interfere.
Improve lua filter base on
latex-divs.lua
in rmarkdown