Heine Manual

This is the usage guide for Heine, a compact math notation that transpiles to LaTeX.

Contents

  1. Atoms
    1. Symbols
    2. Numbers
    3. LaTeX commands
    4. Text
    5. Separators
    6. Groups
    7. Delimited expressions
    8. Fractions and binomials
    9. Roots
    10. Matrices
    11. Cases
    12. Extensions
  2. Atom modifiers
  3. Superscripts and subscripts

Atoms

Atoms are the basis building block of Heine expressions. They come in many flavors.

Symbols

Symbols mainly represent letters and operators.

Latin letters stand for themselves.

ExampleOutput
M,a,t,h
M,a,t,hM,a,t,h

Greek letters are abbreviated by the first two letters of their English name. If a letter has two variants, add an asterisk to choose the other variant.

ExampleOutput
pi,Om,ep,ep*
π,Ω,ε,ϵ\pi,\Omega,\varepsilon,\epsilon

Common blackboard-bold letters can be produced by duplicating the letter.

ExampleOutput
NN,QQ,CC,PP
N,Q,C,P\mathbb{N},\mathbb{Q},\mathbb{C},\mathbb{P}

Other symbols each have their own code. Usually it's two or three characters long. A list will be provided in the future.

ExampleOutput
pd,+,<=>,s>=
,+,    ,\partial,+,\iff,\supe

To produce multiple consecutive symbols without any punctuation between them, use a space.

ExampleOutput
a + b + a b
a+b+aba+b+a b

Numbers

Numbers can be entered as-is, including negative numbers and numbers with a decimal point.

ExampleOutput
42,-1,6.28
42,1,6.28{42},{-1},{6.28}

A convenient shortcut can be used for exponential notation.

ExampleOutput
2.998e8
2.998×108{2.998\times10^{8}}

LaTeX commands

Would you like to use a LaTeX command for which Heine doesn't have a shorthand? No problem! Just enter it with the usual notation.

ExampleOutput
\ket{\omicron}
ο\ket{\omicron}

Text

To produce some regular text, simply surround it in quotes.

ExampleOutput
G " is a group"
G is a groupG\text{ is a group}

Separators

Commas and semicolons can be used as separators, without requiring any spaces. However, if they're followed by a space, they produce a longer space in the output.

ExampleOutput
x,y in RR, n in NN
x,yR,  nNx,y\in\mathbb{R},\;n\in\mathbb{N}

Groups

An expression can be grouped into a single atom using curly braces.
ExampleOutput
A_{i,j}
Ai,jA_{i,j}

Delimited expressions

An expression can be surrounded by various delimiters, which also turns it into a single atom. Note that curly braces have to be preceded by backslashes to distinguish them from a group; they can also be used to create a set comprehension. Unlike LaTeX, delimiters automatically adjust their size.

ExampleOutput
\{x.v | (/{p}{q} - 1) ||x.v|| > 1\}
{x|(pq1)x>1}{\left\{\vec{x}\,\middle|\,{\left(\frac{p}{q}-1\right)}{\left\Vert \vec{x}\right\Vert}>1\right\}}

Note that delimiters may not contain interior whitespace.

Fractions and binomials

A fraction or binomial coefficient consists of / or ncr, respectively, followed by two atoms without whitespace in front.

ExampleOutput
/1{n + k} * ncr{n}{k}
1n+k(nk)\frac1{n+k}\cdot\binom{n}{k}

Roots

A square root is produced with sq followed by one atom. A generic root uses rt followed by two atoms. Just like with fractions, there must not be whitespace in between.

ExampleOutput
sq{x} + rt3{y}
x+y3\sqrt{x}+\sqrt[3]{y}

Matrices

To create a simple matrix, use the word mt followed by the desired delimiters (or curly braces for no delimiters). Inside the delimiters, insert the contents of the matrix, with & to separate entries in a row and \\ to separate rows.

ExampleOutput
mt(cos(th) & sin(th) \\ - sin(th) & cos(th))
(cos(θ)sin(θ)sin(θ)cos(θ))\begin{pmatrix}\cos{\left(\theta\right)}&\sin{\left(\theta\right)}\\-\sin{\left(\theta\right)}&\cos{\left(\theta\right)}\end{pmatrix}

Cases

The notation cs{} can be used for case branching. Use \\ to separate cases and & to separate the condition from the result.

ExampleOutput
de_{i,j} := cs{1,& i = j \\ 0,& i /= j}
δi,j{1,i=j0,ij\delta_{i,j}\coloneqq\begin{cases}1,&i=j\\0,&i\ne j\end{cases}

Extensions

This feature allows passing arbitrary text to the code which is using Heine as a library, allowing it to add extend the capabilities of Heine. They're disabled by default.

Extensions are invoked by using a backslash followed by any content enclosed in square brackets. The content may contain square brackets too, as long as they're balanced.

In xidoc, this feature is used for executing xidoc commands inside Heine code.

ExampleOutput
pi ~~ \[js-eval Math.PI]
π3.141592653589793\pi\approx3.141592653589793

When using Heine as a library, extensions can be added by passing a function of type string -> string to Heine. This function is invoked for every extension usage in Heine code, getting the text including the square brackets as an argument. The return value of the function determines the generated LaTeX code. (Not Heine code! You can compose your function with another invocation of heine if that is the desired behavior.)

As an example, an extension which replaces the text with its length would be implemented like this:

# Subtracting 2 to account for the square brackets
let latex = heine(input, arg => $(arg.len - 2))

This could then be used like so:

ExampleOutput
\[*****] + \[**] = \[*******]
5+2=75+2=7

Atom modifiers

Atoms can have various modifiers added to them by using a dot followed by a single character. There can be multiple modifiers on a single atom.

ExampleOutput
x.v, C.c, A.b.L.i
x,  C,  A1\vec{x},\;\mathcal{C},\;{\overline{\mathbf{A}}^{-1}}

Superscripts and subscripts

A superscript and/or subscript can be added to an atom by using the ^ or _ character respectively. As a special case, an apostrophe can be used to add a superscript prime.

ExampleOutput
(a + b)^2, x_i^n, f''(x)
(a+b)2,  xin,  f(x){\left(a+b\right)}^2,\;x_i^n,\;f''{\left(x\right)}