LaTeX in PmWiki
Dec 31, 1969
I just finished creating a module for PmWiki for rendering latex commands. It makes use of PDF-LaTeX and ImageMagick utilities installed on the server to enable interpretation and rendering of LaTeX commands in PmWiki and display them as images. Also, the module makes use of a cache, thus avoiding the expensive task of re-rendering every time a LaTeX snippet is requested. CMS like Drupal (and I guess MediaWiki as well) already have similar modules. So now we also have it for PmWiki as well!
I have released the module under GNU-GPL.
You can download the latest release from here:
http://www.pmwiki.org/wiki/Cookbook/TrueLatex
Some demonstrations:
1.
Einstein said (:latex:)$R_{\mu \nu} - {1 \over 2}g_{\mu \nu}\,R + g_{\mu \nu} \Lambda = {8 \pi G \over c^4} T_{\mu \nu}$, where $R$ is the Ricci scalar(:latexend:). This is known as the "Einstein field equation".
Produces:
Einstein said . This is known as the "Einstein field equation".
2.
(:latex:) \begin{eqnarray} 10xy^2+15x^2y-5xy & = & 5\left(2xy^2+3x^2y-xy\right) \nonumber \\ & = & 5x\left(2y^2+3xy-y\right) \nonumber \\ & = & 5xy\left(2y+3x-1\right) \end{eqnarray} (:latexend:)
Produces:
3.
(:latex verbose=true:) \[ i\hbar\frac{\partial}{\partial t} \Psi(\mathbf{r},\,t) = -\frac{\hbar^2}{2m}\nabla^2 \Psi(\mathbf{r},\,t) + V(\mathbf{r})\Psi(\mathbf{r},\,t) \] (:latexend:)
Produces:
TrueLatex:
Using image file from cache. You may want to set ForceRender=true for debugging.
4.
(:latex displaycode+=true verbose=true forcerender=true paperwidth='5' ::eqncounter++:) \begin{equation} \prod_{n=2}^N\frac{n}{n-1} = N \end{equation} (:latexend:)
Produces: [:Example4 :]
\begin{equation}
\prod_{n=p}^N\frac{n}{n-1} = \frac{N}{p-1}
\end{equation}
TrueLatex:
Parsing LaTeX:
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
restricted \write18 enabled.
entering extended mode
(./temp-1.tex
LaTeX2e <2011/06/27>
Babel and hyphenation patterns for english, dumylang, nohyphenation, lo
aded.
(/usr/share/texlive/texmf-dist/tex/latex/base/report.cls
Document Class: report 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo
kpathsea: Running mktextfm cmr12
/usr/share/texlive/texmf/web2c/mktexnam: Could not map source abbreviation for cmr12.
/usr/share/texlive/texmf/web2c/mktexnam: Need to update ?
mktextfm: mktexdir ./.texlive2012/texmf-var/fonts/tfm/unknown/unknown failed.
kpathsea: Appending font creation commands to missfont.log.
! Font OT1/cmr/m/n/12=cmr12 at 12.0pt not loadable: Metric (TFM) file not found
.
relax
l.64 \normalsize
?
! Emergency stop.
relax
l.64 \normalsize
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on temp-1.log.
Extracting image:
convert: unable to open image `temp-1.pdf': No such file or directory @ error/blob.c/OpenBlob/2882.
convert: no images defined `92b512a7b663c1c925de8080a75e1ee2.png' @ error/convert.c/ConvertImageCommand/3235.
ERROR in extracting image!
[:/Example4:]
5.
(:latex DisplayCode+=true:)\[ f^{ (n) }(a) = {n! \over 2\pi i} \oint_\gamma {f(z) \over (z-a)^{n+1}}\, dz \](:latexend:)
Produces:
\[ f^{ (n) }(a) = {n! \over 2\pi i} \oint_\gamma {f(z) \over (z-a)^{n+1}}\, dz \]
6.
(:div style="background-color:#aaccff":) (:latex fontsize=Huge:) \[\left(\!\! \begin{array}{c} n \\ r \end{array} \!\!\right) = {^n}C_r = \frac{n!}{r!(n-r)!} \] (:latexend:) ... This formula is displayed on a non-white background. (:divend:)
Produces: