So, I back up my notes by pushing them to GitHub with the Git plugin. It has worked pretty well, but I have noticed issues with LaTeX rendering on GitHub vs. in Obsidian.
Specifically, there are a few cases I’ve found where the LaTeX DOES render in Obsidian but not in GitHub:
If a math block ($$) has text immediately above/below it in the markdown, with no extra line separating it.
If an inline math expression ($) is inside bold or italic indicators.
If a math block ($$) is used inline (not on its own line).
If spaces are between the dollar signs and the math content.
And sometimes, I’ll have an inline math expression with some character directly in front or behind it and it doesn’t render (ex: putting it in quotes). This was inconsistent, though, so I’m not sure.
I’m having a lot of trouble finding ways around these issues and I was wondering if any people who use Obsidian with LaTeX + GitHub experience similar rendering issues. Any ideas for how to deal with them other than just brute-force changing all instances of it by hand?
Also, I know the last two cases I mentioned are just bad LaTeX practice, so the first two are more important.
I don’t put math on GitHub specificallly, so this is general information.
using $$ inline
Nooo, don’t do it.
$$ doesn’t delimit a “math block”. It delimits displayed formulas.
You can use \displaystyle inside $ math to make it resemble $$ math. And \textstyle to do the reverse.
This produces some differences, especially when your math is tall, but this is the way.
mixing MathJax and markdown
Gentle mathwriter, mixing is doomed. Stick to one syntax.
Letters in MathJax have emphasis by default:
$I'm \; italic.$
You can use \text to remove italics:
$\text{I'm text that isn't mathy.}$
For bolding, there’s \boldsymbol.
$\boldsymbol{\phi}$
blank lines before and after displayed math
I don’t know what the standard is, but Obsidian renders math both with and without the blank lines. If you’re saying they are needed on GitHub, then go with that.
A replace-all or replace-in-all-files through another text editor could speed up the transition on notes you’ve already written.
space between $ and content
I would be surprised to see that work on any note-taking or writing-focused platform.
Lists of USD prices, notes about “$ 17.99 but on sale for $ 13.20”, and most lines with two or more dollar signs would turn into math.
The way to keep this consistent across platforms seems to be a simple: Don’t enter a space.
Oh yeah thanks for mentioning Obsidian linter. I just installed that and it helps a lot with some of the cases! One thing I wanted to ask about was my issue with math that is inside markdown bold/italic indicators. So, I would have:
_Some italic text with "$x=3$"_
**Bold with $\emptyset$, etc.**
This kind of stuff would render in Obsidian but GitHub would have trouble rendering it.
This kind of stuff would render in Obsidian but GitHub would have trouble rendering it.
How do you mean “render”? With the examples you gave, default Obsidian renders the math and the markdown text, but it doesn’t render your markdown formatting on the math.
Example shown in Source mode, Live Preview, and Reading:
So I assume you mean that for your examples, GitHub either doesn’t render the math at all, doesn’t render the markdown text, or doesn’t format the markdown text.
You can fix all those by separating your syntax (or simply not mixing them).