This project aims to create a much lighter and more orthogonal syntax for mathematical writing on the computer instead of trying to replace LaTeX as a typesetting system, mathlang aims only to change they syntax.
Thus mathlang converts its own syntax to pure math latex code, allowing you to write in something readable and comfortable while always allowing you to change to a syntax understood by every math typesetting program wether it be Latex, Markdown, HTML, or other.
(Note: this will run only on Linux/MacOS/Unix (i.e. not windows))
You need the go language installed as well as git (this should already be installed on MacOS)
Open a terminal and run:
git clone https://github.com/neosapien3247/mathlang
cd mathlang
To test it out run:
make
To install run:
sudo make install
(Note: while testing, the binary has to be in the same directory as syntax_regexp.json
to find it)
Here you can see a few examples of what mathlang is capable of:
u^{->} : [{ i^{^}; j^{^}}]
\overrightarrow{u} : \left[\begin{matrix} \hat{i}\\ \hat{j}\end{matrix}\right]
RR^{_} = RR cup \{+- inf\}
\overline{\mathbb{R}} = \mathbb{R} \cup \{\pm \infty\}
sum_{k=0}^n ({n;k}) ( alpha/beta )^{n-k} ( gamma/delta )^k = ( alpha/beta + gamma/delta )^n
\sum_{k=0}^n \left(\begin{matrix}n\\k\end{matrix}\right) \left( \frac{\alpha}{\beta}
\right)^{n-k} \left( \frac{\gamma}{\delta} \right)^k =
\left( \frac{\alpha}{\beta} + \frac{\gamma}{\delta} \right)^n
A = ({a,b,c;d,e,f;g,h,i})
A = \left(\begin{matrix}a & b & c\\d & e & f\\g & h & i\end{matrix}\right)
This uses standard go libraries so it doesn't need particular dependencies, simply install go.
git clone https://github.com/neosapien3247/mathlang
cd mathlang
Then to build run:
make
and to install to /usr/local/bin
run
sudo make install
See the wiki for syntax
mathlang -e "expression"
This will output the "translation" of the expression into \LaTeX
... | mathlang -
This will output the STDIN
translated into \LaTeX
This can be very useful in certain editors for example, kakoune
by piping the content of a line and binding it, you can translate
mathlang to \LaTeX on the fly in one keystroke.
mathlang -d
This allows you to only convert what is between delimiters for mathlang code, thus allowing you to pipe an entire file into the converter and only change things between the delimiters. (the delimiters are $$)
This allows mathlang
to be used as a preprocessor, e.g:
mathlang -df "myfile.md" | pandoc -o myfile.pdf
Here are a few examples of the benefits of this system:
forall x in A, exists y in B
\forall x \in A, \exists y \in B
sin^2 theta + cos^2 theta = 1
\sin^2 \theta + \cos^2 \theta = 1
5/3 , 2 + {2 - 6t}/{3+8m}, {-3 + 5}/2c+6 a+b/c
\frac{5}{3} , 2 + \frac{2 - 6t}{3+8m}, \frac{-3 + 5}{2c+6} \frac{a+b}{c}
They even handle fractions of fractions:
varphi = 1 + 1/{1 + 1/{1 + 1/{1 + ...}}}
\varphi = 1 + \frac{1}{1 + \frac{1}{1 + \frac{1}{1 + \cdots}}}
Wether its vectors, conjugates, or hats, mathlang has better syntax!
a^{^}, b^{_}, c^{->}, d^{~}
\hat{a}, \overline{b}, \overrightarrow{c}, \tilde{d}
Parenthesis are already chosen to be the size-adjusting type, wether you need them or not:
(a+b)
\left(a+b\right)
Also note that this works for pipes |
but with specific rules:
- pipes that are surrounded by whitespace do not get changed and stay as
|
- if pipes are stuck only on one side to non whitespace they get changed
- if there is no whitespace the pipes will not be changed.
5 + |-3| = 8
5 + \left|-3\right| = 8
\{ x^2 | x in RR \}
\left\{ x^2 | x \in \mathbb{R} \right\}
forall n in NN^{*}, forall x in RR, x >= 1 => |x^n| >= x
\forall n \in \mathbb{N}^{*}, \forall x \in \mathbb{R}, x \ge 1 \implies |x^n| \ge x
RR^{_} = RR cup \{ +- inf\}
\overline{\mathbb{R}} = \mathbb{R} \cup \{ \pm \infty\}
A = (&{a,b,c;d,e,f;g,h,i})
A = \left(\begin{matrix} a & b & c \\ d & e & f \\ g & h & i \end{matrix}\right)
It can also be good for other formatting:
(a+b)^n = sum_{k=0}^n (&{n;k}) a^k b^{n-k}
\left(a+b\right)^n = \sum_{k=0}^n \left(\begin{matrix} n \\ k \end{matrix}\right) a^k b^{n-k}
@{ f : RR, -> RR; x, |-> x^2}
\begin{cases} f : \mathbb{R} & \to \mathbb{R} \\ x & \mapsto x^2 \end{cases}