How can I create a set of shared `set` and `show` rules which can be imported into a theme?

In case you still don’t understand: In your example, the set and show functions in styling.typ only work within their own scope, which is within styling.typ. Therefore, they cannot style other parts of the document.

To fix this, you need to write a function that takes content and returns styled content, like:

styling.typ

#let styling(it) = {
  set text(
    size: 10pt,
    fill: blue,
    font: ("Lato", "Noto Sans", "Fira Sans"),
    lang: "en",
    ligatures: true,
    discretionary-ligatures: true,
    historical-ligatures: true,
  )

  show math.equation: set text(
    font: ("Lete Sans Math", "Noto Sans Math", "Fira Math"),
    ligatures: true,
    discretionary-ligatures: true,
    historical-ligatures: true,
  )
  show raw: set text(
    font: "Space Mono",
    ligatures: true,
    discretionary-ligatures: true,
    historical-ligatures: true,
  )
  it
}

template.typ

#let exercise(title: "", date: none, body) = {
  ...

  import "styling.typ": styling
  show: styling

  body
}
4 Likes