Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

MimeTeX

Summary: Add markup to display and embed mathematical formulas in wiki pages
Version: 2007-02-16
Prerequisites: pmwiki-2.0.0
Status: Stable
Maintainer: Pm
Categories: Markup Math
Votes:

Questions answered by this recipe

  • Can PmWiki be used to display mathematical formulas?

Solution

See also

Cookbook /
AMmathjax  Add markup to embed math using ASCII MATH by MathJax. (Stable)
ASCIIMath  Display MathML rendered ascii formula into PmWiki 2.x pages (Stable)
Formula  Lightweight rendering of mathematical formulas in wiki pages (Beta)
JsMath  Add markup to display and embed mathematical formulas in wiki pages using TeX. (Obsolete - use MathJax)
LaTeXMathML  Translating LaTeX math notation dynamically to Presentation MathML (Stable)
LinuxTex  Enable TeX markup
LuaExecute  Lets Lua scripts dynamically generate parts of your wiki page (Beta)
MathJax  Add markup to embed math using TeX syntax. (Stable)
Mathtex  Add markup to display and embed several lines of mathematical formulas in wiki pages (testing)
SageCell  This allows you to embed an interactive SageCell into your webpage. Sage is an open source alternative to MathLab, Mathematica, and Maple. (Stable)
SimpleJsMath  Notes on modifying the jsMath for a skin (not a complete recipe)
TrueLatex  Enables interpretation and rendering of real LaTeX markups in PmWiki. Support for XeLaTex included in v1.8. (Working perfectly. Very simple to use, customizable and comes with lots of options.)

Discussion

The mimeTeX utility from John Forkosh Associates, Inc., along with the mimetex.php script above, makes it easy to embed mathematical formulas in wiki pages using the LaTeX math expression syntax. Once installed, the markup {$ and $} can be used to embed a formula in a wiki page. For example, the markup

{$ x^2 + y^2 = z^2 $}

produces

x^2 + y^2 = z^2

More complex formulas can be generated--for example:

{$ e^x=\relstack{\rm lim}{n\rightar\infty}\(1+\frac xn\)^ $}

becomes

e^x=\relstack{\rm lim}{n\rightar\infty}\(1+\frac xn\)^n

See the full mimeTeX manual [forkosh.com] for more details.

Installation

To install MimeTeX, perform the following steps:

1. Download and install the mimeTeX package from http://www.forkosh.com/mimetex.html. You can use the installation instructions given in the README file included with the mimeTeX package; on pmichaud.com we simply unzipped the archive into a mimetex/ directory and executed the command

    cc -DAA mimetex.c gifsave.c -lm -o mimetex.cgi

(you can download the compiled version for linux directly on : [(approve links) edit diff] )

2. Place the mimetex-vc.phpΔ script in your cookbook/ subdirectory and rename it mimetex.php)

3. If you want to have PmWiki simply use MimeTeX as an external CGI script and do no caching of its own, you can place the following lines in your local/config.php (change the URL for mimetex.cgi as necessary):

    $MimetexUrl = '/cgi-bin/mimetex.cgi';
    include_once('cookbook/mimetex.php');

4. If you want PmWiki to call MimeTeX directly and cache the resulting images, then create a directory called pub/cache for the images and give the webserver write permissions to this subdirectory. (On Unix systems this is typically done via the command mkdir pub/cache; chmod 777 pub/cache;.) Then add the following to your local/config.php:

    $MimetexCmd = '/filesystem/path/to/mimetex.cgi';
    include_once('cookbook/mimetex.php');

That should do it! Whenever mimetex.php encounters the {$ ... $} markup, it automatically generates a call to mimetex.cgi and displays the resulting image. If PmWiki is being used to cache the images, then the images are kept in pub/cache/ to avoid regenerating them on future page accesses. A WikiAdministrator can delete the image files in pub/cache/ at any time and MimeTeX will automatically regenerate them as needed.

MimeTeX itself now has an optional built-in cachine mechanism, which is enabled by compiling mimetex.cgi with the -DCACHEPATH=\"path/\" switch (where path/ is a directory relative to mimetex.cgi where images will be cached. This can be used in conjunction with #3 above and still provide caching.

5. If you have a wikifarm installed, you need an extra $FarmD in mimetex.php.

    --- mimetex.php.orig
    +++ mimetex.php
    -SDV($ImgCacheDir,"pub/cache");
    +SDV($ImgCacheDir,"$FarmD/pub/cache");

Also add $FarmD in config.php

    include_once('$FarmD/cookbook/mimetex.php');

Contributors

\bold \hspace{20} \atop{\raise{-11}{\fs3\swarr} \compose{\circle(140,30)}{\rm Have a nice day!}}{\vspace1}

  

MimeTeX Sandbox

