Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's great to see Typst getting more visibility. We migrated a real-world workload to it a couple of years back: generating and e-mailing 1.5M+ PDFs daily at my org, Zerodha.

Our previous pipeline was LaTeX-based (first pdflatex, then lualatex), but we were constantly fighting cryptic memory errors on large documents and huge Docker image sizes that slowed down boot times of our ephemeral workers.

Switching to Typst was a massive win for us. The single static binary resulted in tiny images and faster boot times. More importantly, the performance gains were huge. Overall compile times were ~3–4× faster than LaTeX. On really large documents (2000+ pages, mostly tables), Typst compiles in ~1 minute vs. ~18 minutes with lualatex.

Beyond performance, the better developer experience and good error messages was a nice bonus too.

We wrote a detailed post about the entire architecture - from the job orchestration with Nomad to the S3 optimizations and the Typst migration in particular. If you're curious, you can read it here: https://zerodha.tech/blog/1-5-million-pdfs-in-25-minutes



I am using a LaTeX pipeline for creating text, invoices, forms, etc. from snippets stored in a database. It was quite complicated to set up, but the results are very satisfying. In principle, I would like an easier markup language, but am afraid to wast my time trying out something new, just to run into limitations after awhile.

Here are my most important requirements: Multiple columns configurable for meaningful column and page breaks (minimum number of lines in a new column or page). Reliable automatic hyphenation for multiple languages (at least English and German, perhaps French, Italian and Spanish in the future). Pictures in columns with dynamic placing according to the available space. Complex tables and forms with sensible automatic page breaks. Background images. Different areas on the page which are treated like mini-pages. -- Is Typst capable of all that?


Now, this isn't really an alternative, but I can recommend using pandoc instead of pure LaTex. Personally, I think text blocks are much easier to handle and read in markdown and pandoc allows you to use in-line LaTex wherever markdown is insufficient, without making basic text styling unnecessarily verbose. In my opinion, the result is a better/friendlier LaTex, or limitless markdown respectively. Especially for writing papers and such, you can always start actually writing in basic markdown, which is trivial and almost-WYSIWYG, and later worry about presentation. In my experience, with pure LaTex you easily get lost in sidequests and it's much harder to get into a writing flow and find your way around your own words in the editor.


I wrote my dissertation this way. As long as you’re already comfortable with latex, it’s amazing. Huge time saver not to have to write latex formatting when you don’t have to, but an equally huge time saver to be able to control formatting when you need it.


It's a bit of a weird thing, really. I think, I have not seen any comprehensive, basic tutorial on the matter. I presume a lot of people who've become victim of the LaTex bug, but dislike its overhead, independently found bliss in this pandoc compromise. It's definitely a bit of coping with LaTex Stockholm syndrome, you probably need a specific set of experiences, know some struggle to fully appreciate it.

If anyone here hasn't messed with it, but thinks "I wonder, if LaTex could ruin my life, too", I suggest to start learning pandoc first (it can do various markup conversions, it's useful by itself). Get familiar with pandoc metadata headers on a RTFM basis. A LaTex intro is all you need after that, if you are up for a bit of trial and error. Or learn LaTex first, but not both at the same time, as the layered processing involved is a bit confusing (e.g. pandoc showing pdflatex errors). In any case, I strongly advice to bite the bullet and install the full LaTex package of your distro (no idea about macOS, or windows), as fighting dependencies is suuuper annoying. However, the trade-off is it's truly a behemoth, consequently frequent upgrades for a lot of packages you don't ever use. (I configured dnf to download upgrades automatically, so I can do a quick `dnf upgrade --cacheonly` when opportune.)

Speaking of... I wish pandoc could do Tex package management and dependency resolution.


I ended up just downloading the texlive image and letting it go slightly stale while I wrote. Latex plays poorly with OS package managers and I decided I preferred to be out of date.

I made each chapter a separate file and compiled each one to latex. I had a top level latex file that did an \include{} for each chapter, and a big old Makefile to tie everything together, including figure generation.

All this, and it was still easier than writing every latex command by hand.


If you're going to do this, might as well go with AsciiDoc instead. It's vastly superior as a syntax. Markdown breaks down at the mere mention of something as trivial as a nested list item containing a table of blockquotes.


Not that it couldn’t be trivial in the abstract, but I’m struggling to imagine a use for a nested list item containing a table of blockquotes. It doesn’t seem at all surprising that a tool wouldn’t anticipate that.


Things from the design world, like Acceptance Criteria would happily require it.


Is a lightweight easy-to-read plain text markup language the right tool for that job?


