How to achieve a better alignment in a table?

Hi (again)!

I’ve stripped everything from the real file to provide only the necessary basic code^^

The “:” characters are currently put inside their own column which doesn’t look very good and is prone to break when the form will use a different language (e.g. french) because of longer character lengths.

Is there a better way to keep the alignment for the “:” without having to fall back to a monospace font?


#set page(
  paper: "a4"
)

#set text(
  font: "Segoe UI",
  size: 10pt
)

#pad(top: 14mm, left: -1mm)[
  #grid(
    columns: 2,
    gutter: 42mm,
    table(
      columns: (30mm, 5mm, 28mm),
      stroke: none,
      [Rechnungsnummer],  [:], [#text(fill: rgb(47, 85, 154))[\#20250301]],
      [Rechnungsdatum],   [:], [#text(fill: rgb(47, 85, 154))[14.01.2025]],
      [Fälligkeitsdatum], [:], [#text(fill: rgb(47, 85, 154))[28.01.2025]],
      [Fälligkeitstage],  [:], [#text(fill: rgb(47, 85, 154))[14]],
      [Währung],          [:], [#text(fill: rgb(47, 85, 154))[EUR]]
    ),
    table(
      columns: (17mm, 5mm, 1fr),
      stroke: none,
      [Name], [:], [#text(fill: rgb(47, 85, 154))[Kunde A]],
      [Zusatz], [:], [Provider],
      [Straße], [:], [Musterstraße 1],
      [Ort], [:], [1234 Musterort],
      [Land], [:], [Deutschland],
      [Kundennr.], [:], [#text(fill: rgb(47, 85, 154))[MM001]],
    )
  )
]

Tia, highend!

Hi,

you could try to align the colon using a horizontal and fractional space:

#pad(top: 14mm, left: -1mm)[
  #grid(
    columns: 2,
    gutter: 42mm,
    table(
      columns: (2),
      stroke: none,
      [Rechnungsnummer#h(1fr):], [#text(fill: rgb(47, 85, 154))[\#20250301]],
      [Rechnungsdatum#h(1fr):], [#text(fill: rgb(47, 85, 154))[14.01.2025]],
      [Fälligkeitsdatum#h(1fr):], [#text(fill: rgb(47, 85, 154))[28.01.2025]],
      [Fälligkeitstage#h(1fr):], [#text(fill: rgb(47, 85, 154))[14]],
      [Währung#h(1fr):], [#text(fill: rgb(47, 85, 154))[EUR]]
    ),
    table(
      columns: (17mm, 5mm, 1fr),
      stroke: none,
      [Name], [:], [#text(fill: rgb(47, 85, 154))[Kunde A]],
      [Zusatz], [:], [Provider],
      [Straße], [:], [Musterstraße 1],
      [Ort], [:], [1234 Musterort],
      [Land], [:], [Deutschland],
      [Kundennr.], [:], [#text(fill: rgb(47, 85, 154))[MM001]],
    )
  )
]

Another alternative is to switch the alignment, which I have seen more than leaving a space between the text and the colon.

table(
      columns: (17mm, 1fr),
      align: (right, left, left),
      stroke: none,
      [Name:], [#text(fill: rgb(47, 85, 154))[Kunde A]],
      [Zusatz:], [Provider],
      [Straße:], [Musterstraße 1],
      [Ort:], [1234 Musterort],
      [Land:], [Deutschland],
      [Kundennr.:], [#text(fill: rgb(47, 85, 154))[MM001]],
    )

4 Likes

@Florian
Cool, I didn’t know that:

#h(1fr)

can be used inside a cell!
Thanks, that’s a perfect solution for my requirements^^

@quachpas
Thanks as well but I personally don’t like that style that much, it looks… somehow messy :innocent:

Thanks guys!

2 Likes

@Highend - you’re welcome, i’m happy it helps.

There are many creative ways to put stuff together - i’m happy the community is so helpful. :pray: