dokuwiki_latex [Mike Boyle's Web Site]
The Wiki Title SXS Home Page

LaTeX Plugin for DokuWiki

Inline Offset

The problem is that the basic plugin returns an image and just puts that right in line with the rest of the text. Of course, if—for instance—we have a subscript, the browser believes that the bottom of that subscript is the baseline. The effect is an expression which sticks up out of the line of text. For example, the equation $d/\left( 2 \ddot{a} \right) = d/ \left( 2 \Omega^2 \right)$ sticks up out of the line. We would hope that the bottoms of the letters would be at the baseline, rather than the bottoms of the parentheses.

Suppose we magically obtain the baseline offset; suppose that it is 4pt. If, in the image inclusion tag (in the HTML) we put the following:

style="vertical-align: -4pt;"

the image would look as though it were properly aligned. Thus, instead of this: $d/\left( 2 \ddot{a} \right) = d/ \left( 2 \Omega^2 \right)$, we would have something more like $d/\left( 2 \ddot{a} \right) = d/ \left( 2 \Omega^2 \right)$ that.

We can actually get the offset using a trick I stumbled across on this page. We need to rewrite the class.latexrender.php a little, but nothing too insanely complicated. I’ve modified the tex document found at that link slightly, and incorporated it with my own version of class.latexrender.php, arriving at the following code:
Code for class.latexrender_offset.php:reveal hidden content


Note that I want a text color which isn’t black. If you want black, just comment out those lines.

Now, there is no need to do the extra work for formulas which are displayed on their own. I have a separate syntax which calls it for inline formulas, then calls the original classlatexrender for formulas on their own lines. Here is my version of Alexander Krause’s latexrender plugin for the inline case:
Code for syntax/dollar.phpreveal hidden content

New Syntax

I use a lot of latex, as does the group I work in. I found that people (including, but not limited to me) didn’t want to use the latex plugin because they would have to enter something like <latex>\alpha</latex>, and would invariably forget the direction of that second slash.

To cure this problem, I extended the syntax used in the original plugin, so that people could enter math just like they do in a regular latex document. That is, by entering something like $E=mc^2$, the inline formula $E=mc^2$ would appear. Similarly, we can now enter things like

\begin{eqnarray*}
\Psi_0 &=& -C_{abcd} Y_0^a m^b Y_1^c m^d e^{-2i\gamma} \\
\Psi_4 &=& -C_{abcd} Y_1^a \bar{m}^b Y_1^c \bar{m}^d e^{2i\gamma}
\end{eqnarray*}

The result is the following formula:
\begin{eqnarray*}
\Psi_0 &=& -C_{abcd} Y_0^a m^b Y_1^c m^d e^{-2i\gamma} \\
\Psi_4 &=& -C_{abcd} Y_1^a \bar{m}^b Y_1^c \bar{m}^d e^{2i\gamma}
\end{eqnarray*}
just as it would appear in a latex document. The other environments—displaymath, equation, equation*, and eqnarray*—are also present.

Not only does this require less memory power because the syntax is the same, it also allows us to simply cut and paste from our notes when it comes time to move them over to actual latex documents.

To implement this, I’ve taken the original plugin—found in ‘lib/plugins/latex/’—and made a subdirectory syntax. I then moved the file syntax.php to syntax/latex.php, and added a bunch of new files of my own. Those files are the following:
dollar.phpreveal hidden content

displaymath.phpreveal hidden content

equation.phpreveal hidden content

equationstar.phpreveal hidden content

eqnarray.phpreveal hidden content