Skip to content

Explain how to use multiple fonts in sub/superscripts #8090

Closed

Description

@YDX-2147483647

Description

The baseline and size of sub/superscripts are determined by the font.
If you use multiple fonts with inconsistent metrics, then the result will be poor.

I don't think Typst can do anything here, so let's suggest that the authors specify the baseline and size explicitly.

Discussion on Discord on 2026-04-11

Basic examples

Latin

Image
#let Alpha = text(font: "STIX Two Math", sym.Alpha)
M#super[A#Alpha;A#Alpha;A#Alpha;A]

Han

This was originally reported by an unknown person 纸浪i on 2026-03-11.
typst-doc-cn/clreq#91

Image
#set text(font: "Noto Serif CJK SC")
#show emph: set text(font: "KaiTi")

Current: \
标#super[字_词_]

Expected: \
#set super(baseline: -0.5em, size: 0.5em)
标#super[字_词_]

There is no italics in CJK scripts. To emphasize something, the author can change the font. The font KaiTi (中易楷体) here is shipped with the Windows OS.

More comparison

Image
Code
#set page(height: auto, width: auto, margin: 15pt)

#let example = {
  set text(2em, font: "Noto Serif CJK SC")
  [宋]
  super({
    text(font: "KaiTi")[楷]
    [宋]
    text(font: "Libertinus Serif")[a]
  })
}

#let try(..args) = {
  let print(key) = {
    let value = args.at(key, default: none)
    if value != none {
      raw(repr(value))
    }
  }

  (
    print("baseline"),
    print("size"),
    print("typographic"),
    {
      set super(..args)
      example
    },
  )
}

#set text(font: ("Libertinus Serif", "Noto Serif CJK SC"))
#set raw(lang: "typc")
#show emph: set text(purple)
#import table: cell, hline
#table(
  columns: (auto,) * 4 + (23em,),
  stroke: none,
  align: (x, y) => if x < 3 or y < 2 { center } else { start } + horizon,
  inset: (y: 0.7em),

  hline(),
  cell(colspan: 3)[*`set super(…)`*],
  cell(rowspan: 2)[*Result*],
  cell(rowspan: 2)[*Comment*],
  hline(stroke: 0.5pt),
  `baseline`, `size`, `typographic`,
  hline(),

  ..try(baseline: auto, size: auto, typographic: true),
  [_Default._ Unlisted values in other rows are identical to those in this row.],

  hline(stroke: 0.5pt),
  ..try(baseline: -0.35em),
  [For reference, both Noto Serif CJK and Libertinus Serif set `ySuperscriptYOffset` to 350/1000.],
  ..try(baseline: -0.35em, size: 0.6em),
  [_Expected._ For reference, both Noto Serif CJK and Libertinus Serif set `ySuperscriptYSize` to 600/1000.],

  hline(stroke: 0.5pt),
  ..try(baseline: -0.5em, size: 0.5em),
  [For reference, KaiTi sets `ySuperscriptYSize` and `Offset` to 128/256.],
  ..try(baseline: -0.5em, size: 0.5em, typographic: false),
  [_Also acceptable._],

  hline(stroke: 0.5pt),
  ..try(baseline: -0.1em),
  cell(rowspan: 4)[
    More experiments: `baseline` and `size` only apply to synthesized superscripts; in other words, they have no effect for the typographic “a”.
  ],
  ..try(baseline: -0.1em, size: 0.2em),
  ..try(baseline: -0.7em, size: 0.2em),
  ..try(baseline: -0.7em, size: 0.2em, typographic: false),

  hline(),
)

Activity

  1. added
    docs
    on Apr 10, 2026
  2. added 2 commits that reference this issue on Apr 11, 2026
    4a43c8a
    2b3a9a4
  3. added
    text
    on Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docstext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions