I want to make it so
= Section
== Subsection
shows as
1 Section
Subsection 1.1
I tried doing that using
#show heading.where(level: 2): it => box(strong(it.body + " "))
but that just shows the heading format string
I want to make it so
= Section
== Subsection
shows as
1 Section
Subsection 1.1
I tried doing that using
#show heading.where(level: 2): it => box(strong(it.body + " "))
but that just shows the heading format string
You can get the heading number from the built-in counter
. The counter requires context to evaluate/display, and the block is used to get the default behavior of a heading.
#set heading(numbering: "1.1")
#show heading.where(level: 2): it => context block(
it.body + [ ] + counter(heading).display()
)
= A Section
== A Subsection
== Another Subsection
Hello. For this, you would have to recreate the default heading show rule from scratch and change its behavior:
#import "@preview/text-dirr:1.0.0": text-dir
#set heading(numbering: "1.")
#show heading.where(level: 2): it => {
let body = [#it.body #counter(heading).display(it.numbering)]
let indent = if it.hanging-indent == auto { 0pt } else { it.hanging-indent }
if indent != 0pt { body = h(-indent) + body }
let side = if text-dir() == ltr { "left" } else { "right" }
block(sticky: true, inset: ((side): indent), body)
}
= Section
== Subsection
#heading(depth: 2, hanging-indent: 5em, numbering: "I.")[#lorem(15)]
Now that the text-dirr
package is out, so you can fully copy the default behavior that uses “start” alignment or side, which depends on text.dir
.