사용자 도구


LaTeX plugin

This plugin uses LaTeX+ImageMagick to render mathematical formulae embedded within a DokuWiki page. This gives a professional look to equations, and the syntax allows almost copy-paste conversion between DokuWiki and LaTeX manuscripts. For example, you may simply type $ a + b = c $ into your wiki code and it will automatically be shown as .1)

Installation

Follow the usual plugin installation instructions to download and install the plugin.

:!: External requirements: This plugin requires the following software to be installed on the server hosting your wiki. If you do not have root access, contact your administrator.2)

  • A copy of LaTeX (preferably a recent version of TeXlive), which inclues both latex and dvips binaries.
  • ImageMagick, which in turn requires…
  • Ghostscript

:!: This plugin will not work in PHP safe mode. - unless your server administrator has specifically allowed access to the software this plugin needs.

Systems

Variously out-dated but quite in-depth installation instructions can be found on E-razor's wiki. You might also consult the similar instructions for math in MediaWiki (but note that DokuWiki's plugin does not need texvc, OCaml, etc.). Here is a summary

  • Ubuntu/Debian (works: March 2011)
    apt-get install texlive-latex-base imagemagick ghostscript
  • CentOS 53)4)
    yum install tetex tetex-fonts tetex-dvips tetex-latex ghostscript ImageMagick
    fmtutil-sys --all
  • Fedora Core 3
    yum install tetex-latex ImageMagick
  • Archlinux
    pacman -S texlive-most texlive-lang

    to install latex, read the latex article in the archwiki for more options

  • Windows (confirmed to work on Windows 7 with DokuWiki on a Stick –Mark April 29 2011)
    • Download and install the plugin. For some reason, plugin manager has troubles doing automatic installation on my machine. No mattery, just unpack it manually.
    • You will need to download a LaTeX installation (MikTex works), and ImageMagick. You will also need ghostscript, but this may already be provided by MikTex or some other software you have (some feedback here, anybody?). AndrewC: I needed to install GhostScript independently, as it did not come bundled with MikTex.
    • Make sure that the LaTeX and ImageMagick binaries are in the PATH variable (and restart your webserver to absorb the change), or use the plugin's configuration to set the full paths – note that you will need quotes around filenames with spaces, such as “C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\latex”.
      • The ImageMagick path must be at the beginning of the PATH variable, since the convert binary has the same name as a Microsoft-supplied program.
    • Should be good to go; give it a try!
  • My own experience with Windows –AndrewC, 17 March 2012
    • Just thought I would share my own experiences with this plugin, perhaps save some headaches for anyone else with a similar setup.
    • My setup is: Windows 7 64-bit, Abyss Web Server X1, DokuWiki full local installation, PHP 5.3.10 (installed using Aprelium's preconfigured PHP5 package.)
    • I installed MikTex and ImageMagick, as Mark suggested above. I also needed to install GhostScript separately, as I mentioned it's not included with ImageMagick.
    • VERY IMPORTANT: I found out (the long way ;-)) that ImageMagick and GhostScript must both be 32- or 64-bit. You can't mix and match 32- and 64-bit installations.
    • I didn't have to add any of the paths to my environment variables; it's enough to just specify the full paths to the executables in the plugin configuration.
    • No extra configuration was required. Works like a charm!

Examples

$ a + b = c $

$ a + b = c $

<latex> I am \LaTeXe! </latex>

<latex> I am \LaTeXe! </latex>

\begin{eqnarray*}
& & \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\;
\end{eqnarray*}

\begin{eqnarray*} & & \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\; \end{eqnarray*}

from here

