Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Global/local latex macro definitions #84

Open
itsuhane opened this issue Nov 12, 2022 · 3 comments
Open

[FR] Global/local latex macro definitions #84

itsuhane opened this issue Nov 12, 2022 · 3 comments

Comments

@itsuhane
Copy link

Motivation

Currently, I define custom latex commands inside the first displayed equation block, for example:

$$
\newcommand{\diff}[2]{\frac{\mathrm{d}#1}{\mathrm{d}#2}}
\newcommand{\pardiff}[2]{\frac{\partial{}#1}{\partial{}#2}}
\newcommand{\ie}{\textit{i}.\textit{e}.}
\ie \diff{E}{u} = \pardiff{L}{u} - \diff{}{x}\pardiff{L}{u'} = 0
$$

The command definitions will be available in the current file (and in fact, leaking to the whole obsidian app once this block is rendered, which could be a security issue).

Feature Request

It would be helpful to support macro definitions, for example in the page's md preamble:

---
obsidian-latex-suite:
  latex-preamble: |
    \newcommand{\diff}[2]{\frac{\mathrm{d}#1}{\mathrm{d}#2}}
    \newcommand{\pardiff}[2]{\frac{\partial{}#1}{\partial{}#2}}
    \newcommand{\ie}{\textit{i}.\textit{e}.}
---

$$
\ie \diff{E}{u} = \pardiff{L}{u} - \diff{}{x}\pardiff{L}{u'} = 0 % the commands are available ONLY IN THIS FILE.
$$

Or setting them in some global config file so that all the files in the vault will benefit:

// .config/obsidian-latex-suite.conf.js
{
  // ...
  'latex-preamble': [
    '\newcommand{\diff}[2]{\frac{\mathrm{d}#1}{\mathrm{d}#2}}',
    '\newcommand{\pardiff}[2]{\frac{\partial{}#1}{\partial{}#2}}',
    '\newcommand{\ie}{\textit{i}.\textit{e}.}'
  ], // all the docs will be able to use these commands.
  // ...
}
@itsuhane
Copy link
Author

Follow up:
Extended LaTeX solved part of this issue.
And its looking for another maintainer. Maybe the two plugins can be merged?

@artisticat1
Copy link
Owner

The focus of this plugin is making typing LaTeX easier, as opposed to extending its functionality. Therefore, I think this functionality would belong better in the Extended MathJax plugin that you mentioned.

@cossio
Copy link

cossio commented Dec 7, 2022

The command definitions will be available in the current file (and in fact, leaking to the whole obsidian app once this block is rendered, which could be a security issue).

Maybe this can be brought up as an upstream issue in Obsidian?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants