#let thai-numbering(n) = {
  let chars = ("ก", "ข", "ค", "ง", "จ", "ฉ", "ช")
  if n <= chars.len() {
    chars.at(n - 1)
  } else {
    str(n - chars.len()) // fallback to numbers if exceeds available characters
  }
}

#let chapter-page(doc) = {
  set page(
    paper: "a4",
    margin: (
      top: 2in,
      left: 1.5in,
      right: 1in,
      bottom: 1in,
    ),
    header: context [
      #h(1fr)
      #counter(page).display(thai-numbering)
    ],
  )
  doc
}

#let page-theme(doc) = {
  set page(
    paper: "a4",
    margin: (
      top: 1.5in,
      left: 1.5in,
      right: 1in,
      bottom: 1in,
    ),
    header: context [
      #h(1fr)
      #counter(page).display(thai-numbering)
    ],
  )
  set text(
    lang: "th",
    font: "Laksaman",
    size: 10.5pt,
  )
  set par(
    justify: true,
    justification-limits: (
      tracking: (min: -1pt, max: 3pt),
    ),
    leading: 1em,
  )
  set list(indent: 1em)
  show heading: set text(size: 10.5pt)
  show heading: set block(below: 1em)
  show heading.where(level: 1): set text(size: 12pt)
  show heading.where(level: 1): set align(center)
  show raw: set text(font: "Cascadia Code", size: 10pt)
  show table.cell.where(y: 0): strong
  set ref(supplement: "หัวข้อ")
  doc
}

// Figure with attribution information
#let afigure(
  body,
  attr: "",
  ..args,
) = [
  #figure(body, ..args)
  #box(
    hide(attr),
    width: 0pt,
    height: 0pt,
  ) <afig>
]

#let i = h(3em)
