A New Typst Template for Pandoc (2025)

(imaginarytext.ca)

73 points | by ankitg12 2 days ago

7 comments

  • Gethsemane 34 minutes ago
    Very nice! I also like working from pandoc where possible - being able to split the output into a latex/typst file as well as a docx is very handy, especially when working with collaborators who are more comfortable with word. I wish markdown would see more support in scientific writing - it would solve so many of the headaches with formatting etc (and reduce microsoft's dominance in research)
  • llimllib 7 hours ago
    I wish the article showed what the markdown format for working with typst and pandoc looked like, and what an output PDF looked like. I have no idea whether I'm interested or not from this article
  • jwr 47 minutes ago
    Incidentally, I developed my own template for a markdown rendering pipeline: markdown -> pandoc -> typst, with mermaid diagrams.

    This works very, very well. I get linked in-document references, diagrams, tables, table of contents — everything I need for my design documents (and consulting work).

  • bobek 1 hour ago
    This template is a great starting point. I have tweaked [0] it for A4 and two-column output, if anybody is interested.

    [0]: https://www.bobek.cz/til/pandoc-markdown-typst/

  • Terretta 6 hours ago
    From the article:

    Last summer … Fast-forward to spring 2025. In the intervening months, Typst has been upgraded twice (to v0.13) and Pandoc has upgraded at least 3 times (currently at v3.6.4), and my templates don’t work anymore.

    This template is from March 2025, and we're now May 2026, with four more releases to Typst 0.14.2 (December 12, 2025), and with Pandoc 3.9.0.2 (2026-03-19).

  • LAC-Tech 6 hours ago
    At the risk of making a fool of myself in-front of the rest of the class, I will come out and admit I don't know what the article is talking about.

    > Last summer I spent a lot of time with Typst (at that point v0.11) and Pandoc, working on a flexible and reusable workflow to typeset markdown-formatted articles to PDF.

    I understand that Typst is a markup language that can output a pdf file (big Typst fan btw).

    I understand Pandoc is a thing that transforms documents of one kind to documents of another, ie markdown to html.

    But the author wants to "typeset markdown-formatted article to PDF". Which makes me wonder what this has to do with typst at all.

    • thornewolf 6 hours ago
      The author explain this in more detail in the article; I also was initially confused. The key details come from their broken down pandoc command. Specifically, these two flags:

        --pdf-engine=typst
        -V template=article.typ
      
      Despite the input content being a .md file, we see that the .md contents populate the .typ file. Pandoc then understands how to convert the populated .typ file into a .pdf. The author also notes in their hyperlinked .typ document where the body content is placed:

        // THIS IS THE ACTUAL BODY:
      
      What is not clear to me is the actual mechanism that tells pandoc where to place the body contents in the template. I presume it's some "magic" from the pandoc docs. The pandoc templates documentation[1] does reveal to us that `-V` is setting a variable called `template`. I don't have pandoc locally, but from another post[2] from the same author and a chatgpt query, it seems that the `body` symbol in the template is the chosen substitution symbol.

      [1]: https://pandoc.org/demo/example33/6-templates.html

      [2]: https://imaginarytext.ca/posts/2024/pandoc-typst-tutorial/

      • alethic 5 hours ago
        Pandoc templates use $...$ or ${...} for variable substitution, yes. body is one of the special default variables: the rest are documented in the manual. If you scroll to the bottom of the template linked from the article, you'll notice a $body$, along with a number of $if(...)$ $endif$ conditionals.

        (This actually interferes with Typst's math mode. But you can manually construct math blocks, so no real problem. Pandoc variables are only valid within templates anyway.)

        https://pandoc.org/MANUAL.html#variables-set-automatically

    • __mharrison__ 4 hours ago
      I'll give an example.

      I write Python, software engineering, and data science books in Jupyter. (Because I want both text and code). I've written my own toolchain (multiple times, don't ask, yes, I've tried the one you're thinking of and it didn't work for me).

      I need to convert the notebooks into chapters in my books (PDF so I can print them). In the past, I used code to convert to LaTeX. (It was horrible).

      Now, I use code to convert the Jupyter file to markdown, then (I use pandoc too) to typst. (It is 100x better than LaTeX).

      (I also use pandoc to convert markdown to epub).

      • trostaft 3 hours ago
        > (multiple times, don't ask, yes, I've tried the one you're thinking of and it didn't work for me).

        I know you didn't want questions, but maybe you can save me some trouble?

        Assuming you're talking about quarto, may I ask what you didn't like about it? I've been converting some of my course materials to it and have been enjoying it immensely.

      • cbolton 2 hours ago
        For what's it's worth you can render Jupyter notebooks directly from Typst using the Callisto package. You can then style the notebook content as if it was written in Typst, using show rules, etc:

          #import "@preview/callisto:0.2.5"
          #callisto.render(nb: json("notebook.ipynb"))
        
        though as the sibling comment says Quarto also works great for this, and Typst doesn't do epub (yet?)
  • adolph 7 hours ago
    Thank you kind person for posting this. I've just started my Pandoc journey formatting books for reading in a secondhand Sony DPT-RP1.