In my template, I have an outline that spans over two columns.
columns(2, outline())
With Typst 0.12, it is possible to span elements over multiple columns and I was wondering if this could be used to span the heading of the outline over both columns.
Particularly so that the entries on the top right column start at the same place as the ones on the right, as they are currently offset by the heading.
As seen here, I would like the chapter 9 entries to start at the place chapter 10 currently starts by spanning the heading across both colums
Remove the builtin outline title and write another title manually, like
#line(length: 50%, stroke: 2pt)
#text(size: 1.5em, "CONTENTS")
#columns(2, outline(title: none))
#set heading(numbering: "1.")
= ANN
= LLM
== Prompt Engineering
== Blah
== Blah
== Blah
While it doesn’t seem that the outline header is styleable (or at least I couldn’t find it), I did implement something inspired by @ParaN3xus solution
#heading(outlined: false, numbering: none, "Contents")
#columns(2, outline(title: none))
Depending on if you want this header to show up as a PDF bookmark, you can also add bookmarked: false
to the heading.
1 Like
With 0.12, we got the ability to add multi-column floats, and using set page(columns: ..)
is now the recommended way of styling things, even when there are page-spanning elements on the page – see e.g. Line numbering behavior and page layout - #2 by xkevio or this comment on a related Github issue.
This means that the question can now be cleanly answered like this (also demonstrating how to style the outline heading):
// this is only to make the outline's columns fill up
// more quickly, so that I need to generate fewer headings
#set page(paper: "a5", flipped: true)
#set page(columns: 2)
#set heading(numbering: "1.")
#place(top, float: true, scope: "parent")[
(you can even have stuff before the outline' heading,
just also `place()` it at the top before the outline)
]
#{
// this show rule is scoped to the outline, which means
// it only affects a single heading
show heading: it => {
set block(
stroke: (top: 2pt),
inset: (top: 0.4em),
width: 100%,
)
// THE IMPORTANT BIT: place the outline heading at
// the top of the page, spanning both columns
place(top, float: true, scope: "parent", upper(it))
}
outline()
}
#pagebreak()
// uncomment this if only the outline show be two-column
// #set page(columns: 1)
// some example content
#for section in lorem(5).split(" ") [
= #section
#for subsection in lorem(6).split(" ") [
== #subsection
#lorem(10)
]
]
2 Likes