{$$ f_X(x_1, \dots, x_N) = \frac

 {1}
 {(2\pi)^{N/2} \left|\Sigma\right|^{1/2}}

\exp \left(

 -\frac{1}{2}
 ( x - \mu)^\top \Sigma^{-1} (x - \mu)

\right)$$}

Feel free to use the space below to test various mimeTeX formula markups. x^2 + y^3 = z^4


\begin{eqnarray} 1&=&1\\2&=&2\end{eqnarry}

{$\array{CCC$\Large f=b_\0+\frac{a_\1}{b_\1+\frac{a_2}{b_2+\frac{a_3}{b_3+a_4}}} & \hspace{10} {\small\rm{Notes and\atop mimeTeX Sandbox}} \hspace{10} } \Large \scrJ^{ij}=\frac12\vareps_{ijk}\[\array{cc$\sig_k&0\\0&\sig_k}\] $



\array{CCC$\Large f=b_\0+\frac{a_\1}{b_\1+\frac{a_2}{b_2+\frac{a_3}{b_3+a_4}}} &   \hspace{10} {\small\rm{Notes and\atop mimeTeX Sandbox}} \hspace{10} }   \Large \scrJ^{ij}=\frac12\vareps_{ijk}\[\array{cc$\sig_k&0\\0&\sig_k}\]


\large \Bigint\limits_^{-1$\infty} e^{-x^2} dx\ =\ \frac{\sqrt\pi}2

\frac{-b\pm\sqrt{b^2-4ac}}{2a}

1+\frac{1+\frac{1+\frac{a}{b}}{c}}{d}

e^{i \pi}-1=-2, e^{i\pi}+1=0

sqrt{n} A\veeB


\Large\Bigint_{} e^x = \LARGE f \Large(u_n)

S = S_{0} e^{\frac{-TE}{T_{2}^{*}}}


X \oplus S = \left\{ x+y | x \in X, y \in S \right\}


\frac{number\ of\ favorable\  outcomes}{total\ number\ of\ possible\ outcomes} = \frac{m}{n}

\frac{\sqrt{2}}{\sqrt{2}}

\mathbb{R}^n


\Large \mathbf{F} = - \left( \frac{\partial U}{\partial x} \hat{\mathbf{i}} + \frac{\partial U}{\partial y}\hat{\mathbf{j}} + \frac{\partial U}{\partial z}\hat{\mathbf{k}} \right) = - \nabla U


a \in \mathbb{N} \wedge b \in \mathbb{N}


\frac{\sqrt{250}}{\sqrt{120}}


\Psi=\frac{CO_2}{CaCO_3}


\int_0^1 \sin(x) \mb dx


This is some text wrapped around \int_0^1 \sin(x) \mb dx the formula to see how it behaves.

\nabla \cdot B = 0

e^{i\pi}+1=0


Some examples used from another Wiki:

\frac{3}{4 \pi}   \sqrt{4 \cdot x^2   12} \lim_{n \to \infty} \sum_{k=1}^n \frac{1}{k^2} = \frac{\pi^2}{6} \it{f}(x) = \frac{1}{\sqrt{x} x^2} e^{i \pi} + 1 = 0}\;


\Sigma^0_n \Sigma^{1,Y}_k


Some weird examples... probably a bug. Only one of the formulas below should produce f(x)=x^2...

* {$                    -\bar a_{c 3} \cos \Phi \sin \rho $}
* {$- \bar a $}
* {$ f(x)=x^3 $}
* {$- a $}
* {$\bar a $}
  • -\bar a_{c 3} \cos \Phi \sin \rho
  • - \bar a
  • f(x)=x^3
  • - a
  • \bar a

Ben: I found a similar bug. If you insert \. (which does nothing) at the beginning of each of these, then MimeTeX formats the image correctly. I would guess it is a bug with MimeTeX. Typing the following should work:

* {$\.                    -\bar a_{c 3} \cos \Phi \sin \rho $}
* {$\.- \bar a $}
* {$\. f(x)=x^2 $}
* {$\.- a $}
* {$\.\bar a $}
  • \.                    -\bar a_{c 3} \cos \Phi \sin \rho
  • \.- \bar a
  • \. f(x)=x^2
  • \.- a
  • \.\bar a

Comments: When you want to include mathematics on the same line as text, the alignment is rather ugly. You can simplify this by changing line 46
 return "<img class='mimetex' src='$ImgCacheUrl/$imgname' alt='".

to

  return "<img ALIGN='absMIDDLE' class='mimetex' src='$ImgCacheUrl/$imgname' alt='".

This causes the images to be centered with the center line of the text. It works in IE and Firefox. It still is not perfect at displaying all images, but I think it looks a lot better.

