Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve layout of multi-line headings #2410

Closed
deffi opened this issue Oct 17, 2023 · 8 comments
Closed

Improve layout of multi-line headings #2410

deffi opened this issue Oct 17, 2023 · 8 comments
Labels
feature request New feature or request layout Related to layout, positioning, etc.

Comments

@deffi
Copy link

deffi commented Oct 17, 2023

Example document:

#set heading(numbering: "1.1")

= One
== One point one: #lorem(20)

Result (Typst 0.8):
Typst result

It seems like this could be improved by aligning subsequent lines with the text of the first line, not with the number

This is how LaTeX renders the same thing:

LaTeX result

And MS Word 2016:

Word result

See also #2411 (similar issue, but for the outline instead of the heading)

@tingerrr
Copy link
Contributor

tingerrr commented Oct 17, 2023

This, as well as #2411, could be fixed by making headings show as stack(dir: ltr, numbering, body) by default as well as doing the same for outline.entry.

EDIT: This solution is blocked by #2422, but can be worked around using a grid for now.

@laurmaedje
Copy link
Member

The stack solution doesn't work correctly at the moment because a horizontal stack, in contrast to a grid, doesn't correctly size its children to fit the width. This means that the body will overflow into the right margin. This should be fixed.

@Enivex
Copy link
Collaborator

Enivex commented Oct 17, 2023

Isn't this largely a matter of personal preference, and something that would vary from template to template?

I'm honestly not a fan of having text aligned to a different vertical line than the margin. That being said, I would never choose titles this long in the first place.

@tingerrr
Copy link
Contributor

For now, you can use:

#show heading: it => if it.numbering != none {
  grid(columns: 2, gutter: 0.3em, counter(heading).display(it.numbering), it.body)
} else {
  it.body
}

Which is faithful to the default show rule. A similar thing can be done for outline.entry in #2411.

@deffi
Copy link
Author

deffi commented Oct 18, 2023

Isn't this largely a matter of personal preference, and something that would vary from template to template?

It may be a matter of personal preference, or it may be a matter of (corporate/academic) style guidelines. So I agree that this should be configurable; I wasn't trying to imply that the way LaTeX or Word are doing it is the only correct one.

I'm honestly not a fan of having text aligned to a different vertical line than the margin.

Not even in bullet lists? I think that aligning the text to the right of the bullets is by far the most common layout here. An outline (cf. #2411) seems pretty similar to a (nested) numbered list, and many authors are also applying that layout to the headings themselves.

That being said, I would never choose titles this long in the first place.

This, too, would probably depend on the context. A very quick survey of some textbooks and technical documentation within my reach indicates that titles which exceed the length of a line aren't terribly uncommon.

@laurmaedje laurmaedje added feature request New feature or request layout Related to layout, positioning, etc. labels Oct 22, 2023
@haenoe
Copy link
Contributor

haenoe commented Feb 16, 2024

Hey! Big Typst fan here - thank you all for your tremendous work. I would love to help the project and contribute.
Therefore my question: Is this issue still relevant?

After looking a bit around the codebase my first idea was to solve it using the same technique applied by the #enum(), which internally uses a grid (see here) to correctly separate the numbering/symbol from the content.
Does this make sense in this case here (and in the context of #outline() (see #2411)?

Thank you!

@tingerrr
Copy link
Contributor

Go ahead and implement it, I think it's a better default than the current solution. We don't lose any flexibility so this should be fine. It comes down to laurenz if it will be accepted.

@laurmaedje
Copy link
Member

Solved by #3459

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request layout Related to layout, positioning, etc.
Projects
None yet
Development

No branches or pull requests

5 participants