How to add sidenotes in the margin?

Now that we have footnotes. Anyone attempted to have this in the margin instead of the footer?

Welcome @oameye! I’ve updated your post’s title to suit our question post guidelines: How to post in the Questions category

Make sure your post title is a question you’d ask to a friend about Typst. :wink:


This isn’t built-in yet, but you can try this package: drafting – Typst Universe

This is not what you are asking but I have implemented once Tufte style sidenotes

#let spacing = 0.65em

#set page(
  paper: "a4",
  margin: (x: 3.5cm, y: 2.5cm),
)

#set heading(numbering: "1.")

#let margin-note(body) = {
  place(
    left,
    dx: -25%,  // Adjusted to keep the note within the page boundary
    block(
      width: 20%,  // Reduced width to fit within the margin space
      align(
        right,
        text(
          size: 0.8em,
          body
        )
      )
    )
  )
}

= Introduction

#margin-note[
  This is a margin note that appears alongside the main text.
  It can contain multiple lines and even formatting.
]

This is a sample document demonstrating bibliography settings in Typst. Here's a citation to something @test2024 and another reference @test1999.

Some additional text here to show the spacing...

= Conclusion

The bibliography will appear below with custom spacing and styling.

#bibliography("bibliography.bib")

I also was able to “fake” footnote numbering (but be vary, notes overlap and this is only an dirty hack) ; maybe someon can add footnotes numbering into the body of text

#let spacing = 0.65em

#set page(
  paper: "a4",
  margin: (x: 3.5cm, y: 2.5cm),
)

#set heading(numbering: "1.")

// Define a global counter variable
#let sidenote-counter = 0

// Define a function for the margin note with a counter
#let margin-note(body) = {
  // Increment the counter
  let sidenote-counter = sidenote-counter + 1
  // Place the margin note with a superscripted counter
  place(
    left,
    dx: -25%,  // Keep it within the page
    block(
      width: 20%,  // Width adjusted to fit within margin
      align(
        right,
        text(
          size: 0.8em,
          // Display the counter as a superscript using baseline adjustment

              weight: "medium",
              super(str(sidenote-counter)) +  " " + body
        )
      )
    )
  )
  // Return the superscript counter to be displayed inline
  //super(str(sidenote-counter))
}

= Introduction

#margin-note[
  This is the first margin note with a counter.
]


This is a sample document demonstrating bibliography settings in Typst. Here's a citation to something @test2024 and another reference @test1999.
#margin-note[
  This is the second margin note, which should display an incremented counter.
]

Some additional text here to show the spacing...

= Conclusion

The bibliography will appear below with custom spacing and styling.