707
1
Hi all,
I’m trying to switch from LaTeX to Typst and would like to align the parentheses in my numbered lists. Does anyone know how to do this?
LaTeX example, parentheses aligned:
Created using this code (exam document class):
\renewcommand{\partshook}{
\renewcommand\partlabel{(\hbox to 7pt{\hfil \thepartno \hfil})}
}
Current list in Typst, parentheses not aligned:
Styled using numbly as follows:
set enum(
full:true,
numbering: numbly("{1:1}.", "({2:a})" )
)
Thanks in advance!
Chern
2
This might be related to the font not being of the same width. One solution is to wrap the number in a box and set its width.
#set enum(
number-align: center,
full: true,
numbering: (..num) => {
let pos = num.pos()
if pos.len() == 1 {
// level 1
std.numbering("1.", ..num)
} else if pos.len() == 2 {
// level 2
[(]
box(width: .6em, [#std.numbering("a", pos.last())])
[)]
} else {
// others level
}
},
)
+ Qustion: #lorem(5)
+ #lorem(5)
+ #lorem(5)
+ #lorem(5)
+ #lorem(5)
707
3
This is exactly what I needed, thank you!