Math equations with KaTeX

KaTeX{\KaTeX} is “the fastest math typesetting library for the web.”

Usage

To enable KaTeX in Papicu, add katex: true to a post or page’s front matter. Then, inside your Markdown content, add the desired expression between $$, like: $$ expression $$.

Examples

Here’s an example of a KaTeX expression displayed inline: h(x)=BeCxh(x) = B e^{C x}.

You can also give the formula more space to breath by leaving the expression (sidenote: In case you are curious, h(x)=BeCxh(x) = B e^{C x} is a definition of the Gompertz hazard function.) alone on a paragraph. KaTeX will automatically center it:

h(x)=BeCxh(x) = B e^{C x}
code snippet
Here's an example of a KaTeX expression displayed inline: $$h(x) = B e^{C x}$$.

[...] KaTeX will automatically center it:

$$h(x) = B e^{C x}$$

Here’s a more elaborate example, taking advantage of KaTeX’s environments:

a=b+c=e+f\begin{equation*} \begin{split} a &=b+c \\ &=e+f \end{split} \end{equation*}
code snippet
$$
\begin{equation*}
\begin{split}
a &=b+c \\ 
  &=e+f
\end{split}
\end{equation*}
$$

Overflow shouldn’t be an issue

What happens with our layout in case of a long KaTeX expression?

Let’s test it out:

a very very very very very very very very very very very very very very very long expression\text{a very very very very very very very very very very very very very very very long expression}
code snippet
$$ \text{a very very very very very very very very very very very very very very very long expression} $$

As you can see, Papicu limits the visible width of any KaTeX expression. And, if necessary, it automatically adds horizontal scrolling and a nice little tip.

Supported TeX functions

Check out KaTeX docs for the TeX functions they support. The list is available either sorted alphabetically or grouped by topic.

March 2022