alex01
March 3, 2025, 9:26pm
1
I have a text which want to have the heading in capital letters but the outline entry should be ins mixted (Normal) letters.
Thanks to @aarnent I have solved the first issue with the image How to add image on the margin to the left of a level 1 heading? - #3 by alex01
Now I have tried to understand and adopt the snipplet below but i’m to stupid to get it work.
As an alternative, you can fully customize the text that will be shown in the outline with the following code which is taken from the Typst Examples Book .
#let in-outline = state("in-outline", false)
#show outline: it => {
in-outline.update(true)
it
in-outline.update(false)
}
#let flex-caption(long, short) = context if in-outline.get() { short } else { long }
// And this is in the document.
#outline(title: [Figures], target: figure)
#figure(
rect(),
caption: flex-caption(
[This…
The heading text is with \ | linebreack()
.
My Ideas is to have something like the above, or maybe something simpler, which I don’t know.
= [My Heading in\ the Text,My headig in the outline]
I have tried to call trim()
for it
but that looks like impossible.
#show outline.entry: it => link(
it.element.location(),
it.indented(
it.prefix(),
// wrong!
str(it.body()).trim() + sym.space + box(width: 1fr, it.fill) + sym.space + sym.wj + it.page()
),
)
flokl
March 3, 2025, 10:58pm
2
I’m not quite sure I fully understand your questions, but let’s give it a try.
Now I have tried to understand and adopt the snipplet below but i’m to stupid to get it work.
Here is the code snippet adapted for headings.
Flex headings
#let in-outline = state("in-outline", false)
#show outline: it => {
in-outline.update(true)
it
in-outline.update(false)
}
#let flex-heading(long, short) = context if in-outline.get() { short } else { long }
#outline()
= #flex-heading[My Heading in\ the #linebreak() Text][My heading in the outline]
I have a text which want to have the heading in capital letters but the outline entry should be ins mixted (Normal) letters.
You can use #show heading: upper
which shows all headings with uppercase letter.
The heading text is with \ | linebreack()
.
Do you want to display these headings in the outline without line breaks? You could filter out all linebreak()
occurrences.
Filtered Outline Headings
#show outline.entry: it => {
let body = if it.body().has("children") {
it.body().children.filter(it => {it != linebreak()}).join()
} else {
it.body()
}
link(
it.element.location(),
it.indented(
it.prefix(),
body + sym.space + box(width: 1fr, it.fill) + sym.space + sym.wj + it.page()
)
)
}
#outline()
= My Heading in\ the #linebreak() Text
= Heading
1 Like
alex01
March 3, 2025, 11:12pm
3
@flokl You are a genius.
The second part with the linebreak fix was the solution I searched for.
1 Like
PgBiel
March 4, 2025, 12:40am
4
I believe this might be a simpler (and more correct) solution:
#show outline.entry: it => {
show linebreak: [ ]
it
}
#outline()
= Abc\ Def
2 Likes
alex01
March 4, 2025, 1:46am
5
Agree, this solution works also and it looks much simpler.