Thanks. For question number 3, your code to conditionally suppress the period works great. I now have this code:
#set par(justify: true, first-line-indent: 1em, spacing: 0.6em)
#let body-size = 11pt
#set text(font: "New Computer Modern", size: body-size)
#set heading(numbering: "1.1." + sym.space.quad)
#show heading.where(level: 1): smallcaps
#show heading.where(level: 1): set align(center)
#show heading.where(level: 1): set text(size: 13pt, weight: "regular")
#let space-above-inline-heads = 1em
#show heading.where(level: 2): set text(size: body-size)
#show heading.where(level: 2): it => {
v(space-above-inline-heads)
h(-par.first-line-indent.amount)
counter(heading).display()
it.body
if it.body.text.last() not in (".", "?", "!") { "." }
"---"
}
#show heading.where(level: 3): set text(size: body-size, weight: "regular")
#show heading.where(level: 3): it => {
v(space-above-inline-heads)
h(-par.first-line-indent.amount)
emph({
counter(heading).display()
it.body
if it.body.text.last() not in (".", "?", "!") { "." }
"---"
})
}
// Clever trick to reduce spacing between consecutive headings
// See https://github.com/typst/typst/issues/2953#issuecomment-3187505828
#show heading: it => {
let previous-headings = query(selector(heading).before(here(), inclusive: false))
if previous-headings.len() > 0 {
let ploc = previous-headings.last().location().position()
let iloc = it.location().position()
if (iloc.page == ploc.page and iloc.x == ploc.x and iloc.y - ploc.y < 30pt) { // Threshold
v(-10pt) // Amount to reduce spacing, could make this dependent on it.level
}
}
it
}
= Introduction
#lorem(25)
#lorem(15)
== Motivation
#lorem(20)
=== Subsubsection
#lorem(15)
== Etc.
=== Subsubsection
#lorem(20)
Here is screenshot:
Original question 1) I like what I see in How can I prevent indent on paragraphs with run-in headings? - #2 by ensko to conditionally suppress the indentation of a par when it has been merged with a run-in heading, but have set it aside for now, leaving the approach of negative space. The screenshot shows the unwanted spaces after the dashes. These are selectable characters in the PDF output and this appear to be space characters. I do not understand why the trailing space is wider in the H3 than in the H2.
Original question 2) Sloppy word choice — yes, I meant a small amount excess space not kerning. Setting this complaint aside as the new code has large excess space in place of small excess space.
Original question 3) Yes your conditional period appears to work perfectly.