Other options for aligning are available (see http://www.w3.org/MarkUp/Test/Img/imgtest.html). I think the absmiddle does the best job.


* {$                     -\bar a_{c 3} \cos \Phi \sin \rho $}
* {$ - \bar a $}
* {$  f(x)=x^2 $}
* {$ - a $}
* {$ \bar a $}
  • -\bar a_{c 3} \cos \Phi \sin \rho
  • - \bar a
  • f(x)=x^2
  • - a
  • \bar a

I'm trying to make this work but I keep getting the error message: Warning: Cannot modify header information - headers already sent by (output started at /home6/jcarter/public_html/pmwiki/cookbook/mimetex.php:4) in /home6/jcarter/public_html/pmwiki/pmwiki.php on line 871.

any suggestions???

Try re-downloading the mimetex.phpΔ script. I suspect there may have been extraneous characters at the end of the file. If that doesn't help, try emailing me (pmichaud [snail] pobox [period] com).

\pm\frac{1}{2} That worked! thanks!


I'm looking for markup that I can use for text that will allow me to place alternative strings directly above and below eachother (without using preformatted text). For example, with preformatted text, the result would be like this:

       (ago)
A: (e) ache moyuba

Using frac (and avoiding Q&A):

A: (e) \frac(ago){ache} moyuba

Using large and frac:

A: (e) \Large\frac(ago){ache} moyuba

Using large and relstack:

\Large A:\ (e)\ \relstack(ago){ache} moyuba

Using \\:

A: (e) \Large (ago)\\ache moyuba

 ------

\frac{1}{\sqrt{1}+\frac{1}{\sqrt{2}+\frac{1}{\sqrt{3}+\frac{1}{\sqrt{4}+...}}}}


\huge x = \frac { y z } { 3 ^ r }

f:x\rightarrow y


i'm wondering if and how can this plugin works under windows iis..


Folks can't get it to work config.php has

 $MimetexUrl = '/cgi-bin/mimetex.cgi';
    include_once('cookbook/mimetex.php');

"cgi-bin" is a subdirectory in the "pmwiki-2.1.26" directory. mimetex.cgi is there, still it shows only the typed symbols, not the one I want to display.

Thanks for suggestion <<<<<<<

mw <math>\sqrt{1-e^2}</math> ltx \sqrt{1-e^2} =======

<math>\sqrt{1-e^2}</math> >>>>>>>

\int_0^1 \cos(x) \mb dx

\int\x \mb dx


http://meta.wikimedia.org/wiki/Help:Formula

ax^2 + bx + c = 0

ax^2 + bx + c = 0\,\!

x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}

2 = \left( \frac{\left(3-x\right) \times 2}{3-x} \right)

{$S_{new} = S_{old} - \frac{ \left( 5-T \right) ^2} {2}*}

\int_a^x \int_a^s f(y)\,dy\,ds = \int_a^x f(y)(x-y)\,dy

\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n} {3^m\left(m\,3^n+n\,3^m\right)}

u'' + p(x)u' + q(x)u=f(x),\quad x>a

|\bar{z}| = |z|, |(\bar{z})^n| = |z|^n, \arg(z^n) = n \arg(z)

\lim_{z\rightarrow z_0} f(z)=f(z_0)

\phi_n(\kappa) = \frac{1}{4\pi^2\kappa^2} \int_0^\infty \frac{\sin(\kappa R)}{\kappa R} \frac{\partial}{\partial R} \left[R^2\frac{\partial D_n(R)}{\partial R}\right]\,dR

\phi_n(\kappa) = 0.033C_n^2\kappa^{-11/3},\quad \frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}

f(x) = \begin{cases} 1 & -1 \le x < 0 \\ \frac{1}{2} & x = 0 \\ 1 - x^2 & \mbox{otherwise} \end{cases}

{}_pF_q(a_1,...,a_p;c_1,...,c_q;z) = \sum_{n=0}^\infty \frac{(a_1)_n\cdot\cdot\cdot(a_p)_n}{(c_1)_n\cdot\cdot\cdot(c_q)_n} \frac{z^n}{n!}

\frac{1}{2}


sqrt{x^2+y^2 = z^2}

\sqrt{1-e^2}


\left\| \mu - \alpha \right\|^2

\bar{\partial_A} \phi = 0


\left(\begin{array}{c}N_b \\ n_{a,s}\end{array}\right)^{-1} \,\, \left(\begin{array}{c}n_{b,s}\\ k\end{array}\right) \,\, \left(\begin{array}{c}N_b-n_{b,s} \\ n_{a,s}-k\end{array}\right)\,abcd


27-Feb-2007

mimetex.phpΔ attachment seems to be corrupted. Can it be restored please ??

Attachement problem

24-Jul-2007
mimetex.phpΔ attachment seems to be corrupted. Can it be restored please ??

18-Nov-2007
try to copy content of mimetex-vc.phpΔ to your mimetex.php. It works

User notes +2: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on May 17, 2014, at 08:56 AM