Showing Latex commands with different color

Hi! I’m using Obsidian with Pandoc to generate PDF documents. To accomplish this, sometimes I need to insert some Latex codes inside the Markdown text. Like this:


I would like to know if it’s possible to create a custom CSS in order to Obsidian show latex commands with a different text color to be easier to identify along the normal Markdown text.

I searched the internet for a solution, for weeks now, and doesn’t find anything, so I even don’t know where to start.

Try installing the Dynamic Highlights plugin, it can with the correct configuration highlight your latex commands in edit mode (not in reading mode).

See the following to get you started:

1 Like

Solved! Working like a charm! Thank you so much :slight_smile:

A snippet would also do the work. I haven’t gone into too much detail but I also use Latex in different color with this CSS selector. Works.

.math { 
	line-height: 0px; 
	font-size: 20px;

A snippet would only work if there were some targets to connect to. With only the latex commands in mid text, that’s not the case as they’re just pure text in the markdown context.

See the linked thread for more context.

Sure but isn’t that always the case?

Obsidian renders LaTeX inside $$ blocks with Mathjax and appends the .math class to the div. So you can modify the look. Can you elaborate a bit more on what you are saying?

If you’re doing math, that would indeed be the case, but the OP is adding LaTeX commands into the markdown text, for use when exporting markdown to pandoc. See wording in the original question, and the non-math LaTeX commands.

1 Like

Ah okay understood. Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.