#Outline: Using an alternative to caption
18 messages · Page 1 of 1 (latest)
Typst Example Book has a code snippet for this: https://sitandr.github.io/typst-examples-book/book/snippets/chapters/outlines.html?highlight=caption#long-and-short-captions-for-the-outline
Just stumbled upon this thread and decided to use this. It keeps showing the long caption on the outline for some reason. Trying to isolate the reason but afaik right now it seems to be unable to detect the outline context because of some kind of override in my template.
I don't get it. I tried it in a test project and there it seems to only work if I put the definitions directly in the file, not in an imported one. In the main project, it doesn't work in either case. ("Doesn't work" here always means "I get the long text in both the figure and the outline")
Does anyone know, even if in abstract, why this kind of thing could happen?
Btw @sacred spindle did it work for you?
remember, you cannot import the show rule on outline. import only imports functions and definitions so you can definitely put the flex-caption() function and in-outline in a different file
the show rule would have to be "imported" through the classical template function with .with approach
How so?
But, like, call a with() after import with no arguments?
that depends on your template
I assume you want me to do something like this in the template file:
#let flex-captions() = {
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 }
}
no, you can just put the definition of flex-caption() and in-outline somewhere in your template file. then, i assume, you have a general function that styles your document with set and show rules no? if yes, put the show outline in there. if not, then i would guess you have styled your document in your main file and you can just put the show outline in there or close to whereever you call outline
I have a file with a styling function that I call from main at the beginning, yes. Do you mean I should put the template code in there?
show outline: it => {
in-outline.update(true)
it
in-outline.update(false)
}
this part yea
the function and the state you can put wherever and import them
It worked, thanks!