LudvigH
LudvigH

Reputation: 4763

How to produce \\ at end of line with kramdown?

I have a Jekyll site hosted on github pages. I have successfully loaded MathJax in my _layouts/default.html and now want to author my document. I have tried to set all cofiguration to default to not complicate matters.

The problem is that in some MathJax environments you want to write \\ to denote a newline (such as the align environment, but backslash is a special character in markdown. See example below.

Desired output

<p>\begin{align}
x&amp;=3+2\\
 &amp;=5
\end{align}</p>

Since one must escape backslash in markdown, I have writte the document below

Current input

\\begin{align}
x&=3+2\\\\
 &=5
\\end{align}

running kramdown myfile.md produces

Current output

<p>\begin{align}
x&amp;=3+2\<br />
 &amp;=5
\end{align}</p>

This is expected given the kramdown syntax for paragraphs.

How do I get kramdown to output \\ at the end of the row, instead of giving me a \<br />?

Upvotes: 0

Views: 143

Answers (1)

LudvigH
LudvigH

Reputation: 4763

kramdown has some support for MathJax, which i just found in the documentation. The easy way to do get it right is with input

$$
\begin{aligned}
x&=3+2\\
 &=5
\end{aligned}
$$

producing

\[\begin{aligned}
x&amp;=3+2\\
 &amp;=5
\end{aligned}\]

and that is for all intents and purposes the same as above. There are subtle semantic differences (one equation on two lines vs two equations), but it will look the same. So it is a valid solution to me.

Upvotes: 0

Related Questions