Gribouille 0.3.0: A Grammar of Graphics for Typst (mickael.canouil.fr)
178 points by mcanouil 4 days ago
NiloCK 2 hours ago
Is typst a good tool for something like a flyer (eg, printable respecting fold lines) or more generically one-page posters?
I see PDF as a blessed output, but it seems mostly in context of longer form typesetting-heavy workflows (books, papers), rather than design-heavy.
ink_13 an hour ago
Probably not. As you point out, it's a typesetting tool like LaTeX, not a page layout tool.
You could probably write a template that does the right thing, but that's true of LaTeX as well.
matijsvzuijlen 10 hours ago
Why are all the parameters full words except 'labs'? I find it jarring because to me 'lab' is short for laboratory, not label.
nxobject 7 hours ago
I suspect for consistency with ggplot - the same reason why ‘aes’ is shorthand and everyone forgets that it stands for “aesthetic”.
matijsvzuijlen 6 hours ago
Thanks, that makes sense. I actually just parsed aes as related to encryption without even considering how weird that was given the contect.
nxobject an hour ago
bestouff 9 hours ago
He's open to API suggestions, you should open an issue
matijsvzuijlen 6 hours ago
Yes, I will do that!
red_admiral 7 hours ago
Always pleased to see Typst mentioned. TeX made a lot of choices that made sense at the time, but TeX macros and C #defines especially when nested and/or not properly bracketed to allow nesting are a mess when things go wrong.
kzrdude 6 minutes ago
It is fun how in computer science terms, TeX and Typst are so incredibly far apart. TeX is a macro language that could be implemented in very little memory, while Typst literally memoizes every typst function's result; to the point where it will eat all available memory if the document and its editing increments needs it.
This reflects the time in which they were developed.
flerovium114 7 hours ago
In what setting are you mixing LaTeX and C code?
red_admiral 6 hours ago
No, no, TeX macros nested within other TeX macros.
stared 7 hours ago
Interesting! If I get it right, the API is in the spirit of Observable Plot (https://observablehq.com/plot/), less ggplot2.
In any case, I'm curious whether aes is necessary, or whether it would suffice to drop this function entirely and just use keys in the mapping (similarly for labs). Or, more broadly, whether using patterns from other implementations of the Grammar of Graphics is a conscious decision, or some sort of legacy baggage.
spider-mario 9 hours ago
What’s with the slanted figures until you hover over them?
jeremyscanvic 3 hours ago
Is ggplot2 considered to be a nice interface to plot things compared to say matplotlib in Python? I'm asking out of curiosity, I haven't touched R much
stdbrouw 3 hours ago
Yes, ggplot2 is lovely to work with for complex graphs. Whereas a classic plotting library will have one function to create a bar graph, another to create a line graph, etc., in ggplot instead you can stack layers, each with different properties, variables, shapes, data-dependent colors, scales, whatever you want. It also makes it easy to create grids of similar graphs.
mightyham 28 minutes ago
I find matplotlib to be clunky and verbose compared to ggplot. When using python, I will often use https://plotnine.org/ because it gives me a nice ggplot like API.
Arodex 2 hours ago
The "grammar of graphics" conceptualized in ggplot is a very cohesive way to make (I think almost) any kind of graph, while remaining a high-level language/DSL.
elsoja 5 hours ago
It seems to be fully written in native Typst, without any WASM backend. I wonder how is the performance like for complex plots or for documents with a large number of figures.
unrealhoang 12 hours ago
This is awesome, is there a way to render the graphics/chart in svg so that we can implement something like hover & popup (with data information)?
alhidade 10 hours ago
Typst supports SVG output natively.
red_admiral 8 hours ago
From past experience (may be different now): Typst supports SVGs that are actually vanilla SVGs. The SVG standard lets you embed a HTML page and CSS as a <foreignObject>, which only renders properly in a browser or something that bundles one (surprise!). This is not the fault of Typst and I think Typst is correct not to go down that route.
Just a heads up if you wonder why draw.io (diagrams.net) SVGs display as black boxes.
adamnemecek 11 hours ago
Typst is the most important open source project of the last 5 years.
I predict a future where markdown and latex are largely replaced by typst. And I couldn't be more excited.
It is such a stepup from markdown and latex. Try it today if you are intrigued.
cryo32 7 hours ago
Not so sure.
I work with a lot of people in academia who work with LaTeX. I haven't met anyone who knows Typst even exists. And the source material is usually just thrown in Word or LibreOffice.
The problem is also momentum. Do you rewrite 30 years' of CTAN contributions, internal templates/styles and the toolchain off and start again or not? There's not much reason to. And you will hit the same brick walls doing so that you hit with TeX the first time round.
If it is a greenfield, possibly, but all the orgs I've seen using LaTeX have been using TeX since the dawn of time and respect the accumulated knowledge rather than the distraction of a new tool.
k2enemy 3 hours ago
I'm in academia and used to use LaTeX for everything, and have switched almost 100% to typst. Not many of my colleagues are aware of typst but a few use it.
I think there is hope though. Grad students are slowly picking it up, and they are the future of academia. I've seen similar transitions away from Fortran and Matlab as grad students embrace different tools than what their advisors use.
meling 3 hours ago
I’m in academia and I try to convert everyone I know… I only recently started using it for a few things, and I used Claude to do some pretty advanced stuff that I wouldn’t have ventured to even try with latex. That is, I think a lot of the relevant CTAN packages can be developed using LLMs more quickly than you might expect.
For next year, I plan to prepare a thesis template for our university and encourage students to try it instead of latex (most of our students use latex now).
lkm0 6 hours ago
> accumulated knowledge
my experience is the opposite. Due to LaTeX's arcane scripting and the lack of interest people have in learning it beyond "it compiles on overleaf", I'm seeing a lot of accumulated superstition. People copying and pasting preambles with useless packages, unused newcommands. Worse, people sometimes use their group's newcommands without being aware of the native functions, e.g. \beginmymatrix replacing \begin{pmatrix}. Even if change is slow, any amount of Typst adoption is good.
cryo32 6 hours ago
vatsachak 6 hours ago
Academia is stuck in the past in a lot of ways.
cryo32 6 hours ago
adamnemecek an hour ago
> I haven't met anyone who knows Typst even exists.
It was released in 2023 and became polished enough to use like last year. Yeah, adoption takes time but the technology is significantly better.
> The problem is also momentum. Do you rewrite 30 years' of CTAN contributions, internal templates/styles and the toolchain off and start again or not?
With latex you have to rely on third party. With typst you can write it yourself (or with an agent), like writing functions is not painful in typst.
sieve 7 hours ago
I like typst. But I am not a fan of the syntax. I use it as an intermediate format on the way to PDF. A document markup language should avoid building a programming language inside it. Pick python, or lua, or whatever.
utopiah 11 hours ago
I'm not sure either matter to be honest.
It's cool sure, powerful also... but when anybody has access to both vector-based editor and raster-based editor ... but also tools that incorporate them, e.g. rich text editors ... but also entire toolchain going from compilers to libraries all the way to Web based notebook with their editors and running environment that can then output printable artifacts, I don't think there has to be "the" way. They might be a more popular way within a certain zeitgeist but... does one project has to "replace" another one?
I guess I don't really get the passion some people have for "perfect" rendering. I'm fine with just text, then just readible equations below it, then an OK looking graph. I don't actually care if any of those are pixel perfect. I don't get it.
IMHO in terms of actual knowledge transmission reproducibility and interactivity are way more important. They might not look as good and in fact introduce a TON of complexity but I believe it's better than yet another system that is slightly better looking while being slightly easier, for those people with a specific mindset, to setup and use.
PS: still both Gribouille and Typst are cool projects! Just want to make sure I'm not sounding critical against those efforts.
poulpy123 8 hours ago
I cannot tell the future of typst and gribouille, but for:
> I'm fine with just text, then just readible equations below it, then an OK looking graph. I don't actually care if any of those are pixel perfect. I don't get it.
what you describe is fine for a readme or a blog post, but for books, scientific articles, or any long format, having a good layout and typography will totally impact the end result
zhshnsnnaaka 11 hours ago
I agree but to me it seems humanity has a terminal case of being unable to separate content from presentation. I can see it in this thread with clamoring for Typst in READMEs etc. If READMEs need to be anything they need to be plain bloody text. Markdown is the absolute maximum. Having some “header semantics” defined is fine as that’s universal in a document but let’s keep it simple guys, OK?
Information needs to be plain and clear. Presentation can be fancy. Let’s keep these very, very different things separate. AI will thank you as well.
practal 10 hours ago
red_admiral 7 hours ago
If you've ever debugged TeX package conflicts because someone wants "that layout, except with those headers and this font", yes the whole stack needs replacing with something that does not hold all its state in global variables and has a sensible scripting language (LuaTeX never really took off).
TRiG_Ireland 11 hours ago
My primary use for Typst is pretty agendas for my Toastmasters club. https://typst.app/project/rmyyeU17y51rl6ISSqGji9
Typesetting isn't just for science. I like that it looks good; I enjoy the creative step of experimenting with document design; and Typst is just fun to use.
adamnemecek 11 hours ago
> It's cool sure, powerful also... but when anybody has access to both vector-based editor and raster-based editor ... but also tools that incorporate them, e.g. rich text editors ... but also entire toolchain going from compilers to libraries all the way to Web based notebook with their editors and running environment that can then output printable artifacts, I don't think there has to be "the" way. They might be a more popular way within a certain zeitgeist but... does one project has to "replace" another one?
cool, why do you think people use tikz? And like generating images programmatically from text is impossibly more powerful than using vector editors.
mastermage 11 hours ago
For Latex I agree thats definitely. Markdown I am unsure as Markdown is not meant for creating documents but to just have a little Richt Text Markup in READMEs and other Text files. Typst needs a compile step and altough that one is fast as hell it is still different from Markdown that renders directly from the file without an intermediary.
josephg 11 hours ago
Right; but markdown has expanded beyond that niche. Lots of projects use markdown for other stuff - like mdbook, or for blogs.
I think markdown is a great format for readme files. But for real documentation, the added features of typst are fantastic. Like, being able to write scripts, have figures and custom styling, populate data from JSON files, plugins, typography, numbered sections, footnotes and all sorts of other stuff. Markdown doesn't even support comments properly!
I want typst for blogging, long form articles and documentation. Markdown is great for small stuff. But it doesn't scale.
mastermage 10 hours ago
applicative 9 hours ago
Certhas 8 hours ago
adamnemecek 11 hours ago
The problem with markdown is that it's not extensible and that there is no spec. Essentially all READMEs would be better off using typst, they would make for better READMEs.
sbysb 11 hours ago
applicative 9 hours ago
mastermage 10 hours ago
tlarkworthy 11 hours ago
red_admiral 8 hours ago
Markdown and Typst serve different markets - I don't need page layouts and font choices in a pull request, for example. Typst is however a good Markdown++ in that once a collection of markdown files grows to book size, it's easy enough to port.
Typst challenging TeX would be my dream too - there's a lot of math you can port just be leaving off the backslashes. Mind you the kids these days know TeX primarily as "that language in overleaf".
aloisdg 5 hours ago
Markdown is already seen as arcane by non technical folks. Which is sad btw.
Typst is not going to replace it.
That said I was not a huge latex user and nowadays I use typst a lot. Typst is everything I was expected from latex.
The content is in markdown and loaded by typst with cmarker