You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this a bug or actually an expected behavior. It seems the width of a numbered list is not always 100% but instead restricted to the maximum width of its lines.
Therefore, if you don't have a long (>=100%) line in a numbered list, your math blocks in that list will not be placed at the horizontal center of the page. These math blocks are instead centered relative to the the parent numbered list. This is some what conterintuitive (at least from a previous LaTeX user's perspective).
With a long line:
Without a long line:
To reproduce:
= Question 1
+ #set enum(numbering: "(a)")
+ The constructed sequent is given as follows:
$ q arrow p, r arrow not p, q and r tack.long ((p and q) arrow not r) or ((p and r) arrow not q) $
//The constructed sequent has assumptions $X={A_1,A_2,A_3}$ and a conclusion $C$ where:
Without the long line:
$ A_1 &= q arrow p\
A_2 &= r arrow not p\
A_3 &= q and r\
C space &= ((p and q) arrow not r) or ((p and r) arrow not q)
$
Reacted by +merlan #flirora, Vihan, Ajai Khatri Nelson, Jiahao Li, Nick Mertin, memeplex, jthulhu, Michael Yang, Bay, Thrasos and 4 more
I've made a more comprehensive fix which reimplements lists and enums using terms, which should also work on width: auto pages. Just paste the function code below and use show: fix-lists at the top of your document.
It supports nearly all list and enum features (as of Typst 0.13), except for
1. #set enum(numbering: "1.a."), i.e. using a string for numbering with more than one level with full: false. That requires parsing the numbering and would be a bit too much for this snippet, so I've kept it simple here. Otherwise, using full: true, using custom numbering functions and stuff is supported.
2. #set enum(number-align: bottom). That would break the implementation. I suppose the implementation could be conditionally disabled based on whether number-align was customized.
As a disclaimer, visuals can potentially change in an unexpected way with this fix. If you try it and the output isn't desirable, you may wish to look into a different solution.
That would break lists in automatically sized containers.
Isn't it possible with Typst's layout algorithm for a list to know whether its parent is automatically versus absolutely sized?
If the parent of a list is absolutely sized, keep the current behaviour. If the parent of a list has a defined size, I think it is pretty much unanimously expected that the list should inherit its parent's width, like a paragraph of text would.
Isn't it possible with Typst's layout algorithm for a list to know whether its parent is automatically versus absolutely sized?
I can't claim to know the codebase enough to fully acertain that it's not possible, but my understanding is:
During layout, each layout function has no knowledge of the parent container of what it's laying out (layout functions are agnostic to the position of an element in the AST, they only take in the actual element along with a style object).
Fixing the issue outside of the layout function isn't really possible, because only a grid is laid out (the information about the list elem it comes from is forgotten, i.e. you can't make exceptions for lists outside of the list layout function).
Implementing .within selectors in the compiler would solve this issue (I think?), and might be the simplest way forward. Obviously this is an enormous undertaking.
Activity
queensferryme commentedon Apr 2, 2023
A quick workaround would be finding some line and wrap it with
#box(width: 100%).[-]Unable to center math blocks in a numbered list[/-][+]Center alignment broken in lists[/+]vihanb commentedon Sep 2, 2023
For anyone else who is encountering this issue. I added the following to my template to resolve this issue:
isaacholt100 commentedon Feb 13, 2024
Wrapping the list with
box(width: 100%, ...)didn't work for me, I had to wrap the equations in a box and set alignment to center:Enter-tainer commentedon Feb 27, 2024
Should we make
enumandlist's width 100% by default?laurmaedje commentedon Feb 27, 2024
Then you can't have a list in an automatically sized block anymore.
Asta-QQ commentedon Mar 17, 2024
I find that this will make the following content a new paragraph, maybe use #block to replace #box is better.
Andrew15-5 commentedon Oct 1, 2024
This issue was mentioned in https://forum.typst.app/t/how-to-make-nested-bulleted-lists-where-content-includes-centered-equations/846/3.
Wouldn't this be enough?
Strange that changing the width of the existing block element doesn't change anything:
typst/crates/typst/src/math/equation.rs
Lines 163 to 175 in 022f34c
Edit:
Since this is not an ideal solution, I simplified the previous one instead (which I guess should be better):
laurmaedje commentedon Oct 2, 2024
That would break lists in automatically sized containers.
Andrew15-5 commentedon Oct 2, 2024
Are you referring to the top snippet or the bottom one?
laurmaedje commentedon Oct 2, 2024
The top one. Sorry I was on my phone and too lazy to quote.
asd-a commentedon Oct 22, 2024
Can we use
widthas a parameter oflistto meet the both?laurmaedje commentedon Oct 22, 2024
I think that wouldn't be a great UX as you couldn't easily adjust the
widthparameter from list syntax.The issue can be fixed just with changes to the internals of the layout engine.
Andrew15-5 commentedon Mar 21, 2025
This issue has been mentioned on Typst Forum. There might be relevant details there:
https://forum.typst.app/t/how-to-make-centralized-formulae-in-enums/3363/2
LRoInT commentedon Jul 4, 2025
The problem is 100% isn't equal the
page.width, you can see it from this:So the way to solve it is to use
page.widthand solve how much space dose the numbering and indent usePgBiel commentedon Jul 8, 2025
I've made a more comprehensive fix which reimplements lists and enums using
terms, which should also work onwidth: autopages. Just paste the function code below and useshow: fix-listsat the top of your document.It supports nearly all list and enum features (as of Typst 0.13), except for
1.
#set enum(numbering: "1.a."), i.e. using a string for numbering with more than one level withfull: false. That requires parsing the numbering and would be a bit too much for this snippet, so I've kept it simple here. Otherwise, usingfull: true, using custom numbering functions and stuff is supported.2.
#set enum(number-align: bottom). That would break the implementation. I suppose the implementation could be conditionally disabled based on whethernumber-alignwas customized.As a disclaimer, visuals can potentially change in an unexpected way with this fix. If you try it and the output isn't desirable, you may wish to look into a different solution.
My fix is available here: https://gist.github.com/PgBiel/c530ae8ac937469510ab382e03a6ba2b
For example:
Output:
Full test document (note that it still works with `width: auto` pages)
Note: the tests in this document use some sample text given by another user
szdytom commentedon Jul 11, 2025
A simple workaround is manually place a
#h(1fr)somewhere in the listJollywatt commentedon Nov 30, 2025
Isn't it possible with Typst's layout algorithm for a list to know whether its parent is automatically versus absolutely sized?
If the parent of a list is absolutely sized, keep the current behaviour. If the parent of a list has a defined size, I think it is pretty much unanimously expected that the list should inherit its parent's width, like a paragraph of text would.
tjbcg commentedon Nov 30, 2025
I can't claim to know the codebase enough to fully acertain that it's not possible, but my understanding is:
.withinselectors in the compiler would solve this issue (I think?), and might be the simplest way forward. Obviously this is an enormous undertaking.