How do I force pagebreak in jupyter cell for typst output #11164
-
DescriptionFollowing document produces typst error: ---
title: |
Report
format:
typst:
papersize: a4
margin:
x: 2cm
y: 2cm
keep-typ: true
keep-md: true
execute:
echo: false
---
```{python}
from IPython.display import Markdown
from IPython.display import display
```
```{python}
display(Markdown("## Test 1"))
display(Markdown("Some Text"))
display(Markdown("{{< pagebreak >}}"))
display(Markdown("## Test 2"))
display(Markdown("Some Text"))
```
The page break in the last cell is wrapped into a typst block, but no page breaks are allowed in typst blocks. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
I don't think you need to use |
Beta Was this translation helpful? Give feedback.
-
You need If this is not used, then only the last Markdown will work. So you would need to only used one per cell ---
title: |
Report
format:
typst:
papersize: a4
margin:
x: 2cm
y: 2cm
keep-typ: true
keep-md: true
execute:
echo: false
---
```{python}
from IPython.display import Markdown
```
```{python}
Markdown(r"""## Test 1
Some Text
{{< pagebreak >}}
## Test 2
Some Text""")
``` Hope it helps. |
Beta Was this translation helpful? Give feedback.
-
This helps indeed. However I need to have images on each page, but I'm unable to combine this approach together with images. ---
title: Parameter Report
format:
typst:
papersize: a4
fontsize: "11pt"
margin:
x: 2cm
y: 2cm
template-partials:
- "typst-template.typ"
keep-typ: true
keep-md: true
execute:
echo: false
---
```{python}
from IPython.display import Markdown
from IPython.display import display
import matplotlib.pyplot as plt
import numpy as np
```
# Data
```{python}
#| output: asis
x = np.linspace(0,10)
y1 = np.sin(x)
y2 = np.cos(x)
Markdown("## Experiment 1")
fig, axes = plt.subplots(squeeze=False)
axes[0, 0].plot(x, y1)
fig
Markdown(r"""## Test 1
Some Text
{{< pagebreak >}}
## Test 2
Some Text""")
Markdown("## Experiment 2")
fig2, axes = plt.subplots(squeeze=False)
axes[0, 0].plot(x, y2)
fig2
``` |
Beta Was this translation helpful? Give feedback.
-
After a few more tests I'm a little bit closer to the solution I think ---
title: Parameter Report
format:
typst:
papersize: a4
fontsize: "11pt"
margin:
x: 2cm
y: 2cm
keep-typ: true
keep-md: true
execute:
echo: false
ipynb-shell-interactivity: none
---
```{python}
from IPython.display import Markdown
from IPython.display import display
import matplotlib.pyplot as plt
import numpy as np
```
# Data
Introduction Page....
```{python}
#| output: asis
for i in range(5):
display(Markdown("""
{{< pagebreak >}}
"""))
display(Markdown(f"## Experiment {i+1}"))
x = np.linspace(0,i+3)
y1 = np.sin(x)
fig, axes = plt.subplots(squeeze=False)
axes[0, 0].plot(x, y1)
display(fig)
fig, axes
display(Markdown(
"""
### Result
this was really good
"""))
``` I still have the issue that all the plots arrive at the end of the block again? I thought Below is the intermediate md file: ---
title: Parameter Report
format:
typst:
papersize: a4
fontsize: "11pt"
margin:
x: 2cm
y: 2cm
keep-typ: true
keep-md: true
execute:
echo: false
ipynb-shell-interactivity: none
---
# Data
Introduction Page....
{{< pagebreak >}}
## Experiment 1
{}
### Result
this was really good
{{< pagebreak >}}
## Experiment 2
{}
### Result
this was really good
{{< pagebreak >}}
## Experiment 3
{}
### Result
this was really good
{{< pagebreak >}}
## Experiment 4
{}
### Result
this was really good
{{< pagebreak >}}
## Experiment 5
{}
### Result
this was really good
{}
{}
{}
{}
{}
``` |
Beta Was this translation helpful? Give feedback.
Sorry I missunderstood... I thought only top-level expressions are collected and the rest is ignored.
However I think I found a working solution:
plt.ioff()