How can I exclude page number for Heading 1 in outline list?

Another newbie question (from a retired, humanities person!). I have set up a template which does most of what I want, but I do wish to modify it in a couple of ways relating to the outline.

The first is this one: My 4 levels of headings are working as I want with only Headings 1 and 2 appearing in the outline. But what I would like in the outline is for only the text of Heading 1 to be shown, without the dots and the page number.

This is my current code for headings and outline:

#show heading.where(
  level: 1
): it => block(sticky: true, width: 100%)[
  #set align(center)
  #set text(24pt, weight: "regular")
  #smallcaps(it.body)
]

#show heading.where(level: 2): set text(20pt, weight: "semibold")

#show heading.where(level: 3): set text(16pt, weight: "semibold")

#show heading.where(level: 4): set text(14pt, weight: "semibold")

#outline(
  depth: 2,
  title: ([Contents]),
  target: heading.where(outlined: true),
  indent: 18pt,
)

#show outline.entry.where(
  level: 1
): it => {
  v(1em, weak: true)
  strong(it)
}
#show outline.entry.where(
  level: 2
): it => {
  v(0.3em, weak: true)
  strong(it)
}

which gives me:

when what I’d really like is:

How can I achieve this? (The latter I mocked up in a word processor hence the difference in font appearance etc. which can be ignored).

:slight_smile:
Mark

1 Like

Hi @Mark_Hilton,

If you have a look at Outline Function – Typst Documentation, you will find the hint on how to do it.

An adapted version of the example is:

#show outline.entry.where(level: 1): it => link(
  it.element.location(),
  // Keep just the body, dropping
  // the fill and the page.
  it.indented(it.prefix(), it.body()),
)

#outline()

= About ACME Corp.
== History

Which leads to the desired output:

1 Like

Hi @vmartel08, thank you very much for your input. This solves the issue.

To tell you the truth, the problem for someone like me, with a background in the humanities and no background in coding, is that it is sometimes difficult to work out how to achieve what one wants because the examples often seem somewhat impenetrable.

:slight_smile:
Mark

1 Like

@Mark_Hilton, please try and format your code blocks appropriately like mentioned in How to post in the Questions category :

2 Likes

Hi again Mark, that’s why there is a forum about it :blush:. Lots of it comes from reading around and trial and error. Please come back should you have more questions.

2 Likes

My apologies; I thought I had syntax-highlighted the code correctly, but I must have typed typst rather than typ.

As for “minimum code snippet”, I posted only what I thought would be necessary for others to see; clearly I was mistaken in my estimate, so again I apologise. I have much to learn!

:slight_smile:
Mark

typst and typ are identical. You can still edit your message and change that.

1 Like

Thanks, sorted. Turned out I had typed (typst) with parentheses!

<dohh!!>

:slight_smile:
Mark

2 Likes