<latex>\setlength{\unitlength}{1mm}
\begin{picture}(93,46)
  \put( 0,14){\vector(1,0){60}} 
  \put(61,13){$x$}
  \put(20,4){\vector(0,1){37}} 
  \put(19,43){$y$}
  \put(50,34){\circle*{2}} 
  \put(52,35){$P$}
  \multiput(20,34)(4,0){8}{\line(1,0){2}} 
  \put(14.5,33.5){$y_P$}
  \multiput(50,14)(0,4){5}{\line(0,1){2}} 
  \put(48,11){$x_P$}
  \put( 2,8){\vector(3,1){56}} 
  \put(59,26.5){$x'$}
  \multiput(50,34)(1.9,-5.7){2}
    {\line(1,-3){1.2}}     
  \put(52,22){$x_P'$}
  \multiput(50,34)(-5.8,-1.933){6}
    {\line(-3,-1){3.6}} 
  \put(12,21){$y_P'$}
  \put(22,8){\vector(-1,3){10.5}} 
  \put(10,41){$y'$}
\end{picture}</latex>

<latex>\setlength{\unitlength}{1mm} \begin{picture}(93,46)

\put( 0,14){\vector(1,0){60}} 
\put(61,13){$x$}
\put(20,4){\vector(0,1){37}} 
\put(19,43){$y$}
\put(50,34){\circle*{2}} 
\put(52,35){$P$}
\multiput(20,34)(4,0){8}{\line(1,0){2}} 
\put(14.5,33.5){$y_P$}
\multiput(50,14)(0,4){5}{\line(0,1){2}} 
\put(48,11){$x_P$}
\put( 2,8){\vector(3,1){56}} 
\put(59,26.5){$x'$}
\multiput(50,34)(1.9,-5.7){2}
  {\line(1,-3){1.2}}     
\put(52,22){$x_P'$}
\multiput(50,34)(-5.8,-1.933){6}
  {\line(-3,-1){3.6}} 
\put(12,21){$y_P'$}
\put(22,8){\vector(-1,3){10.5}} 
\put(10,41){$y'$}

\end{picture}</latex>

Syntax

The following syntax is recognized by the LaTeX plugin at the moment. For the most part, the recognized syntax is inserted as-is into a small LaTeX template (which can be changed in the Configuration Manager), then compiled:

  • $…$ syntax is rendered in-line, just as in LaTeX
  • $$…$$ syntax is rendered on its own line, just as in LaTeX
  • \begin{displaymath}…\end{displaymath} syntax
  • \begin{eqnarray}…\end{eqnarray} syntax
  • \begin{eqnarray*}…\end{eqnarray*} syntax
  • \begin{equation}…\end{equation} syntax
  • \begin{equation*}…\end{equation*} syntax
  • Special: <latex>…</latex> syntax is rendered in-line in non-math-mode. This is useful to enter environments such as picture, etc.

Caveats

  • Although the numbered-equation styles are available, the numbers do not carry over between equations. You can hard code them by including a LaTeX command like \setcounter{equation}{5}, which will reset the equation counter to start at 5.
  • The symbol $ can no longer be used for currency, so use %%$%% instead in wiki text.

Configuration/Settings

From the Configuration Manager, you can modify the following settings:

  • Media namespace in which to store images (default is :wiki:latex).
  • Image type: default is png.
  • Maximum allowed image size.
  • Maximum allowed length of LaTeX code (sort of a security filter).
  • Paths to latex, dvips, convert, and identify programs.
  • Options to convert program, to control image size, transparency.
  • The LaTeX template used for each rendered block: add \usepackage{} statements here, change color, etc.

Admin plugin

There is an admin plugin included for ease in managing the LaTeX image cache, which can easily grow to thousands of equations in size. This can be accessed through the administration actions panel.

The admin plugin also allows you to troubleshoot problems in the rendering process.

Latex syntax in tables

Generally, latex does not work in a table. For example,

|  \begin{equation*} e=mc^2 \end{equation*}  |

results in:

\begin{equation*} e = mc^2 \end{equation*}
Strange, it works here!
-TT, 2013-02.28

Not rendering Latex Code

Plugin does not render any latex code in dokuwiki pages, displays only the text as if not recognizing the syntax. No images in corresponding image folder. With admin tool everything is working fine. Found no error messages or anything. Any hints?

Converting to PDF

There are a few plugins to convert the pages to pdf, for example:

https://www.dokuwiki.org/plugin:dw2pdf

Unfortunately I am not able to see the latex formulas in the pdf document. Anyone have any idea how to fix this or know of a dokuwiki to pdf convert that acutally works with this latex plugin?

An idea how to fix this (at least in Firefox, Linux of course):
add ?do=export_html to the address line of your Firefox and press Enter. Then use ctrl+p to start the print dialog. Choose print to file + pdf and voilla, there it is a pdf export with all latex parts.
-TT, 2013-02-28
1)
vertical alignment is a bit better in practice.
2)
or consider installing the simpler MimeTeX plugin which requires no external software