Open f3fora opened 1 week ago
I think that's hard to implement, you might consider setting the color of primary.
As you wish, However, I believe the solution is really simple.
You can just remove the .body
in https://github.com/touying-typ/touying/blob/334f8a2190ae1767c269b75474c7d33f0aa8f0bc/src/utils.typ#L344
, or at least allow an option to trigger this.
Ok, I thought removing .body
would cause numbering and outline errors, but it doesn't seem to be. However, there will still be problems with text size. I would consider adding this as an option in the next release. Thanks!
I suggest that the function display current heading
can be modified as:
#let display-current-heading(
self: none,
level: auto,
numbered: true,
hierachical: true,
depth: 9999,
setting: body => body,
..sty,
) = (
context {
let sty = if sty.pos().len() == 0 {
current-heading => {
if numbered and current-heading.numbering != none {
_typst-builtin-numbering(
current-heading.numbering,
..counter(heading).at(current-heading.location()),
) + h(.3em)
}
current-heading
}
} else if sty.pos().len() == 1 {
sty.pos().at(0)
} else if sty.pos().len() > 1 {
panic("sty allows only a positional argument")
}
let current-heading = utils.current-heading(level: level, hierachical: hierachical, depth: depth)
if current-heading != none {
setting(sty(current-heading))
}
}
)
To achieve the same results in e.g. in simple
theme, modifying header
as
header: self => display-current-heading(
setting: utils.fit-to-width.with(grow: false, 100%),
depth: self.slide-level,
it => it.body,
),
Moreover, given that there is a scale
factor in the headings with level 1 and 2 (see https://github.com/typst/typst/blob/8a8c4cec77342cc8c0772122cd2d0a71085c2c24/crates/typst/src/model/heading.rs#L266-L287), one may want to set
#show heading.where(level: 1): set text(size: (1em / 1.4))
#show heading.where(level: 2): set text(size: (1em / 1.2))
This doesn't solve the text-size problem and can lead to double numbering. I'd consider adding a 'native' parameter that defaults to false to control this behavior, so that theme developers can choose from it.
Nonetheless, the parameter of sty
in the utils.display-current-heading
currently is
...len() > 1
should be ...len() == 1
. See: https://github.com/touying-typ/touying/blob/334f8a2190ae1767c269b75474c7d33f0aa8f0bc/src/utils.typ#L331-L336After some thoughts, I suggest this implementation:
#let display-current-heading(
self: none,
level: auto,
hierachical: true,
depth: 9999,
sty: (setting: body => body, numbering: false, current-heading) => setting({
if numbering and current-heading.numbering != none {
_typst-builtin-numbering(
current-heading.numbering,
..counter(heading).at(current-heading.location()),
) + h(.3em)
}
current-heading.body
}),
..setting-args,
) = (
context {
let current-heading = utils.current-heading(level: level, hierachical: hierachical, depth: depth)
if current-heading != none {
if sty == none {
current-heading
} else {
sty(..setting-args, current-heading)
}
}
}
)
In this way, the current behavior is preserved, and one can easily use a custom sty
function.
For the "native" behavior one can simply set sty: it => it
or sty: none
.
I think it's a good idea, and I'll consider adding it in the next release.
I would like to be able to set a style for all heading, which if not explicitly modified in the theme is honored.
For example, I would like to set the style for all the headings, even if they are the title or the subtitle of the slide. In the following code, I would expect that
Title
,First Slide
and123
will be alwaysred
andsmallcaps
. Currently, only123
isred
andsmallcaps
Also adding this option in the
init
of theconfig-methods
doesn't work.