wei2912 / obsidian-latex

MIT License
146 stars 21 forks source link

Cannot load LaTeX packages into preamble.sty #20

Closed DylanJVA closed 2 years ago

DylanJVA commented 2 years ago

I'm trying to use the physics package and i tried including this in the preamble.sty: \usepackage{physics} and I also tried this: \require{physics}, which was according to this obsidian forum post. The example you give does not show how to include some LaTeX package, it only shows how to define a macro. Unless thats not what this extensions can do, can you please explain how to use this extension to use an arbitrary LaTeX package?

xldenis commented 2 years ago

You cannot, Obsidian uses MathJax which while similar to latex is not latex.

Leedehai commented 1 year ago

Hi @xldenis it appears your answer contradicts with what you mentioned in https://forum.obsidian.md/t/new-plugin-mathjax-extended-preamble/10174 about using \require{physics}.

Wondering if I missed anything? Thanks 😊

Update: Oddly enough, with preamble.sty like this

% Enable MathJax's "physics" package, which partially implements the LaTeX
% package "physics".
\require{physics}

I am indeed able to use the physics package in Obsidian, e.g. the differentials and partial derivatives render perfectly for me:

\dd x, \dd[2]x, \pdv[2]{f}{x}, \pdv{}{x}{y}
Screenshot 2023-01-15 at 15 13 18
wei2912 commented 1 year ago

Update: Oddly enough, with preamble.sty like this

% Enable MathJax's "physics" package, which partially implements the LaTeX
% package "physics".
\require{physics}

I am indeed able to use the physics package in Obsidian, e.g. the differentials and partial derivatives render perfectly for me:

\dd x, \dd[2]x, \pdv[2]{f}{x}, \pdv{}{x}{y}
Screenshot 2023-01-15 at 15 13 18

Sflr, please see https://docs.mathjax.org/en/latest/input/tex/extensions/physics.html - you can load the physics package dynamically under MathJax but it might not correspond entirely to the LaTeX physics package (not sure what the exact differences are). Nevertheless I think it should work for most usecases.

DylanJVA commented 1 year ago

Hi @xldenis it appears your answer contradicts with what you mentioned in https://forum.obsidian.md/t/new-plugin-mathjax-extended-preamble/10174 about using \require{physics}.

Wondering if I missed anything? Thanks 😊

Update: Oddly enough, with preamble.sty like this

% Enable MathJax's "physics" package, which partially implements the LaTeX
% package "physics".
\require{physics}

I am indeed able to use the physics package in Obsidian, e.g. the differentials and partial derivatives render perfectly for me:

\dd x, \dd[2]x, \pdv[2]{f}{x}, \pdv{}{x}{y}
Screenshot 2023-01-15 at 15 13 18

Can confirm this works. Thank you! Not sure if it was added in the update...