Remix.run Logo
Using Pandoc and Typst to Produce PDFs(imaginarytext.ca)
94 points by bribri 13 hours ago | 15 comments
WA 6 hours ago | parent | next [-]

Browser support to print HTML sucked. No page counter / max pages, no way to properly style headers and footers. Chrome 131 recently added CSS support for @page [1][2] and cross-references in the same doc (giving you the page number), which is a great step forward. I think this simplifies Markdown → PDF even more on the tooling side.

[1] https://developer.chrome.com/blog/print-margins

[2] https://developer.mozilla.org/en-US/docs/Web/CSS/@page

stakhanov 10 hours ago | parent | prev | next [-]

An alternative stack that circumvents LaTeX and that I've successfully used for a book-scale project would be pandoc+weasyprint.

sitkack 6 hours ago | parent [-]

https://github.com/Kozea/WeasyPrint

> From a technical point of view, WeasyPrint is a visual rendering engine for HTML and CSS that can export to PDF. It aims to support web standards for printing. WeasyPrint is free software made available under a BSD license.

Hmm, I wonder if you could use servo for a similar purpose.

5evOX5hTZ9mYa9E 10 hours ago | parent | prev | next [-]

I really wish there were more resources for Typst out there. The reference documentation seems comprehensive, but as somebody who is neither a developer nor experienced in LaTeX, I seem to need a bit more handholding.

minigamedev 9 hours ago | parent [-]

There is a community project called typst by examples, see this link https://sitandr.github.io/typst-examples-book/book/

Gethsemane 5 hours ago | parent | prev | next [-]

I've similarly found the combination of pandoc + typst to be quite exciting. I've found it particularly useful for typesetting academic papers - I'm quite averse to word in general, don't require extensive mathematical typesetting support, and find latex to generally be quite unapproachable (just look at the size of the default pandoc template!), and so it gives me a method of making a decent pdf whilst simultaneously producing a .docx for my collaborators. Being able to track changes with git is also a huge advantage, although never had the chance to work with someone who is comfortable using git :(

The recently added support for PDF/A is also quite exciting, as I've never found a satisfactory solution to this with latex. Now I just wish journals would support markdown submissions...

binarycoffee 9 hours ago | parent | prev | next [-]

I can see why someone would prefer Typst over LaTeX when the source is written in Typst or LaTeX, but what are the advantages if your source document is in Markdown? Is there anything else beyond the (presumably) smaller install size of Typst?

cbolton 9 hours ago | parent | next [-]

When compiling the Markdown to PDF, you might want to customize the PDF template. That's arguably easier and more pleasant to do with a Typst template than a Latex template. Also the compilation with Typst is often much faster.

Gethsemane 5 hours ago | parent | prev | next [-]

Something I found useful is that you can create a much more minimal pandoc template for typst than for latex. Obviously if familiar with latex it probably won't be an issue, but when I tried to make my own barebones pandoc template (i.e., stripping out beamer) I gave up.

setopt 5 hours ago | parent | prev [-]

Typst is 2-3 orders of magnitude faster than latex, which for book-sized projects can be the difference between a minute and sub-second compilation time.

zwnow 5 hours ago | parent | prev | next [-]

Nice, does it work with images? Like can I render images and place text on top of them, well positioned?

knbknb 9 hours ago | parent | prev | next [-]

Can Typst only produce PDFs? Are other output formats on the development roadmap?

(I know that pandoc is incredibly flexible.)

cbolton 9 hours ago | parent [-]

Currently it only outputs PDF, PNG and SVG. The next release will have preliminary support for HTML. This will be a structured output so from there it will be easier to support other formats either directly or in post-processing e.g. through pandoc. Pandoc itself supports Typst input but I'm not sure how reliable that is.

actionfromafar 8 hours ago | parent [-]

Don’t know either, but some things are unrepresentable in the pandoc internal format. It can internally represent an intersection of all its supported formats.

4 hours ago | parent | prev [-]
[deleted]