I am trying to test rendering of katex on my browser. It renders correctly, but when I try using \newline to signal a line break, it throws me an error:
ParseError: KaTeX parse error: Expected 'EOF', got '\newline' at position 45: …)-\tfrac{1}{2}x\̲n̲e̲w̲l̲i̲n̲e̲ \Righta…
<body>
<div class="maths">
\Rightarrow\quad F(x)-\tfrac{1}{2}x
\Rightarrow\quad F(x)-F(a)\leq\tfrac{1}{2}(x-a)[2ex]
</div>
<script>
// Get all <div class ="maths"> elements in the document
var x = document.getElementsByClassName('maths');
for (var i = 0; i < x.length; i++) {
try {
if (x[i].tagName == "DIV") {
t = katex.render(x[i].textContent, x[i], { displayMode: true });
} else {
t = katex.render(x[i].textContent, x[i]);
}
}
catch (err) {
x[i].style.color = 'red';
x[i].textContent = err;
}
}
</script>
How can I call for a newline in Katex since "\newline" doesn't work?
Use three backslashs instead of two.
I'm using markdown to publish blog with KaTeX. It works for me.
It renders: