How to set a hanging indent for footnotes?

I have found how to insert a footnote into a text, but can someone help me with the code needed to set footnotes with the number on the left margin and a hanging indent.

I insert footnotes like this:

[500 g], [Polish _kielbasa_ sausage#footnote[There are many types of _kielbasa_ sausage…], cut into 2 cm chunks],

which, on rendering looks like this:

When what I’d really like is (though retaining the superscripted number would be OK):

How do I achieve this, please?

I’m actually a bit surprised typst doesn’t offer this functionality directly. I think the best way to do what you are trying to achieve is to convert the footnote entry into a numbered list:

#show footnote.entry: it => {
  let loc = it.note.location()
  let val = counter(footnote).at(loc).first()
  enum(
    numbering: "1",
    body-indent: 1em,
    enum.item(val)[#it.note.body]
  )
}

The downside is that it’s affected by show/set rules on enum

Thanks a lot. That solves it for this text, which is non-academic; but I think I understand the problem with show/set rules on enum for future texts. I’ll wait to see if anyone else comes up with a solution that doesn’t involve enum; if I hear no more I’ll mark that as the solution.

:slight_smile:
Mark

There are several options to do something like that: You can use a grid as in

#show footnote.entry: it => {
  let nums = counter(footnote).at(it.note.location())
  let number = numbering(it.note.numbering, ..nums)
  let link = link.with(it.note.location())
  grid(columns: (auto, 1fr), gap: 1em, link(number), it.note.body)
}

or measure the width of the number and use it as the hanging ident (which is how it’s done for headings and outline entries)

#show footnote.entry: it => context {
  let gap = 1em
  let nums = counter(footnote).at(it.note.location())
  let number = numbering(it.note.numbering, ..nums)
  let width = measure(number).width + gap
  let link = link.with(it.note.location())
  par(hanging-indent: width, link(number) + h(gap) + it.note.body)
}

Depending on how you want it to look when there are multiple footnotes with different number widths, you can also use a grid with a fixed size for the first column, so that the footnotes are aligned with each other.

#show footnote.entry: it => {
  let gap = 1em
  let nums = counter(footnote).at(it.note.location())
  let number = numbering(it.note.numbering, ..nums)
  let link = link.with(it.note.location())
  grid(columns: (2em, 1fr), link(number), it.note.body)
}

Note that due to an issue, links to footnotes currently (as of v0.13.1) don’t work properly when using a show rule on footnote.entry.

1 Like

In spite of the issue you mention, the third of your suggested solutions will suit me fine for the foreseeable future, so thank you very much. I will mark my question as solved by you.

:slight_smile:
Mark