moyan pan
moyan pan

Reputation: 21

How can I use right-aligned text in Typst?

I'm currently developing my resume at the moment, how can I setup all texts in Typst like in the image down below?

Example Image

I found the official documentation of alignment but nothing was mentioned, wondering if I can set the text like in the image?

Upvotes: 2

Views: 1390

Answers (1)

ntjess
ntjess

Reputation: 1470

You can either use a grid or a table, but in this case a table makes formatting a little easier. I'm also using the tablex package because it allows you to format each table cell based on its x/y position, which helps avoid styling each item individually.

Specifically, set align(right) in the format-titles function right-aligns the left column and the gutters of the table indicate the spacing.

#import "@preview/tablex:0.0.8": tablex

#show heading: it => [
  #box(it)
  #box(width: 1fr, line(length: 100%))
]
#set text(font: "Roboto")

= Skills & Certifications

#let format-titles(cell) = {
  cell.content = if calc.even(cell.x) {
      set text(weight: "bold", size: 1.1em)
      set align(right)
      cell.content
    } else {
      set text(weight: "light")
      cell.content
    }
  cell
}

#tablex(
  columns:2,
  stroke: none,
  inset: 0pt,
  row-gutter: 1em,
  column-gutter: 1em,
  map-cells: format-titles,
)[
  ServiceNow Certification
][
  System admin
][
  General Programming Knowledge
][
  Git, Linux, CLI
][
  Frontend Development
][
  HTML5, Javascript, CSS
]

enter image description here

Upvotes: 3

Related Questions