Skip to content

Page numbers are left aligned in note-outline #43

@Bstn1802

Description

@Bstn1802

The page numbers appear left aligned as soon as some have multiple digits. While this could be easily fixed by setting the alignment of the third column to bottom + right it would make the line of dots stop earlier for entries with a single digit page number so it is necessary to merge the second and third column.

Comparing note-outline to the built-it outline for headings, I noticed that outline wraps text differently and allows text to go above the page number. Personally, I like that note-outline forces text to break right before the page number by using separate columns of a grid, so in my proposal below I kept the aesthetic.

Relevant part of drafting.typ:

typst-drafting/drafting.typ

Lines 407 to 425 in 4592eef

grid(
columns: (1em, 1fr, 10pt),
column-gutter: 5pt,
align: (top, bottom, bottom),
box(
fill: note-props.fill,
stroke: if note-props.stroke == none {
none
} else if paint != note-props.fill {
paint
} else {
black + .5pt
},
width: 1em - 2pt,
height: 1em - 2pt,
),
[#note-props.body #box(width: 1fr, repeat[.])],
[#note.location().page()],
),

Proposed change of that section:

grid(
  columns: (1em, 1fr),
  column-gutter: 5pt,
  align: (top, bottom),
  box(
    fill: note-props.fill,
    stroke: if note-props.stroke == none {
      none
    } else if paint != note-props.fill {
      paint
    } else {
      black + .5pt
    },
    width: 1em - 2pt,
    height: 1em - 2pt,
  ),
  [#box(width: 1fr, [#note-props.body #box(width: 1fr, repeat[.])]) #note.location().page()],
),

Before:
Image

After:
Image

Built-in outline for reference (which I personally actually don't like):
Image

Example used to test different cases and generate the before and after screenshots:

#import "@preview/drafting:0.2.2": inline-note, note-outline

#note-outline()

#pagebreak()

// short entry
#inline-note[#lorem(10)]

#range(4).map(_ => pagebreak()).join()

// demonstrate word wrap with single digit page number
#inline-note[,,,#lorem(20)]
#inline-note[,,,,#lorem(20)]

#range(4).map(_ => pagebreak()).join()

// entry with double digit page number
#inline-note[#lorem(10)]

#range(4).map(_ => pagebreak()).join()

// demonstrate word wrap with double digit page number
#inline-note[,#lorem(20)]
#inline-note[,,#lorem(20)]

(I used commas to slightly push words to the edge and force a word wrap. Not sure if this is consistent across different systems/fonts)

PS: Is it possible to get syntax highlighting for typst in markdown code blocks? I tried ```typ and ```typst

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions