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

Paragraph justification sometimes doesn't use the full page width #5472

Open
1 task done
Andrew15-5 opened this issue Nov 26, 2024 · 12 comments
Open
1 task done

Paragraph justification sometimes doesn't use the full page width #5472

Andrew15-5 opened this issue Nov 26, 2024 · 12 comments
Labels
bug Something isn't working layout Related to layout, positioning, etc.

Comments

@Andrew15-5
Copy link
Contributor

Description

#set page(margin: (left: 3cm, right: 1cm))
#set text(14pt)
#set par(justify: true)

+ Методология и технология проектирования информационных систем: учебное пособие
  \/ Ю. М. Казаков, А. А. Тищенко, А. А. Кузьменко [и др.]. --- Москва: ФЛИНТА,
  \2018. --- 136 с. --- ISBN 978-5-9765-4013-2. --- Текст: электронный \//
  Электронно-библиотечная система «Лань»: [сайт]. --- URL:
  https://e.lanbook.com/book/113460
+ Ипатова, Э. Р. Методологии и технологии системного проектирования информационных
  систем: учебное пособие / Э. Р. Ипатова. --- 2-е изд., стер. --- Москва: ФЛИНТА,
  \2016. --- 256 с. --- ISBN 978-5-89349-978-0. --- Текст: электронный \//
  Электронно-библиотечная система «Лань»: [сайт]. --- URL:
  https://e.lanbook.com/book/84356
// + #lorem(24)

#v(0cm)

+ https://geekbrains.ru/posts/development_methodology_msf --- Методология MSF
+ http://www.informicus.ru/default.aspx?SECTION=6&id=73&subdivisionid=7 --- Методология
  RUP

image

As soon as I insert + #lorem(24) in the first list, they both become full-width:

image

I cannot explain why would this ever happen. I never noticed this before, but apparently this behavior is the same for previous versions too. I guess I rarely have 2 lists on the same page.

By definition, the justification stretches the content to the full-width of the page. My only hunch is something to do with non-Latin/Unicode stuff.

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst
@Andrew15-5 Andrew15-5 added the bug Something isn't working label Nov 26, 2024
@Enivex
Copy link
Collaborator

Enivex commented Nov 26, 2024

I suspect that this may be a duplicate of #5449 ? The issues seem very similar

@Andrew15-5
Copy link
Contributor Author

It's not a regression, so I doubt that.

@laurmaedje
Copy link
Member

Probably the list (which is laid out as a grid) has shrink-to-fit semantics from the grid.

@laurmaedje laurmaedje added the layout Related to layout, positioning, etc. label Nov 26, 2024
@Andrew15-5
Copy link
Contributor Author

But I don't know any field that does that, which means there is no workaround? Without completely rewriting the list show rule in Typst.

https://typst.app/docs/reference/layout/grid/

@PgBiel
Copy link
Contributor

PgBiel commented Nov 26, 2024

In principle they are just auto columns, separate lists are separate grids so they aren't in the same column. The underlying problem has the same cause as the centering equations in lists issue (#529).

However, what isn't clear is why justification isn't requesting the full width. Usually, the text would cause the list to resize to full width due to being too long.

In either case, the fix would be similar as the other issue. You can try to add #h(1fr) at the end of a line in the smaller list (or in both).

@Andrew15-5
Copy link
Contributor Author

Nice! Adding #h(1fr) at the end of the 1st or 2nd item does the trick, thanks.
But now I have a small question: how to avoid the space before # (if it actually affects anything)? Because without it, the URL will have the id h(1fr) (which is an interesting edge case for URL + code mode).

@PgBiel
Copy link
Contributor

PgBiel commented Nov 26, 2024

I'm pretty sure the space there doesn't make much of a difference since what comes after it is also a space, but, if it's really necessary, you can write #[https://...]#h(1fr).

@laurmaedje
Copy link
Member

However, what isn't clear is why justification isn't requesting the full width. Usually, the text would cause the list to resize to full width due to being too long.

The width is determined as the maximum natural line width after line breaking. So it doesn't necessarily request the full width.

@Enivex
Copy link
Collaborator

Enivex commented Nov 27, 2024

However, what isn't clear is why justification isn't requesting the full width. Usually, the text would cause the list to resize to full width due to being too long.

The width is determined as the maximum natural line width after line breaking. So it doesn't necessarily request the full width.

That's unfortunate, since it'll lead to situations like this, where the margin is uneven

Edit: As far as I can recall, this is not how justification works elsewhere

@laurmaedje
Copy link
Member

It's only in blocks with shrink-to-fit behaviour.

@Enivex
Copy link
Collaborator

Enivex commented Nov 27, 2024

It's only in blocks with shrink-to-fit behaviour.

How do I know if a given block has that kind of behavior?

See also #5479

@laurmaedje
Copy link
Member

All non-fixed-size blocks have that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working layout Related to layout, positioning, etc.
Projects
None yet
Development

No branches or pull requests

4 participants