I am not certain whether it is intended or a bug, but, when using stack
with a horizontal direction, max width is calculated for each element independently, resulting in a shifted right page margin.
E.g. the following code
this is a #h(1fr) normal paragraph
#stack(dir: ltr, "(1) ", [this is a #h(1fr) stack])
results in the following placing:
The right margin of the stack is shifted to the right by the width of (1)
. (should be noted that this is not fr
-specific and affects line breaking as well)
If this is indeed intended, my question is, what, if not stack
, should be used for creation of e.g. custom list-like layouts?
Andrew
May 13, 2025, 11:16am
2
Hello. Please read How to post in the Questions category before posting a question (from the pinned topic ).
If your question pertains to a bit of Typst markup you have problems with, put it in the question body! You can syntax-highlight Typst code by wrapping it in ` ```typ … ````. It will then look like this:
#set font(size: 12pt)
Hello from *Typst* at $ pi.var + 1 $ o'clock!
If you need to highlight a code or math mode snippet instead, the language tags typc
and typm
do that, respectively.
1 Like
Andrew
May 13, 2025, 11:25am
3
Hmm, I think it is a bug, since by default everything must follow the set margins. You should open an issue about it.
retroflexivity:
If this is indeed intended, my question is, what, if not stack
, should be used for creation of e.g. custom list-like layouts?
It depends on how your list layout supposed to work. Internally, lists are implemented through grid. typst/crates/typst-layout/src/lists.rs at ad539ef4ed0551a7eb22f7c9c0ab1c0fd1b59209 · typst/typst · GitHub
opened 11:41AM - 13 May 25 UTC
bug
layout
### Description
When using `stack` with a horizontal direction, max width seems… to be equal to the stack's max width for every element, resulting in a shifted right page margin.
E.g. the following code
```typ
this is a #h(1fr) normal paragraph
#stack(dir: ltr, "(1) ", [this is a #h(1fr) stack])
```
results in the following layout:

The right margin of the stack is shifted to the right by the width of `(1) `.
### Operating system
Linux
### Typst version
- [x] I am using the latest version of Typst
Thank you! Grids do seem more suitable, and avoid the bug.
I’ll file an issue right away.
1 Like
Also relevant, this Discord discussion :
laurmaedje:
TLDR: Stacks haven’t really been touched in ~2 years and are wonky and broken
– Discord , 2024-10-16T00:00:00Z
It’s definitely still an issue, but I’d just prefer grid out of principle. I’m not aware of something that can be done with a stack, but not a grid.