How to use different text in outline and actual heading?

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.

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()
  ),
)

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

@flokl You are a genius. :man_bowing:

The second part with the linebreak fix was the solution I searched for.

1 Like

I believe this might be a simpler (and more correct) solution:

#show outline.entry: it => {
  show linebreak: [ ]
  it
}

#outline()

= Abc\ Def

2 Likes

Agree, this solution works also and it looks much simpler.