Universe

A package for marking and annotating in math blocks in Typst.

A full documentation is here.

Example

$
markul(p_i, tag: #<p>)
= markrect(
exp(- marktc(beta, tag: #<beta>) marktc(E_i, tag: #<E>, color: #green)),
tag: #<Boltzmann>, color: #blue,
) / mark(sum_j exp(- beta E_j), tag: #<Z>)

#annot(<p>, pos: left)[Probability of \ state $i$]
#annot(<beta>, pos: top + left, yshift: 2em)[Inverse temperature]
#annot(<E>, pos: top + right, yshift: 1em)[Energy]
#annot(<Boltzmann>, pos: top + left)[Boltzmann factor]
#annot(<Z>)[Partition function]
$

Example1

Usage

Import the package mannot on the top of your document:

#import "@preview/mannot:0.2.0": *

To define the target of an annotation within a math block, use the following marking functions:

  • mark: marks the content with highlighting;
  • markrect: marks the content with a rectangular box;
  • markul: marks the content with an underline;
  • marktc: marks the content and changes the text color.
$
  mark(x, tag: #<t1>) + markrect(2y, tag: #<t2>)
  + markul(z+1, tag: #<t3>) + marktc(C, tag: #<t4>)
$

Usage1

You can customize the marking color and other styles:

$
  mark(x, tag: #<t1>, color: #purple)
  + markrect(2y, tag: #<t2>, color: #red, padding: #.2em)
  + markul(z+1, tag: #<t3>, stroke: #.1em)
  + marktc(C, tag: #<t4>, color: #olive)
$

Usage2

You can also use marking functions solely for styling parts of a math block, without tags:

$
  mark(x^2 +, color: #blue, radius: #20%)
  f(markul(x^2 + 1, color: #red, stroke: #.1em))
$

Usage3

Once you have marked content with a tag, you can annotate it using the annot function within the same math block:

$
  mark(x, tag: #<t1>, color: #purple)
  + markrect(2y, tag: #<t2>, color: #red, padding: #.2em)
  + markul(z+1, tag: #<t3>, stroke: #.1em)
  + marktc(C, tag: #<t4>, color: #olive)

  #annot(<t1>)[annotation]
  #annot(<t4>)[another annotation]
$

Usage4

You can customize the position of the annotation and its vertical distance from the marked content, using the pos and yshift parameters of the annot function:

#v(3em)
$
  mark(x, tag: #<t1>, color: #purple)
  + markrect(2y, tag: #<t2>, color: #red, padding: #.2em)
  + markul(z+1, tag: #<t3>, stroke: #.1em)
  + marktc(C, tag: #<t4>, color: #olive)

  #annot(<t1>, pos: left)[Set pos \ to left.]
  #annot(<t2>, pos: top, yshift: 1em)[Set pos to top, and yshift to 1em.]
  #annot(<t3>, pos: right, yshift: 1em)[Set pos to right,\ and yshift to 1em.]
  #annot(<t4>, pos: top + left, yshift: 3em)[Set pos to top+left,\ and yshift to 3em.]
$
#v(2em)

Usage5

Changelogs

  • v0.2.0:
    • remove the mannot-init function;
    • support placing underlay under the math content when marking;
    • add marking functions: markrect, markul, marktc.
  • v0.1.0: first release.