wikipendium / wikipendium.no

Compendiums edited as a wiki.
https://www.wikipendium.no
Apache License 2.0
36 stars 5 forks source link

Adding article-specific LaTeX macros #250

Open tOgg1 opened 10 years ago

tOgg1 commented 10 years ago

For some articles it would be great to have the possibility of creating local LaTeX macros. E.g. in the article TFY4165 right now there is a need for the inexact-differential symbol, which "needs" a macro to be defined, something along the lines of

\newcommand{\dbar}{\ensuremath{\mathchar'26\mkern-12mu d}}

(the example just to convince you this actually has use cases)

Also, could it be possible to import, in any way, a non-default package?

sigvef commented 10 years ago

\newcommand is already supported, but it must be declared while in math mode. Unfortunately, \mathchar is not supported right now. Currently, the best option for creating the inexact-differential symbol would be to do something like $ đ $.

Also, could it be possible to import, in any way, a non-default package?

Any extension (aka package) from https://github.com/leathrum/mathjax-ext-contrib should be technically possible to import. Other than these, importing packages is non-trivial.

tOgg1 commented 10 years ago

but it must be declared while in math mode.

So if I do $$ \newcommand{\dbar}{\ensuremath{\mathchar'26\mkern-12mu d}} $$ somewhere, \dbar would work?

sigvef commented 10 years ago

No, unfortunately, since \mathchar doesn't work on Wikipendium. Other \newcommands that don't use \mathchar work fine though. As an example, doing:

$ \newcommand{\bigO}[1]{\mathcal{O}\bigl(#1\bigr)} $
$ \bigO{n^2} $

yields:

image

tOgg1 commented 10 years ago

Ah yes, you said that already. Right.