atom-community / markdown-preview-plus

Markdown Preview + Community Features
https://atom.io/packages/markdown-preview-plus
Other
370 stars 84 forks source link

Support triangle of power in latex #484

Closed shaneing closed 4 years ago

shaneing commented 4 years ago

For example:

$$ \tripow{x}{a+b}{} = \tripow{x}{a}{} \cdot \tripow{x}{b}{} $$

Then, render it:

Screen Shot 2020-04-22 at 10 14 07 PM
lierdakil commented 4 years ago

AFAIK, this is non-standard LaTeX, so I'm not keen on hard-coding it directly, but we do support global user-defined macros.

See the docs for more information on macro definitions in MPP.

TL;DR: you might try to add something like this to your ~/.atom/markdown-preview-plus.cson:

dotriangle: [
  "\\hspace{-.2ex}{\\vcenter{#1\\kern.2ex\\hbox{$\\triangle$}\\kern.2ex}}",
  1]
tripow: ["
\\mathop{
 \\mathchoice
    {
       \\vphantom{\\dotriangle\\LARGE}
       \\rule[-1.4ex]{0.1em}{0pt}
       _{\\scriptstyle #1}
       {\\overset{\\scriptstyle #2}
       {\\dotriangle\\LARGE}}
       \\rule[-1.4ex]{0em}{0pt}
       _{\\scriptstyle #3}
       \\rule[0ex]{0.1em}{0pt}
     }
   {
       \\vphantom{\\dotriangle\\normalsize}
       \\rule[-1.05ex]{-0.7ex}{0pt}
       _{#1}
       \\overset{#2}
       {\\dotriangle\\normalsize}
       \\rule[-1.05ex]{0pt}{0pt}
       _{#3}
       \\rule[0ex]{-0.2em}{0pt}
     }
   {
       \\vphantom{\\dotriangle\\normalsize}
       \\rule[-1.05ex]{-0.8ex}{0pt}
       _{\\scriptstyle #1}
       {\\overset{\\scriptstyle #2}
       {\\dotriangle\\normalsize}}
       \\rule[-1.05ex]{0pt}{0pt}
       _{\\scriptstyle #3}
       \\rule[0ex]{-0.3em}{0pt}
    }
   {}
}
", 3]

(adapted slightly from https://tex.stackexchange.com/questions/307833/how-to-represent-the-triangle-of-power-in-latex)

shaneing commented 4 years ago

@lierdakil Awesome, thanks a lot!