Skip to content
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

Pagebreak shortcode does not work in typst in multiple columns layout #11819

Open
mcanouil opened this issue Jan 8, 2025 · 6 comments
Open
Labels
enhancement New feature or request shortcodes issues related to shortcodes typst

Comments

@mcanouil
Copy link
Collaborator

mcanouil commented Jan 8, 2025

Pagebreak shortcode does not work in typst when using multiple columns layout.

---
title: "Quarto Playground"
format: 
  typst:
    columns: 2
---

This is a playground for Quarto.

{{< lipsum 1 >}}

{{< pagebreak >}}

{{< lipsum 1 >}}

Leading to

pandoc 
  to: typst
  output-file: index.typ
  standalone: true
  shift-heading-level-by: -1
  default-image-extension: svg
  wrap: none
  citeproc: false
  toc: true
  
metadata
  columns: 2
  title: Quarto Playground
  
[typst]: Compiling index.typ to index.pdf...error: pagebreaks are not allowed inside of containers
    ┌─ index.typ:305:1
    │
305 │ #pagebreak()
    │  ^^^^^^^^^^^

ERROR: Error
    at Object.complete (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/command/render/output-typst.ts:79:13)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async file:///Users/mcanouil/Projects/quarto/quarto-cli/src/command/render/render.ts:300:23
    at async withTimingAsync (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/core/timing.ts:50:20)
    at async Object.complete (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/command/render/render.ts:276:7)
    at async Object.onPostProcess (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/command/render/render-files.ts:720:28)
    at async renderFileInternal (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/command/render/render-files.ts:689:3)
    at async renderFiles (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/command/render/render-files.ts:325:9)
    at async render (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/command/render/render-shared.ts:102:18)
    at async renderForPreview (file:///Users/mcanouil/Projects/quarto/quarto-cli/src/command/preview/preview.ts:428:24)

Originally posted by @ironupiwada in #11591 (reply in thread)

@mcanouil mcanouil added bug Something isn't working typst shortcodes issues related to shortcodes enhancement New feature or request and removed bug Something isn't working labels Jan 8, 2025
@mcanouil
Copy link
Collaborator Author

mcanouil commented Jan 8, 2025

That's not really a bug as Typst uses a different break when inside columns:

---
title: "Quarto Playground"
format: 
  typst:
    columns: 2
---

This is a playground for Quarto.

{{< lipsum 1 >}}

`#colbreak()`{=typst}

{{< lipsum 1 >}}

`#colbreak()`{=typst}

{{< lipsum 5 >}}

I don't know if the {{< pagebreak >}} shortcode could be enhanced here to support switching to colbreak when multi-columns layout.

@cscheid
Copy link
Collaborator

cscheid commented Jan 8, 2025

We can try to do something smarter, but the problem is that the number of columns isn't fixed in a Typst document (it's scoped), so we can't just check the metadata.

@mcanouil
Copy link
Collaborator Author

mcanouil commented Jan 8, 2025

I would not try to cover all uses cases, only the case when columns is set because most if not all other cases would be specific to Typst thus the user should/would use raw Typst.

@mcanouil
Copy link
Collaborator Author

mcanouil commented Jan 8, 2025

FYI, in my opinion, the pagebreak shortcode is only a convenient/simple way to get a page break across formats, but Typst page break is more flexible (https://typst.app/docs/reference/layout/pagebreak/) so in the context of Typst, the shortcode is more a limitation.

@gordonwoodhull
Copy link
Contributor

We can try to do something smarter, but the problem is that the number of columns isn't fixed in a Typst document (it's scoped), so we can't just check the metadata.

Could a scoped traversal help here?

@cscheid
Copy link
Collaborator

cscheid commented Jan 10, 2025

That qualifies as smarter, yes :) (It still won't work if someone changes the columns in a raw block... But I think I'd be fine with that.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request shortcodes issues related to shortcodes typst
Projects
None yet
Development

No branches or pull requests

3 participants