How do I remove the bibliography from the outline?

I’m trying to build a sort of “template” for myself in which I want to load a bibliography, without necessarily showing it. I’m currently using this code snippet to determine, whether or not to show it:

context (
    if query(cite) == () [
      #hide(bibliography(
        "Typst/Literatur.yaml",
        style: "institute-of-electrical-and-electronics-engineers",
      ))
    ] else [
      #pagebreak()
      #bibliography(
        "Typst/Literatur.yaml",
        style: "institute-of-electrical-and-electronics-engineers",
      )
    ]
  )

As you can see, the bibliography file will be loaded, but remains hidden, while there are no citations.
The problem is, that it still shows up in the outline.

Is there a way to get rid of the outline entry?

1 Like

Hi, welcome to the forum!

You can set the title parameter to none.

2 Likes

Thank you! Now I feel kinda stupid, especially since I used the title parameter in at least two other snippets :grimacing:
Well, I hope this might help someone else, too!

1 Like

Please, read how to properly format the post body in
How to post in the Questions category, and edit it accordingly.

I read through the section and adjusted the code formatting and title accordingly. I hope this is what you meant, but a pointer to what specifically you dislike would be helpful nonetheless.

1 Like

Additionally, there is no reason to use content blocks instead of code ones, it even takes 3 more #. Create a dedicated section on dangers of using square brackets carelessly (multi-line) · Issue #6844 · typst/typst · GitHub

context if query(cite) == () {
  hide(bibliography(
    "Typst/Literatur.yaml",
    style: "institute-of-electrical-and-electronics-engineers",
    title: none,
  ))
} else {
  pagebreak()
  bibliography(
    "Typst/Literatur.yaml",
    style: "institute-of-electrical-and-electronics-engineers",
  )
}

Or without repetition:

let bib = bibliography.with(
  "Typst/Literatur.yaml",
  style: "institute-of-electrical-and-electronics-engineers",
)
context if query(cite) == () {
  hide(bib(title: none))
} else {
  pagebreak()
  bib()
}

Even shorter:

set bibliography(style: "ieee")
let file = "Typst/Literatur.yaml"
context if query(cite) == () {
  hide(bibliography(title: none, file))
} else {
  pagebreak()
  bibliography(file)
}

Since it’s the default style anyway:

let file = "Typst/Literatur.yaml"
context if query(cite) == () {
  hide(bibliography(title: none, file))
} else {
  pagebreak()
  bibliography(file)
}
2 Likes

To answer the question in the post title: You can avoid having the bibliography in the outline by doing

#show bibliography: set heading(outlined: false)

This way you can still have a title for the bibliography section. (The other solution of setting the title to none works fine for the specific use case though.)

2 Likes

Thanks for the detailed response! I opted to go with your second suggestion.

While looking through the “setup” or “template” part of my document, I’ve found 2 other places where I used [] instead of {} and changed those as well.
I’m guessing that using [] to provide a string to a property or variable is considered bad practice?

In my first response, I actually meant that a pointer to what part of my formatting was faulty would have been nice, but I guess I found the right mistakes :P

1 Like

Good.

I explained all the key points in details in the issue. One line markup snippet doesn’t have extra spaces created, therefore not bad. It’s the way for smart quotes, references etc.