Centering LaTex equations in Obsidian

Hello everyone,

i am new to Obsidian and I am trying to use Latex syntax in my notes. I have a strange issue since I was wondering why I am not able to have equations that are centered in the middle of the text…
Basically what I am used to do is typing the double $$ and then write the equations. For instance:
$$\cos{x}$$

But then the equation is written aligned on the left of the page …

Any similar issues ??

Thank you in advance,

Does that happen with the default theme? Some community themes, including Atom, left-align equations.

oh you are right : I use the atom theme… does it mean that I have to use the default theme to obtain a centered equations ?

Thank you again

I have the opposite problem. I use the basic Dark then Everforest theme.

1 Like

In fact, Atom is the only theme with this behavior as far as I know. So almost any theme other than Atom is likely to be fine.

And importantly, you don’t even have to give up Atom. You can customize/adjust a single part of a theme using CSS snippets.

In this case, create the following .css file under <root of your vault>/.obsidian/snippets and enable this snippet in the Appearance settings (see the link above for details).

mjx-container[display="true"] {
  text-align: center !important;
}
1 Like

Hello,

Thank you for your feedback : maybe you should try the option proposed by @ush by creating a .CSS file with specifying the position that you want.

It worked for me !
Tell me if it worked for you too,

Best regards

Thank you a lot @ush for your help : I followed your instructions and it worked for me. Sorry for such a newbie request : I am not familiar with obsidian yet !

Thank you again,

2 Likes

I updated the snippet because the older version targeted every math element regardless of its type (inline/display). Now it only styles display math (i.e. $$ ... $$).

Glad to hear it worked for you!

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