Giter Club home page Giter Club logo

notes.typ's Introduction

notes.typ

Footnotes, endnotes, notes.

example.png

See example.pdf for the example PDF.

Usage

Quickstart

The easiest way to use this library is to place the notes.typ file somewhere where you can import it, and do

#import "notes.typ": note, notes

at the top of your document.

Then, anywhere you want to place a note, do

- This is an *important* point #note[My note goes here]

// ...
// and where you want to render the notes:

#notes()

Footnotes

If you want to always collect notes at the bottom of the page, you simply call #notes in your footer:

#set page(
  footer: [
    This is my footer.

    #notes()
  ]
)

Custom note rendering

The notes function is a sane-defaults function for displaying notes at the bottom of a section / page. You probably want to define your own by creating a function that a calls render_notes.

You can use the notes function as a starting point:

#import "notes.typ": note, render_notes

// ...

#let notes(
  size: 8pt,
  font: "Roboto",
  line: line(length: 100%, stroke: 1pt + gray),
  padding: (top: 3mm),
  alignment: bottom,
  numberings: "1",
  group: note_default_group,
  reset: true,
  reset_counter: false
) = {
  let render(notes) = {
    if notes.len() > 0 {
      set align(alignment)
      block(breakable: false, pad(..padding, {
        if line != none { line }
        set text(size: size, font: font)
        for note in notes {
          [/ #text(font: "Roboto Mono")[[#numbering(numberings, note.index)]]: #note.text]
        }
      }))
    }
  }
  render_notes(group: group, reset: reset, reset_counter: reset_counter, render)
}

To customize the note marker, you can define your own note function with the display argument set as you prefer:

#let mynote = note.with(
  display: (note) => {
    super(text(weight: "bold", fill: orange, note.index))
  }
)

Advanced Usage

Reset note counter after each render of notes

#let mynotes = notes.with(reset_counter: true)

Two different note sets

If you want two different sets of note tracking states, you can define your own "group" name.

The typical use-case might be footnotes + endnotes.

#let footnote = note.with(group: "footnote")
#let show_footnotes = notes.with(group: "footnote")

#let endnote = note.with(group: "endnote")
#let show_endnotes = notes.with(group: "endnote")

And then use then as normal

- I want to add something at the bottom of the page #footnote[My Footnote]
- I want to add something to the end of the document #endnote[My Endnote]

And your page footer could be

#set page(footer: show_footnotes)

while at the bottom of your document you have a call to

#show_endnotes()

notes.typ's People

Contributors

tudborg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.