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
Leading doesn't work that way in Typst. It's the space between the line edges and not between the baselines. Just like the amount of lead you would put between the lines. I'm not saying this is necessarily the best way to do it or the end of the story for Typst, just that it's that way right now.
Hmmm... But do you know how to obtain Typst lead from Latex lead? (From the leading package)
This is important to me because I'm recreating my college's template for master dissertation and they have specific leading and i would also need 1.5 spacing...
In latex i would achieve this with \leading{20.4pt} (but it produces different results on Typst).
For the 1.5 spacing i can do this with \linespread{1.5}\selectfont
I think the simplest solution would be to typeset the same text in whatever tool your numbers are from, and then play around with leading in typst (ideally in em and not pt so it's correct if you change font size) until it's close enough to your liking.
I used the measure tool in Adobe Acrobat to create our templates!
But why do we have to suffer by using this "not [...] necessarily the best way", when there are at least 2 issues (#159, #1221) that are saying this way is not the best and there is a better way. (And I'm not including my issue, because I didn't open it and instead writing here.)
I was so frustrated that I "must" have a 1.5 line spacing, but when I used \fontsize{14}{21} the person who was validating the document said that it's nothing like 1.5 line spacing. The root of the problem lies in the proprietary software called Word by Microsoft. With digital ruler (flameshot and okular without text antialiasing) I found out that "1.5" in Word is actually ~1.92. Which is basically 2.0 instead of 1.5! I was so shocked and angry.
I found out that font height is basically the vertically longest glyph in the font — most of the times () are probably the tallest glyphs. And so the line spacing=1 is when the () from one line barely touches () from an adjacent line. I just checked — space between 2 adjacent baselines is roughly the same as space from the lowest point of () to the lowest point of the next ().
When I used \fontsize{14}{21} (and similar) in reality the leading was in the range of 1.55–1.65 which can be considered "1.5 line spacing" as 1, 1.5 and 2 can be defined as groups in which each exact line spacing fall. In other words, leading 1.4–1.6 falls in "1.5" group, 1.9–2.1 — "2" group etc. This means that I was actually right and the aforementioned validator was wrong. If only proprietary software (Google Docs & Microsoft Office) was explicit about what this "1.5" actually means! Or just simply stick to the truth and use an actual "1.5" instead of "1.92".
Anyway, setting block(spacing) or par(leading) to 0ptleads to this:
Parenthesis are overlapped, but the rest of the glyphs are not. So, when leading is 0em, then the text lines could collide into each other — which is bad (this should never happen). Wait, but leading is space between baselines. In Typst case, it is the space between "the baseline of the top line" and "not the highest point of the bottom line" (kind of in the middle). Which only works for limited amount of glyphs (again, not including () and probably some other glyphs). And the "only works for the limited amount of glyphs" is the main problem. If Typst were to use "the better way", then it would work for any glyphs in the selected font. And the fact that leading in par() (and block(spacing)) is actually (leading – 1 baseline) makes it more confusing.
I'm practically begging to differ, i.e., change the definition of leading that Typst is following. For example, when I #set par(leading: 1.5em) it would be the same as \fontsize{14}{21}, but more precise (as I mentioned this macro makes leading about 1.55–1.65 instead of 1.5, but you can make it exactly 1.5 with different macros). And when, for example, I #set block(spacing: 1em) it would show parenthesis on adjacent lines barely touching each other.
This would make Typst more compatible with LaTeX and will remove all the "measuring" to get the ideal leading. When requirement says "set leading to 1.5" or "2", then Typst will actually do exactly that and everyone will be happy.
P.S. I didn't test leading in LibreOffice (and other FOSS). Sorry about switching between "line spacing" and "leading" a lot: when I was using "line spacing" I was referring to either quote from document requirements or just as a "widespread term" which is used in many software programs, and when I was using "leading" I was being more "correct" as leading is the original and more precise term.
saying this way is not the best and there is a better way.
They're just two different competing definitions of leading. The one typst uses is unarguably the oldest, original definition. Leading refers to the lead strips put between consecutive lines in manual typesetting, i.e. spacing between lines. Unfortunately with the advent of computer typesetting, some tools ended up using a different definition.
But what about tall glyphs? If 0em means 0 space between glyphs (in practice this is what it looks like), then what about parenthesis and other overlapping glyphs such as p and h?
Is it really OK to leave this with no changes?
And LaTeX compatibility — why break the compatibility so bad? There is a guide for LaTeX users and a special section with settings that mimics the "LaTeX look":
...
#setpar(leading: 0.55em, ...)
...
This maybe will mimic the default LaTeX look, but you can't mimic the \fontsize{10}{15} with #set par(leading: 15pt/1.5em) or #set par(leading: 5pt/0.5em) (including/excluding 1 baselineskip). Everyone just defaults to using measuring tools to get leading just right.
Typst is still in beta, and breaking changes are a normal thing at this stage. I think before stable release (i.e., in the near future) is the perfect time to switch the definition of leading to more understandable and widespread (and it's not a wrong definition too).
But what about tall glyphs? If 0em means 0 space between glyphs (in practice this is what it looks like), then what about parenthesis and other overlapping glyphs such as p and h?
And LaTeX compatibility — why break the compatibility so bad?
Typst does not claim to be compatible with LaTeX.
Why did LaTeX break compatibility with physical typesetting so bad?
There is a guide for LaTeX users and a special section with settings that mimics the "LaTeX look":
...
#setpar(leading: 0.55em, ...)
...
This maybe will mimic the default LaTeX look, but you can't mimic the \fontsize{10}{15} with #set par(leading: 15pt/1.5em) or #set par(leading: 5pt/0.5em) (including/excluding 1 baselineskip). Everyone just defaults to using measuring tools to get leading just right.
Only because you're starting with measurements using one definition, and want to apply them directly. You would have the same issue going the other way.
Typst is still in beta, and breaking changes are a normal thing at this stage. I think before stable release (i.e., in the near future) is the perfect time to switch the definition of leading to more understandable and widespread (and it's not a wrong definition too).
That is subjective. I find the definition that typst uses more understandable. It's also the original definition.
Only because you're starting with measurements using one definition, and want to apply them directly. You would have the same issue going the other way.
Well, yes, but I was speaking like I'm a LaTeX user who wants to "directly" port his leading settings to Typst (which isn't so far from the truth), and it wouldn't work because of the reason you said. I of course understand that leading settings in these programs are based on the different truths definitions.
I checked and for me 0.25em "Typst leading" is "close enough" for x1 baseline a.k.a. 1.0 line spacing (sometimes also called leading) (tested for 10pt and 30pt, also for different fonts). This means that 0.75em is approximately 1.5 line spacing and, therefore, 1.25em is ~2.0 line spacing (well, more like 2.1).
Basically:
#letleading= 1.5em// Your line spacing (1, 1.5, 2, etc.)#letleading= leading-0.75em// "Normalization"// #set block(spacing: leading) // This is for an old version of Typst (<=0.11.1).#setpar(leading: leading, spacing: leading)
With leading: 0.25em parentheses do overlap a little (in some fonts more, in others less). For 0.75em and 1.25em the error only increases (~1.56 instead of 1.5, ~2.1 instead of 2.0).
If someone need more precise line spacing, then good luck with ruler measurements and pixel peeping.
Reacted by Pedro Peixoto, Gordon Woodhull, 古翱翔, Konrad Konieczny, Tae-Geun Kim-Morgen, Ertuğrul Uyar and Domi
Just want to mention: after setting par.leading to zero, the distance between baselines actually equals to text.top-edge. You could experiment it to see this behavior:
If you want to get the behavior like LaTeX, you could do set text(top-edge: 0cm). However, this may lead to unexpected results as some default styles rely on something similar to the default par.leading behavior.
I recommend setting the text.top-edge to a certain em length that matches your font, and then you could calculate a proper par.leading that results in a certain distance of baselines. For example, I have set text(top-edge: 0.85em) because 0.85em could just matches the top edge of the CJK characters in my font; then, I have set par(leading: 0.9em), and the actual distance of baselines will be 0.85em + 0.9em = 1.75em.
Update
I did some hack and found that similar spacing behavior could be achieved better with measure. However, it is only suitable for non-CJK documents.
// Assume that the font's cap-height are consistent// over different font sizes#letleading(line-height) = {
letcap-height= measure("X").heightletcap-em= cap-height/1em.to-absolute()
line-height-cap-em*1em
}
#letpaper(body) = {
settext(
lang: "en",
region: "US",
font: "TeX Gyre Termes",
size: rem,
)
context {
letlineskip= leading(1.75em)
setpar(
justify: true,
leading: lineskip,
spacing: lineskip,
first-line-indent: 2em,
)
body
}
}
Activity
laurmaedje commentedon Mar 27, 2023
Leading doesn't work that way in Typst. It's the space between the line edges and not between the baselines. Just like the amount of lead you would put between the lines. I'm not saying this is necessarily the best way to do it or the end of the story for Typst, just that it's that way right now.
vaavaav commentedon Mar 27, 2023
Hmmm... But do you know how to obtain Typst lead from Latex lead? (From the
leadingpackage)This is important to me because I'm recreating my college's template for master dissertation and they have specific leading and i would also need 1.5 spacing...
In latex i would achieve this with
\leading{20.4pt}(but it produces different results on Typst).For the 1.5 spacing i can do this with
\linespread{1.5}\selectfontEnivex commentedon Mar 27, 2023
I think the simplest solution would be to typeset the same text in whatever tool your numbers are from, and then play around with leading in typst (ideally in em and not pt so it's correct if you change font size) until it's close enough to your liking.
reknih commentedon Apr 4, 2023
I used the measure tool in Adobe Acrobat to create our templates!
Andrew15-5 commentedon Jun 18, 2023
But why do we have to suffer by using this "not [...] necessarily the best way", when there are at least 2 issues (#159, #1221) that are saying this way is not the best and there is a better way. (And I'm not including my issue, because I didn't open it and instead writing here.)
I was so frustrated that I "must" have a 1.5 line spacing, but when I used
\fontsize{14}{21}the person who was validating the document said that it's nothing like 1.5 line spacing. The root of the problem lies in the proprietary software called Word by Microsoft. With digital ruler (flameshotandokularwithout text antialiasing) I found out that "1.5" in Word is actually ~1.92. Which is basically 2.0 instead of 1.5! I was so shocked and angry.I found out that font height is basically the vertically longest glyph in the font — most of the times
()are probably the tallest glyphs. And so theline spacing=1is when the()from one line barely touches()from an adjacent line. I just checked — space between 2 adjacent baselines is roughly the same as space from the lowest point of()to the lowest point of the next().When I used
\fontsize{14}{21}(and similar) in reality the leading was in the range of 1.55–1.65 which can be considered "1.5 line spacing" as 1, 1.5 and 2 can be defined as groups in which each exact line spacing fall. In other words, leading 1.4–1.6 falls in "1.5" group, 1.9–2.1 — "2" group etc. This means that I was actually right and the aforementioned validator was wrong. If only proprietary software (Google Docs & Microsoft Office) was explicit about what this "1.5" actually means! Or just simply stick to the truth and use an actual "1.5" instead of "1.92".Anyway, setting
block(spacing)orpar(leading)to0ptleads to this:Parenthesis are overlapped, but the rest of the glyphs are not. So, when leading is
0em, then the text lines could collide into each other — which is bad (this should never happen). Wait, but leading is space between baselines. In Typst case, it is the space between "the baseline of the top line" and "not the highest point of the bottom line" (kind of in the middle). Which only works for limited amount of glyphs (again, not including()and probably some other glyphs). And the "only works for the limited amount of glyphs" is the main problem. If Typst were to use "the better way", then it would work for any glyphs in the selected font. And the fact thatleadinginpar()(andblock(spacing)) is actually (leading–1 baseline) makes it more confusing.I'm practically begging to differ, i.e., change the definition of leading that Typst is following. For example, when I
#set par(leading: 1.5em)it would be the same as\fontsize{14}{21}, but more precise (as I mentioned this macro makes leading about 1.55–1.65 instead of 1.5, but you can make it exactly 1.5 with different macros). And when, for example, I#set block(spacing: 1em)it would show parenthesis on adjacent lines barely touching each other.This would make Typst more compatible with LaTeX and will remove all the "measuring" to get the ideal leading. When requirement says "set leading to 1.5" or "2", then Typst will actually do exactly that and everyone will be happy.
P.S. I didn't test leading in LibreOffice (and other FOSS). Sorry about switching between "line spacing" and "leading" a lot: when I was using "line spacing" I was referring to either quote from document requirements or just as a "widespread term" which is used in many software programs, and when I was using "leading" I was being more "correct" as leading is the original and more precise term.
Enivex commentedon Jun 18, 2023
They're just two different competing definitions of leading. The one typst uses is unarguably the oldest, original definition. Leading refers to the lead strips put between consecutive lines in manual typesetting, i.e. spacing between lines. Unfortunately with the advent of computer typesetting, some tools ended up using a different definition.
Andrew15-5 commentedon Jun 18, 2023
But what about tall glyphs? If
0emmeans0space between glyphs (in practice this is what it looks like), then what about parenthesis and other overlapping glyphs such aspandh?Is it really OK to leave this with no changes?
And LaTeX compatibility — why break the compatibility so bad? There is a guide for LaTeX users and a special section with settings that mimics the "LaTeX look":
This maybe will mimic the default LaTeX look, but you can't mimic the
\fontsize{10}{15}with#set par(leading: 15pt/1.5em)or#set par(leading: 5pt/0.5em)(including/excluding 1baselineskip). Everyone just defaults to using measuring tools to get leading just right.Typst is still in beta, and breaking changes are a normal thing at this stage. I think before stable release (i.e., in the near future) is the perfect time to switch the definition of leading to more understandable and widespread (and it's not a wrong definition too).
Enivex commentedon Jun 18, 2023
This has nothing to do with the definition of leading. It's the top-edge and bottom-edge options of https://typst.app/docs/reference/text/text/
Typst does not claim to be compatible with LaTeX.
Why did LaTeX break compatibility with physical typesetting so bad?
Only because you're starting with measurements using one definition, and want to apply them directly. You would have the same issue going the other way.
That is subjective. I find the definition that typst uses more understandable. It's also the original definition.
Andrew15-5 commentedon Jun 18, 2023
Well, yes, but I was speaking like I'm a LaTeX user who wants to "directly" port his leading settings to Typst (which isn't so far from the truth), and it wouldn't work because of the reason you said. I of course understand that leading settings in these programs are based on the different
truthsdefinitions.Andrew15-5 commentedon Jun 27, 2023
I checked and for me
0.25em"Typst leading" is "close enough" forx1 baselinea.k.a. 1.0 line spacing (sometimes also called leading) (tested for10ptand30pt, also for different fonts). This means that0.75emis approximately 1.5 line spacing and, therefore,1.25emis ~2.0 line spacing (well, more like 2.1).Basically:
With
leading: 0.25emparentheses do overlap a little (in some fonts more, in others less). For0.75emand1.25emthe error only increases (~1.56 instead of 1.5, ~2.1 instead of 2.0).If someone need more precise line spacing, then good luck with ruler measurements and pixel peeping.
balthild commentedon Oct 16, 2023
Just want to mention: after setting
par.leadingto zero, the distance between baselines actually equals totext.top-edge. You could experiment it to see this behavior:If you want to get the behavior like LaTeX, you could do
set text(top-edge: 0cm). However, this may lead to unexpected results as some default styles rely on something similar to the defaultpar.leadingbehavior.I recommend setting the
text.top-edgeto a certainemlength that matches your font, and then you could calculate a properpar.leadingthat results in a certain distance of baselines. For example, I haveset text(top-edge: 0.85em)because0.85emcould just matches the top edge of the CJK characters in my font; then, I haveset par(leading: 0.9em), and the actual distance of baselines will be0.85em + 0.9em = 1.75em.Update
I did some hack and found that similar spacing behavior could be achieved better with
measure. However, it is only suitable for non-CJK documents.