Skip to content

Typst - do not hardcode #figure() in Table writer? #9777

Closed
@cscheid

Description

@cscheid

Would Pandoc take a PR that enabled the Typst writer to disentangle the emission of #figure() from #table()? Or, minimally, a PR that would stop Pandoc from emitting #figure() when no caption or identifier are present?

Explain the problem.

Pandoc currently is unable to emit table code in Typst without also emitting a figure(): https://github.com/jgm/pandoc/blob/main/src/Text/Pandoc/Writers/Typst.hs#L276-L294

$ pandoc -f markdown -t typst
| f | b |
|---|---|
| 1 | 2 |
#figure(
  align(center)[#table(
    columns: 2,
    align: (auto,auto,),
    table.header([f], [b],),
    table.hline(),
    [1], [2],
  )]
  , kind: table
  )

This makes it quite hard to write Pandoc documents that put a Typst table inside a crossref environment of any other kind, or that would include a table without incrementing the table typst counter by virtue of the surrounding #figure().

Typst figures accept kind variables other than table and figure. Notably, we use that in Quarto for subfigures and custom crossrefs ("Supplemental Table..."). In Pandoc 3.2, counters will be necessarily incorrect (and hard to fix) when users refer to tables in different environments.

Pandoc version?

$ pandoc --version
pandoc 3.2
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /Users/cscheid/.local/share/pandoc
Copyright (C) 2006-2024 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions