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

Inconsistent list indentation depending on marker width #4126

Open
1 task done
Gravitonic opened this issue May 13, 2024 · 9 comments
Open
1 task done

Inconsistent list indentation depending on marker width #4126

Gravitonic opened this issue May 13, 2024 · 9 comments
Labels
bug Something isn't working layout Related to layout, positioning, etc.

Comments

@Gravitonic
Copy link

Description

Because the layout of lists (list and enum) are adjusted by the spacing before and after markers, the width of the marker itself can affect the indentation of the list. Since different lists' markers can have different widths, this means that lists can have different indentation:

Screenshot

Untitled

Typst code to reproduce

+ one
+ two
+ three

intervening paragraph

11. eleven
+ twelve
+ thirteen

In contrast, LaTeX, Google Docs, and Microsoft Word all seem to let users set the indentation based on the list item bodies.

LaTeX

Screenshot 2024-05-13 at 9 32 14 AM

Google Docs

image

Microsoft Word

image

Reproduction URL

https://typst.app/project/rqnPOljOs8eDzgh36DKpki

Operating system

Web app, macOS

Typst version

  • I am using the latest version of Typst
@Gravitonic Gravitonic added the bug Something isn't working label May 13, 2024
@Gravitonic Gravitonic changed the title Write a short and descriptive title! Inconsistent list indentation depending on marker width May 13, 2024
@Enivex Enivex added the layout Related to layout, positioning, etc. label May 24, 2024
@Enter-tainer
Copy link
Contributor

Enter-tainer commented Jun 4, 2024

In LaTeX, the list markers are right aligned, and there is a minimal gap between list marker and actual content.

image

@Enter-tainer
Copy link
Contributor

When list marker is left aligned, the dot will not be aligned:

\usepackage{enumitem}
\newcommand\setItemnumber[1]{\setcounter{enumi}{\numexpr#1-1\relax}}

\begin{enumerate}[align=left]
    \item first
    \item second
    \setItemnumber{500000000000}
    \item very large
\end{enumerate}

image

@Enter-tainer
Copy link
Contributor

Enter-tainer commented Jun 5, 2024

Looks like word and latex has interesting behavior when aligning list markers and list content
Microsoft word:

image

LaTeX:

\documentclass{article}
\usepackage{enumitem}
\usepackage{lua-visual-debug}

\newcommand\setItemnumber[1]{\setcounter{enumi}{\numexpr#1-1\relax}}

\begin{document}

\maketitle

\section{Introduction}

\begin{enumerate}[align=left, nosep]
    \item first
    \item second
    \setItemnumber{9}
    \item 9
    \item 9
    \item 9
    \setItemnumber{99}
    \item lorem
    \item lorem
    \item lorem
    \setItemnumber{999}
    \item lorem
    \item lorem
    \item lorem
    \setItemnumber{9999}
    \item lorem
    \item lorem
    \setItemnumber{99999}
    \item lorem
    \item lorem
    
\end{enumerate}

image

@Enter-tainer
Copy link
Contributor

Overall I feel like both word, typst and LaTeX's solution is good. Currently typst can align list content and list marker using grids, at the cost of baseline mismatch. It would be better if list marker in typst can be in the paragraph as list content, so they share the same baseline naturally.

For me i think normal people will never notice the alignment difference: they will never have a super long list that has more than 100 items.

@Enivex
Copy link
Collaborator

Enivex commented Jun 5, 2024

Overall I feel like both word, typst and LaTeX's solution is good. Currently typst can align list content and list marker using grids, at the cost of baseline mismatch. It would be better if list marker in typst can be in the paragraph as list content, so they share the same baseline naturally.

For me i think normal people will never notice the alignment difference: they will never have a super long list that has more than 100 items.

The list doesn't necessarily have to include more than 100 items. You can skip numbers. You may also use non-decimal numbers (roman numerals for instance)

Real life example: Doing a review where the numbers correspond to page or line numbers.

@Enter-tainer
Copy link
Contributor

Overall I feel like both word, typst and LaTeX's solution is good. Currently typst can align list content and list marker using grids, at the cost of baseline mismatch. It would be better if list marker in typst can be in the paragraph as list content, so they share the same baseline naturally.
For me i think normal people will never notice the alignment difference: they will never have a super long list that has more than 100 items.

The list doesn't necessarily have to include more than 100 items. You can skip numbers. You may also use non-decimal numbers (roman numerals for instance)

Real life example: Doing a review where the numbers correspond to page or line numbers.

Yes, that is correct.

@Enter-tainer
Copy link
Contributor

For this case, I think we can first measure the maximum width of all list markers. Then we can correctly set the width of the box. So we can beat LaTeX and word 😎

@Enivex
Copy link
Collaborator

Enivex commented Jun 5, 2024

For this case, I think we can first measure the maximum width of all list markers. Then we can correctly set the width of the box. So we can beat LaTeX and word 😎

I think that tex and word is choosing a middle ground on purpose. Imagine you had one label that's much longer than the other ones.

@Enter-tainer
Copy link
Contributor

For this case, I think we can first measure the maximum width of all list markers. Then we can correctly set the width of the box. So we can beat LaTeX and word 😎

I think that tex and word is choosing a middle ground on purpose. Imagine you had one label that's much longer than the other ones.

It looks like the default in tex and word can fit in 3~4 numbers. I think this is a good default and this covers most use case. The width can also be customized.

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

3 participants