Can I limit `#include`d document's outline to not contain outer document's headings?

Not sure if this is intended behavior but its confusing me;

I have a main document that has some headings and adds multiple appendices through #include "app.typ". However if any appendix includes an #outline, this outline is updated to contain all headings, even from other #include documents.

Is there any way I can scope the outline to just its own document?

It is intended behavior, but you can work around it. Outline has a target parameter, to which you can give a selector using before and after clauses:

#outline(
  target: selector(heading).before(<end-main-matter>)
)

= Section
#lorem(20)

== Subsection
#lorem(20)

#metadata(none)<end-main-matter>
#pagebreak()


= Appendix A

#metadata(none)<start-appendix-a>
#[
  #set heading(offset: 1)

  // the rest of this block would be in your include
  #outline(
    target: selector(heading)
      .after(<start-appendix-a>)
      .before(<end-appendix-a>)
  )

  = Section
  #lorem(20)
  
  == Subsection
  #lorem(20)
]
#metadata(none)<end-appendix-a>

I use set heading(offset: 1) so that the outline and all other headings in the appendix document automatically race contained within the “Appendix A” heading; you may want to do this differently though.

1 Like

You could also have a look at suboutline – Typst Universe

1 Like