The following is a compilation of several LaTeX rendering bugs I encountered while converting a textbook from LaTeX to Github Markdown. I will also list potential workarounds, provided I have any. Hopefully this document becomes and more normal as these bugs are fixed.
Sometimes the renderer doesn't render inline math mode LaTeX if there are more than one such modes used. This also causes a slight spacing issue and can also eat input in the same line.
If two inline math mode usages within the same line have no commands, such as:
If the second math mode contains a command, such as
To demonstrate how much gets eaten and how, here is how the two lines above look like if I combine them into one line.
If the second math mode contains a command, such as
The math command itself can be rendered be fixed by adding a space before the first offending math mode.
For example: $a $ and
In a given paragraph, it is not always straightforward to see which math modes have to be fixed. Take the following excerpt, which contains numerous inline math modes, but only some of them needed to be altered to display correctly, and curiously, the first fix needed was far from a command.
This can be seen by looking at
NOTE: It is not advisable to naively add spaces to the beginning and end of all inline math modes because of the next issue.
If there is a space at the end of an inline math mode, and there are any further characters, then content will not always render.
Two examples, each on their own line, are below:
$\mathbb{N} $ foo
$\cdot $ bar
where the expected outputs are
Either don't end inline math modes with spaces or have a newline after each inline math mode.
Inline math mode doesn't render if it contains a newline character.
It's easy to imagine long commands coming about when writing, but a small example is
Make sure there are no line-breaks in inline math commands.
NOTE: It is clear that if there is more than a single concurrent line-break, then the command should not render, as in normal LaTeX.
Two underscore characters in (even in seperate math modes!) can be interpreted as metacharacters in certain circumstances, such as when the underscores are surrounded by non-alphabetic characters.
A minimal example is: $a)0 b+$
Here, it is important that the bracket and the plus (the "bounding" characters) be non-alphabetic characters.
A more natural occurence, that shows that the underscore is italicizing things (and un-italicizing when it reaches the next compatible underscore), as well as how this can impact multiple math modes (even not on separate lines) is:
"If $(a_n){n\in\mathbb{N}}$ is convergent to $\lim{n\to\infty}s_n$, then we write..."
NOTE: This can even prevent rendering of a centered math mode, e.g. if a paragraph ended on one.
In certain cases, it might be possible to add a spaces, such as after the first underline. For example:
A period cannot follow inline math mode that ends in a period.
This was found with $n=0,1,2,...$. but even $n.$. is enough to prevent rendering.
Introduce a space before the period outside of the math mode.
This changes the output to
Centered math mode that contains a linebreak can fail to render if there is other math previously in the same paragraph.
Here is some arbitrary math:
We observe the same behaviour even if the previous math is centered math, but in the same paragraph:
One way around this is to not have line-breaks in centered math, but this can get very messy with e.g. matrices, tables, etc. A somewhat safer approach is to isolate all centered math modes, such that there is an empty line both before and after centered math mode.
Centered math can fail to render if there is any preceding text or symbols in the same paragraph, even if the math mode starts at the beginning of the next line in the paragraph.
Compare these two situations, which do not run Text $$\begin{array}{cc} 0 & 1 \end{array}$$
,.!?+- $$\begin{bmatrix} 0 & 1 \end{bmatrix}$$
with
and
Isolate centered math mode with empty lines before and after.
The summation operator, with limits, does not render correctly in a inline math mode.
If I write in LaTeX e.g. the sum from
It is possible to use the centered math mode to obtain a correct summation sign:
A backslash is not being correctly read when in inline math mode.
Here is an example using a literal curly bracket, which does not render correctly,
and if we imagine a larger example, where the author wanted to use the \left and \right functions, then it can prevent rendering altogether:
Here is another, where the hashtag symbol is not recognized
If the single backslash backslash is replaced by a double backslash, then the LaTeX renderer gets what it's supposed to get and the result is rendered.
If a letter appears directly after the "less than" operator, then rendering fails.
While if we replace
Adding a space direcly after the "less than" operator makes is render:
The asterisk character behaves oddly with the superscript operator.
While it will sometimes render correctly, such as: $$ t^{*} $$
if we place it in an environment whose name contains an asterisk, it does not render, seemingly as if the final asterisk was not there.
$$ \begin{align*} t^{} \end{align} $$
The issue can also arise if there is another asterisk, but not in an environment name. Here is a snippet from a large equation that necessitated being on two lines:
$$ t^_{1-\alpha,n+m-2} \ -t^_{1-\alpha,n+m-2}$$
Use "\ast" instead of the asterisk character, apart from when it is part of the name of an environment.
When in either inline or centered math mode, if there is an equals sign on its own line, then it is interpreted as a markdown meta-character.
Here are the results when using both inline and centered math modes:
ba$
ba$$
For the centered math mode, moving the final
The same is not true if the same is done with the inline version, which results in this:
but in that case it is possible to delete newlines until the correct result is obtained:
Certain envirornments don't expand to multiple lines properly unless the markdown itself also contains newlines as well.
Here is an example using inline math
$f(x,y) = \begin{cases} 2 & x \leq 1\ 0 & \text{otherwise} \end{cases}$
and even using centered math mode doesn't fix the issue:
If we manually add the rquired newlines, then we get:
Which works well in this case, but could be more akward if one wanted to make an inline sentence with e.g. vectors.