I try to understand how to import show heading. I copied an example (working) and cut it in a main and an imported file and it stoped working.
The file dragon.typ to import:
#show heading: set align(center)
#show heading: set text(font: "DejaVu Sans Mono" )
#show heading: it => block[
\~
#emph(it.body)
#counter(heading).display(it.numbering)
\~
]
and the main:
#import "dragon.typ" : *
#set heading(numbering: "(I)")
= Dragon
With a base health of 15, the dragon is the most
powerful creature.
= Manticore
While less powerful than the dragon, the manticore
gets extra style points.
The show heading - which I understand is executed on import - is not showing effect. The titles are left aligned, not centered, not italics etc. What is my misunderstanding?
This is similar to How can I create a set of shared `set` and `show` rules which can be imported into a theme? - #3 by ParaN3xus and can be sorted out by wrapping your code into a function that will be used as a template for your document.
Also see Making a Template – Typst Documentation as it describes the process step by step.
#let my-template(body) = {
show heading: set align(center)
show heading: set text(font: "DejaVu Sans Mono" )
show heading: it => block[
\~
#emph(it.body)
#counter(heading).display(it.numbering)
\~
]
body
}
Then
#import "dragon.typ" : *
#show: my-template
#set heading(numbering: "(I)")
= Dragon
With a base health of 15, the dragon is the most
powerful creature.
= Manticore
While less powerful than the dragon, the manticore
gets extra style points.
1 Like
Thank you - works! I have read the template section in the documentation but did not generalized the message in it. I have tried the approach with the function that wraps around, but did not include the body as argument and was not understanding the show all construction mentioned there. Thank you for clarification and I hope for more documentation!
1 Like