Absolutely! The writers are generally not highly technically experienced, but have to produce highly technical documents that need to be regularly reviewed and changed for years at a time.


If you're going to do this, why not generate Pandoc ASTs directly? You can do so from a number of languages and they support (by definition) a superset of any given markup's features, with blocks to call out directly for things you can only do in Latex.

I assume the original question is asking about programmatic document generation, in which case working with a real AST is probably also a productivity and reliability win as well.


I haven't done pictures in columns but the rest should be doable.

I've migrated my invoicing (and all my other publishing/slides) to typst from latex and couldn't be more happy.


I think so!

I've not tried a couple of things you mention (e.g. background images) but e.g. for dynamic placing there are libraries like https://typst.app/universe/package/meander

The core of Typst is a pretty featureful well-thought-out FP language. This makes expressing libraries for any piece of functionality very pleasant.


I’ve worked places that will regularly send generated PDFs of things like statistics or small reports or other generic boring business stuff every week or month.

It’s always been some combination of MJML, inline DIY HTML, or PDFs generated with Puppeteer etc.

Do you think Typst would be a good fit there too?


We are a python shop and use WeasyPrint. It works well for invoice type things.

I suppose it depends on how much web dev experience is on hand.


Same, used to work at a place that used to use ghostscript + chromedriver and went to Weasyprint.

Weasyprint is quite wonderful, fast, and you can file upstream tickets and get good clarity on what's going on.

And you're writing your templates in CSS + HTML, which generally flows well.

At the end of the day the problems are rarely "CSS + HTML vs Latex vs Typst", but more just about making decisions about how you want something to be laid out when you have dynamic input.

"What should happen when I have a huge blob of text here" is often a non-trivial question. "What should I do on a page break here" is a non-trivial question. And they often involve having to, at the high level, make decisions. People whine about CSS, sometimes you just gotta read the spec and figure things out (rather than stop at your intuition for how certain fields work).

Nice thing about CSS + HTML is you can open up your output in a browser and futz about with it very easily.


For your use case, why were you using LaTeX in the first place? That is more surprising than finding a replacement for LaTeX.


If you're compiling millions of documents, many with thousands of pages, you probably need something very universal. LaTeX is boring tech, off the shelf, ready to use. It might take some work to figure out the initial setup with regards to templating and everything else, but after that, you can be generally pretty content that it will handle most things you throw at it just fine.


LaTeX is notoriously bad at being boring tech. It has a lot of very rough edges, especially when it comes to longer documents.


And yet this very post positions Typst as a potential alternative to LaTeX. In other words, LaTeX is still in the top position.

Personally I think ConTeXt is a far superior tool, though its documentation is always trailing quite a distance behind its current capabilities.


I am currently preparing to switch to DITA. The learning curve is steeper at the beginning, but I find the overall concept of topic-oriented, information-typed authoring with content reuse very attractive.

Some people might say that writing in XML is annoying, but it isn't if you have a decent XML editor. In my case, it is Emacs nXML mode. Customisation is possible with DITA-OT [1] and plugins, and yes, it is also based on XSLT. Overall, I think DITA is an industry-proven XML powerhouse. It may be boring, but it has huge potential for anyone with advanced documentation requirements.

[0] https://dita-lang.org/dita/archspec/base/introduction-to-dit...

[1] https://www.dita-ot.org/


I’d suggest LaTeX because of its strengths with tables, mathematical notation, and similar content.

LaTeX notation works well for this and can be easily converted to both web and PDF formats.

But compilation speed definitely needs improvement.

On the other hand, how often do you actually need to compile thousands of pages into a single document? That’s really an edge case.


What else would you use to generate PDFs from a text-based template?


20-ish years ago I wrote a system to do that with xslt. Would not recommend.


E.g. Pandoc, universal tool…


You will be surprised to learn that pandoc uses latex for generating the PDF. It's barely hidden:

https://www.pandoc.org/demo/example33/2.4-creating-a-pdf.htm...


I know it ;) But we are talking about how to use something universal. I like pandoc as it is easy to use and… boring.


Your original comment before editing complained about using pdflatex as if it was not part of the pandoc toolchain. It was not about pandoc being universal.


Doesn’t Pandoc just use LaTeX under the hood?


Pandoc works with typst too.


A good XSL-FO impl with docbook or something like that?


Apart from typst, I've used weasyprint.


DITA, see my other comment on level up.


Asciidoctor?


Docbook


ReportLab?


Would you be able to post a sample/mock of a document that you produce, would be very interesting.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: