Typst and other alternatives to LaTeX

I don’t quite understand how Quarto works with typst. Suppose you have a qmd file

---
title: "Hello Typst!"
format:
  typst:
    toc: true
    section-numbering: 1.1.a
    columns: 2
---

This file will be compiled using typst and is quick. However, any mathematics that you write in the qmd file is latex notation, i.e.,

---
title: "Hello Typst!"
format:
  typst:
    toc: true
    section-numbering: 1.1.a
    columns: 2
---
This is my equation: $\frac{a}{b} = \pi$. 

Does anyone know if you can actually write typst notation/language in the markdown file?

Typst blocks are written like this

```{=typst}
$ x + y $ and other markup
```
2 Likes

Right, but those are blocks. If you want to type ‘regular’ math (e.g., inline equations), you still have to type latex.

For inline try

`something`{=typst}

Were you able to do this on typst?

1 Like

Thanks, those examples look nice.

1 Like

I know you’re discussing Quarto here, but with Pandoc at least you can target LaTeX output while using Typst syntax for math input, mixed with Pandoc Markdown. See the Conclusion section of Typst: a possible LaTeX replacement [LWN.net].

This depends on the content mostly, not the output requirements. You can tweak output to whatever appearance you prefer in any of these alternatives.

For simple markup requirements (headers, bold, italic, links, lists, cross-refs, simple figures), Markdown is hard to beat. You can use tools like Pandoc to emit PDF, HTML, various ebook formats, etc. If your markup requirements fit Markdown, choose that, it is the best choice, future-proof, low bar for contributors, simple to type, etc.

If you want more than trivial math, advanced/fine tuned figure placement, choose LaTeX or Typst. Which one fits your project best depends on your tolerance for rough edges (Typst has quite a few, but they are being worked on), previous knowledge (you may know LaTeX), compilation time (Typst is faster, but this matters mostly for for very large documents).

If you want dynamically generated content (eg results from code), Quarto is probably the best choice.

6 Likes

Like many other I don’t think there’s one single best system but it depends a lot on what you want to do and what constraints you have.

I believe that you can get a decent idea whether typst is an interesting tool for you by playing with it for an hour or so. Start with a tutorial and go on to try something more complicated that’s important for your needs.

This writeup of experiences writing a PhD thesis in typst may be of interest to people weighing typst against latex.

For my needs at work I’m replacing a markdown+pandoc+latex+latexdiff+julia stack with only typst+julia, with nice gains in simplicity, speed, and writing experience. The only missing piece is a new typst release (which does seem to be getting close) with enough HTML export functionality for our limited needs.

8 Likes

Typst is better suited than LaTeX for sharing with AI.

I am a 70 year old mathematician, succeeding to a greater extent than conventional wisdom believes possible at becoming hybrid with AI for my research and coding. I pay $200 monthly for top tier individual access to Anthropic’s models. I have struggled mightily over the past year in experiments to sort out what works. What doesn’t work is listening to the noise out there; most people have no clue how to effectively use AI.

One needs to make a radical shift in perspective from “solo programmer” to “CTO of an efficient organization”. One plans, one plans to plan, one conducts code reviews, in collaboration with AI. One finds best ways to reify all thought, for an historical record AI can consult.

AI can read LaTeX documents, but they’re verbose, and written in a ghastly language structured poorly for AI. AI can read PDF files, but they’re verbose, and written in a ghastly language structured poorly for AI.

Even if one has an unlimited budget and can tolerate weaker responses, using either LaTeX or PDFs with AI is contributing to global warming.

If Markdown or AsciiDoc or similar markup languages do not suffice for one’s documentation, Typst is an ideal choice. It’s terse, and far more expressive than Markdown. Humans read the output. AI reads the source.

My code documentation resembles a math text, so I need Typst.

6 Likes

Spot on for both Typst and using AI, which is much more like being a project manager than an individual coder.

If this is true, I find it both appalling and depressing. Being a project manager is my worst nightmare. I only want to solve problems, but now that is being taken away.

AI kills the human spirit. All that is left is management :slightly_frowning_face:

15 Likes

A stupid manager at that: Should General have a guideline or rule preventing registration of vibe-coded packages? - #61 by PetrKryslUCSD

1 Like

Well, sure, just like vibe coding is stupid, mostly. But is it a better use of time to write your own docstrings than to review auto generated?

I find that writing docstrings uncommonly sharpens my understanding of what it is I want to accomplish with the code. To the point where I start hacking on the code based on what I learned writing the docs…

9 Likes

That is admirable. I’m more like what I expect the majority is apt to do, which is to put off writing the docstrings “until everything is final.”

2 Likes

Can you explain this? My impression is that when it comes to document structure, LaTeX and Typst constructs map almost 1:1 to each other, eg as explained here. I don’t see how one would be more complicated than another for LLMs.

I am somewhat surprised that LLMs found enough training material for Typst to work better than LaTeX for this purpose.

2 Likes

I think for a typical declarative LaTeX document that’s true. But I wouldn’t be surprised to see large differences with anything that involves “programming”, and many documents include some programming bits. I mean Typst is a mostly “pure” language (in the sense of function purity) so pieces of code can be understood locally, and the scripting language makes common tasks simple to implement. TeX is the opposite of that, e.g. macro definitions in one file can even change how code is parsed in another file, and any task with complexity north of “store / retrieve value from array” requires ridiculously complicated macro sequences.

Taking an example from a totally random paper I promise:

(Not the typical LaTeX code in an article source of course :slight_smile: but the middle-ground might indeed be in Typst’s favor)

Claude already understands Typst fairly well in my experience, it even translated some of my TikZ figures to (ugly) CeTZ figures.

1 Like

Typst is indeed better designed than LaTeX in this respect, but on the other hand LaTeX is fairly mature, so most users can get away with no programming per se, just loading existing packages.

I am a heavy user of LaTeX and most of my “programming” consists of various simple expansions with \newcommand.

1 Like