Skip to content

List indentation should not depend on marker width #4126

Open

Description

@Gravitonic

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

Activity

  1. added
    bug
    on May 13, 2024
  2. changed the title [-]Write a short and descriptive title![/-] [+]Inconsistent list indentation depending on marker width[/+] on May 13, 2024
  3. added
    layout
    on May 24, 2024
  4. Enter-tainer commented on Jun 4, 2024

    @Enter-tainer
    Contributor

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

    image

  5. Enter-tainer commented on Jun 5, 2024

    @Enter-tainer
    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

  6. Enter-tainer commented on Jun 5, 2024

    @Enter-tainer
    Contributor

    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

  7. Enter-tainer commented on Jun 5, 2024

    @Enter-tainer
    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.

  8. Enivex commented on Jun 5, 2024

    @Enivex
    Collaborator

    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.

  9. Enter-tainer commented on Jun 5, 2024

    @Enter-tainer
    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.

  10. Enter-tainer commented on Jun 5, 2024

    @Enter-tainer
    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 😎

  11. Enivex commented on Jun 5, 2024

    @Enivex
    Collaborator

    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.

  12. Enter-tainer commented on Jun 5, 2024

    @Enter-tainer
    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.

  13. Enter-tainer commented on Jul 7, 2024

    @Enter-tainer
    Contributor

    Comparison between LaTeX and word for lists with longer content. @laurmaedje what do you think of this? Will it make sense if we switch enum/list implementation to something similar to this?

    image
    image

  14. laurmaedje commented on Jul 8, 2024

    @laurmaedje
    Member

    Yes, I think we should switch lists to something like this. I believe Word uses tab stops to implement the behaviour. Without them or a min-width property, I think it will be hard to get this behaviour. I started a branch for tab stops recently.

  15. Enter-tainer commented on Jul 8, 2024

    @Enter-tainer
    Contributor

    I started a branch for tab stops recently.

    Sounds cool! I'd like to do some initial work by reimplementing list/enum in a term-list-like way. And I guess I can somehow use your tab stop feature when it is merged.

  16. changed the title [-]Inconsistent list indentation depending on marker width[/-] [+]List indentation should not depend on marker width[/+] on Oct 8, 2024
  17. added
    change request
    and removed
    bug
    on Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    change requestlayout

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions