LaTeX Plugin

Name LaTeX Plugin
Vendor Stepstone Technologies Inc. (Website)
Authors
Homepage http://confluence.atlassian.com/display/CONFEXT/LaTeX+Plugin
Issue Management n/a
Categories Content Macros
Version 1.2.1
Availability Confluence v2.0 to v2.10-m1
State Stable
Support Unsupported Plugins
License Freeware / Open Source (BSD)
Price Free
Release Docs http://confluence.atlassian.com/display/CONFEXT/LaTeX+Plugin
Java API Docs n/a
Download Source https://svn.atlassian.com/svn/public/contrib/confluence/latex-plugin
Download JAR latex-plugin-1.2.1.jar
This plug-in can be installed and updated via the Confluence Repository Client. However, see the instructions below for adding the necessary configuration files and installing TeX before using the LaTeX plug-in.

Description/Features

A plug-in for displaying LaTeX in Confluence. (Requires TeX to be installed separately.)

Prerequisites

  1. You must have a working version of TeX installed on your Confluence server, and
  2. The commands latex and dvipng must be reachable by the $PATH system environment variable.

Both latex and divpng are included in many TeX distributions.

It's a great idea to test your environment before installing the LaTeX plug-in. Make sure you generate a PNG file from a valid latex file at the command line. For instance, download simple.tex and type the following:

latex simple.tex
dvipng simple.dvi

This should generate a file named simple.png containing a familiar equation:

If not, you'll need to troubleshoot your TeX installation before continuing. Try http://www.tug.org/tetex/ and http://sourceforge.net/projects/dvipng/ for more information. (Mac OS X users might prefer the handy MacTeX installation, but be warned that you'll need to add the appropriate /usr/local/teTeX/bin/ subdirectory to your $PATH. And the TeX Users Group recommends the proTeXt package for installing LaTeX on Windows.)

Finally, if you peeked at the simple.tex file contents, don't be discouraged by its complexity. The LaTeX plug-in simplifies the code you'll need to add to your wiki markup.

Windows Users Take Note

Some users have had difficulty getting dvipng to work. In response to this problem, James Matheson has graciously contributed a mimetex-based version of the plug-in. Thanks, James! Note that to use the mimetex version, you will need to ensure that you have a copy of mimetex.exe in the system path. You can find a copy of mimetex.exe in the Mimetex download package at http://www.forkosh.com/mimetex.exe/windows/mimetex.zip

Installation

Once you've tested your TeX installation as above, follow these steps to install the LaTeX plug-in. (Note that CONFLUENCE_HOME_DIR should be replaced with the directory specified in your confluence-init.properties file).

  1. Install the latex-plugin-1.2.1.jar using the Confluence Plug-in Manager or the Confluence Repository Client.
  2. Create a directory called CONFLUENCE_HOME_DIR/latex and copy the following files into it:

Usage

Do not use the 'Rich Text' editor to write LaTeX markup. The rich text editor escapes some of the LaTeX characters, generating unpredictable output.

In your wiki markup, use the parameter-free {latex} macro to wrap your LaTeX code. For example, to generate the same equation you saw in the simple.tex test above, your wiki markup would look like:

{latex}
\( E=mc^{2} \)
{latex}

which would cause the following to appear in your Confluence page:

You'll notice that the wiki markup is much simpler than the test example. See the Configuration section below to learn why.

Here is a more complicated example.

Configuration

The properties files you installed in your CONFLUENCE_HOME_DIR/latex directory allow the simplification of LaTeX commands in your wiki markup. This is because the latexheader.tex and latexfooter.tex files specify LaTeX commands that are prepended and appended, respectively, to your wiki markup commands.

Also, the latex.properties file includes parameters to send to dvipng to further tailor the image generated.

You won't need to edit these files to use the LaTeX plug-in, although the LaTeX Jedi (you'll know if you are one) won't be able to resist tweaking these files.

Please do not specify an output file for the dvipng paramaters in latex.properties, as this disables the LaTeX macro!

Logging

To turn logging on, add the following text to CONFLUENCE_INSTALL_DIR/confluence/WEB-INF/classes/log4j.properties (replace CONFLUENCE_INSTALL_DIR with your actual installation directory):

####
# LaTeX debug messages
####
log4j.logger.com.stepstonetech.confluence.plugins.latex=DEBUG,confluencelog
log4j.additivity.com.stepstonetech.confluence.plugins.latex=false

This will print all LaTeX debugging messages to your atlassian-confluence.log file.

To turn logging off, change the word DEBUG to ERROR.

Compatibility

We've successfully used the LaTeX plug-in in Linux and Mac OS X environments with:

  • tetex version 3.0
  • dvipng versions 1.6 & 1.8
  • ava 1.5.0
  • Confluence 2.2.4, 2.2.5, and 2.2.9

Version History

Version Description
latex-plugin-1.2.1.jar Fixes a minor file-cleanup bug
latex-plugin-1.2.jar Public release of the LaTeX Plug-in

Tips & Tricks

If you would like to reuse Latex statements several times on a page, or across multiple pages, you may like to start a Latex statement library. Create a page specifically for storing statements and add a child page for each statement. Then use the Include Page macro to embed those statement pages wherever they are needed.

Labels

plugin plugin Delete
macro macro Delete
latex latex Delete
math math Delete
equations equations Delete
maths maths Delete
mathematics mathematics Delete
markup markup Delete
content content Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Feb 15, 2007

    James Matheson says:

    Has anyone installed this on a Windows server? And if so, how did they do it?

    Has anyone installed this on a Windows server? And if so, how did they do it?

    1. Feb 15, 2007

      Darryl Duke says:

      The TeX Users Group

      The TeX Users Group recommends the proTeXt for installing LaTeX on Windows.

    2. Mar 01, 2007

      Dirk Ringe says:

      We just successfully installed the plugin on a windows server 2003 utilizing mik...

      We just successfully installed the plugin on a windows server 2003 utilizing miktex. It runs fine so far but we have two issues:

      • dvipng on windows hangs when started from a service (tomcat) when it needs to update the font cache. Logging into the server and running the latex script manually updates the font cache and then the glyphs can be used from the plugin. Annoying.
      • Rendering the page seems to need much time (several seconds). We run this on a powerful server so that irritates me. Is there a chance for the plugin to cache the rendered images for faster delivery?
      1. Mar 27, 2007

        Matt Jones says:

        Has anyone found a solution to the first bullet point here? I'm having the exact...

        Has anyone found a solution to the first bullet point here? I'm having the exact same issue and it's a show stopping bug for us. I've played around with the permissions of the temp directories and it didn't help at all.

        1. Aug 03, 2007

          Bert Pluymers says:

          I think I found a workaround for the first problem mentioned above. After some ...

          I think I found a workaround for the first problem mentioned above.

          After some investigations I found that dvipng does not produce correct png files when encountering new symbols. If you run dvipng again it seems to do things right.

          To work around this problem I created a simple .exe file in VB that runs dvipng twice. I trick confluence in using this new .exe file by renaming the original dvipng.exe to _dvipng.exe and naming this VB application dvipng.exe

          The downside is of course that the conversion takes somewhat longer.

          I use confluence 2.5.4 and miktex 2.6, which includes dvipng 1.9.

          1. Feb 07, 2008

            Darryl Duke says:

            Please see the "Windows Users Take Note" section above. James Matheson has kindl...

            Please see the "Windows Users Take Note" section above. James Matheson has kindly contributed a mimetex version of the plug-in to get around problems with dvipng on Windows. Thanks, James!

            1. May 19

              Ian Pottier says:

              Hi, If you run confluence as a service under another account than "LocalSystem" ...

              Hi,

              If you run confluence as a service under another account than "LocalSystem" then dvipng does not hang. I believe that this problem comes from the environment which is inherited from confluence (and not explicitely set when spawning the dvipng process). Does someone have any idea of which (missing) part of the environment could make dvipng hang?

              mimetex plugin works otherwise fine, but is not quite as good looking in the rendering...

              BR 

            2. Jun 03

              Jamie says:

              I have MikTex 2.7 installed and working on a Confluence 2.7.3 server (runni...

              I have MikTex 2.7 installed and working on a Confluence 2.7.3 server (running Windows and Websphere 6.1). This was installed because proText was recommended for Windows and it has you install MikTex. I can run the samples above from the command line and they work correctly.  Then, I installed the Latex plugin and it did not work - the page hangs when I try to view any page using the latex macro. 

              I saw the note to Windows users above and installed the Mimetex plugin (in addition to the Latex plugin, although I've tried removing it also and no difference).  I can run mimetex.exe successfully from the command line.  I put mimetex.exe into the Java bin folder on the server and made sure that the folder is in the system PATH variable.  Still... the pages with latex macros hang and will not display.

              Can anyone tell me what I might be missing to get this plugin to work in Windows?

              Thanks, Jamie

  2. Feb 15, 2007

    Carter M. Snowden says:

    Thanks. Installed on our test server (running v. 2.2/Linux/Tomcat ) and it looks...

    Thanks. Installed on our test server (running v. 2.2/Linux/Tomcat ) and it looks good.
    This has been a much requested feature at our institution.
     

  3. Feb 19, 2007

    David Aldrich says:

    To display math equations, we have used MimeTex (

    To display math equations, we have used MimeTex (http://www.forkosh.com/mimetex.html) as a CGI on our server. Does the LateX plugin use a same approach?

    Can the equations be exported to HTML/PDF?

    It would be nice if your example worked live rather than show a png.

    1. Feb 19, 2007

      Darryl Duke says:

      I believe there are two main differences between mimeTeX and this plugin. (1) Fr...

      I believe there are two main differences between mimeTeX and this plug-in. (1) From their site: "mimeTeX is an entirely separate little program that doesn't use TeX or its fonts in any way." It's a single cgi installation, which simplifies the install a bit. The downside is that it's not the official or full TeX implementation. (2) To display equations with mimeTeX, you need to write something like: <img src="/cgi-bin/mimetex.cgi?x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}"> in the HTML, which would require someone to write a macro to generate it.

      As for exporting LaTeX Plug-in equations, the following are supported: (1) exporting space as PDF, and (2) when printing a screen using the browser's print page. (It doesn't currently export equations when exporting space as HTML.)

      Perhaps the folks at Confluence would consider installing LaTeX and this plug-in to support live examples here. I'll try to find time this week to set up a demo space on the stepstonetech.com site.

      1. Feb 20, 2007

        David Ruddock says:

        The confluence bug that prevents image plugins from exporting to .doc or .html i...

        The confluence bug that prevents image plugins from exporting to .doc or .html is tracked here:
        [CONF-7601] - Macro plugins which produce images are not able to export to .doc or .html formats
        Please vote for it to be fixed.

        1. May 27

          Don Willis says:

          That bug is now fixed.

          That bug is now fixed.

  4. Mar 21, 2007

    Frederico Guth says:

    I have had a hard time trying to insall Latex Plugin in Windows environment unsu...

    I have had a hard time trying to insall Latex Plugin in Windows environment unsuccessfully .

    My Latex distribution is MikTex (I know there are a recommendation for ProTeX, but I already had MikTex installed and working).

    The problem seems to be in dvipng (version 1.8). When I try to convert simple.dvi to simple.png it generates a 1kb png 1 pixel squared (just a dot).  I had never have to use dvipng. Does anyone have a clue why? 

    1. Mar 22, 2007

      Frederico Guth says:

      I finally found another dvipng and it worked with windows.

      I finally found another dvipng and it worked with windows.

      1. Jun 28, 2007

        Egon Kuster says:

        I found that I needed to edit the {{latex.properties}} file to change the word '...

        I found that I needed to edit the latex.properties file to change the word 'transparent' to 'Transparent' (note capital T). This then seemed to fix the problem. Very weird.

        1. Aug 15, 2007

          Kjetil Frydenlund says:

          I find same thing pretty weird. In the test environment, I changed 'transparent'...

          I find same thing pretty weird. In the test environment, I changed 'transparent' to 'Transparent' and it worked out after some configuration. When I later copied the configuration files to production environment, I had to change back to 'transparent' without capital T to get it to work. I wonder why a change to the tolatex.properties file is needed?

  5. Mar 31, 2007

    Reinhard Simon says:

    This seems to be a very useful plugin. Is the source code available? The subvers...

    This seems to be a very useful plugin. Is the source code available? The subversion directory has only *.class files in the .jar file.

    Thanks,

    Reinhard

  6. Jun 28, 2007

    Egon Kuster says:

    quick bug. If the dvipng does not respond or the users cancels an operation then...

    quick bug. If the dvipng does not respond or the users cancels an operation then it will leave running dvipng processes running and therefore possibly consuming all the system resources. In addition the Confluence Home Temp directory becomes littered with temporary files.

  7. Jun 29, 2007

    Vipan Bahl says:

    Hi I installed the TEX live plugin as part of the prerequisite and when i test t...

    Hi

    I installed the TEX live plugin as part of the prerequisite and when i test this i get the dvipng not found error, i understand that this should be part of the texlive install but it does not look like unless i am wrong or missing out something.Can anyone help me with this .Also i downloaded the dvipng 1.9 tar file and get error trying to compile to get the binaries created , any help on either will be really helpfull to me in installing this and making use of latex plugin.

    Thanks

  8. Sep 11, 2007

    Michael Ogrinz says:

    No joy here, either. I've installed proTeXt, and verified the system path settin...

    No joy here, either. I've installed proTeXt, and verified the system path settings (I can run the above sample with no problems). But my pages still say they can't find latex. Restarting the server is no help. This is what I have in the logs:

    debugMsg Finished writing LaTeX markup to: LaTeX41494.tex
    debugMsg The tex file should be created and called: LaTeX41494tex
    debugMsg Creating a a new dvi file from the tex file using the command: latex
    debugMsg Running the process: latex
    debugMsg Using the arguments:
    debugMsg ... arg 1 = -interaction=batchmode
    debugMsg In working directory: D:\confluence\data\temp
    debugMsg Started cleaning up all generated files from the conversion process.
    debugMsg Removing generated file: LaTeX41494.tex
    debugMsg Finished cleaning up all generated files from the conversion process.
    debugMsg Unable to run latex. Please make sure latex is in the system PATH and can be run using the commandline.
    debugMsg CreateProcess: latex -interaction=batchmode D:\confluence\data\temp\LaTeX41494.tex error=2

    1. Sep 23, 2007

      Dirk Bethe says:

      Michael, The Latex file is generated and the plugin looks for lates.exe in your ...

      Michael,

      The Latex file is generated and the plugin looks for lates.exe in your PATH but doesn't find it. If the sample files work on the command line then your latex is installed for a user. You've probably updated a User PATH and not the the System PATH.

      Check that latex is in the System PATH and restart Tomcat

      1. Sep 24, 2007

        Michael Ogrinz says:

        Nope it's definitely on the system path (server restart didn't help). My users r...

        Nope - it's definitely on the system path (server restart didn't help). My users really want this - does anyone have any other ideas?

  9. Sep 24, 2007

    Chris Marshall says:

    Hi I've followed the directions and installed LaTeX and dvipng, tried the sampl...

    Hi -

    I've followed the directions and installed LaTeX and dvipng, tried the sample simple.tex example (all worked OK, except the output of the dvipng command was simple1.png, not simple.png) but it is nopt working when I use it:

    2007-09-24 15:49:59,954 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg Creating a a new png file from the dvi file using the command: dvipng
    2007-09-24 15:49:59,983 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg Running the process: dvipng
    2007-09-24 15:49:59,985 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg Using the arguments:
    2007-09-24 15:49:59,986 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg ... arg 1 = -T
    2007-09-24 15:49:59,988 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg ... arg 2 = tight
    2007-09-24 15:49:59,989 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg ... arg 3 = -bg
    2007-09-24 15:49:59,990 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg ... arg 4 = transparent
    2007-09-24 15:49:59,992 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg ... arg 5 = -o
    2007-09-24 15:49:59,993 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg ... arg 6 = /nfs/arbitrage/statarb/gsatrader/runtime/confluence-2.5.4/data/temp/LaTeX24226.png
    2007-09-24 15:49:59,994 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg In working directory: /nfs/arbitrage/statarb/gsatrader/runtime/confluence-2.5.4/data/temp
    2007-09-24 15:50:00,221 DEBUG [http-8087-Processor1] [confluence.plugins.latex.LatexMacro] debugMsg Process failed with exit code: 134

    Do you have any ideas about this?    

  10. Oct 14, 2007

    Tom Wilger says:

    Great plugin\!\! I was able to get it up on my linux system pretty fast. I put s...

    Great plugin!! I was able to get it up on my linux system pretty fast. I put some LaTeX code in on a page and it worked. I then logged out then logged back in, went to the page and things kind of hung. Eventually, I had to restart my confluence server. Unfortunately, when I went back to the page with my LaTeX code in it I got this:

     When I run latex or dvipng from the command line it works fine. Any thoughts?

  11. Oct 14, 2007

    Tom Wilger says:

    I turned on debugging and got this (see my problem above) 20071014 15:36:29,975 ...

    I turned on debugging and got this (see my problem above)

    2007-10-14 15:36:29,975 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg Finished writing LaTeX markup to: LaTeX44540.tex
    2007-10-14 15:36:29,976 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg The tex file should be created and called: LaTeX44540tex
    2007-10-14 15:36:29,978 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg Creating a a new dvi file from the tex file using the command: latex
    2007-10-14 15:36:29,979 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg Running the process: latex
    2007-10-14 15:36:29,981 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg Using the arguments:
    2007-10-14 15:36:29,982 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg ... arg 1 = -interaction=batchmode
    2007-10-14 15:36:29,984 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg In working directory: /opt/confluence/temp
    2007-10-14 15:36:30,018 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg Started cleaning up all generated files from the conversion process.
    2007-10-14 15:36:30,022 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg Removing generated file: LaTeX44540.tex
    2007-10-14 15:36:30,024 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg Finished cleaning up all generated files from the conversion process.
    2007-10-14 15:36:30,025 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg Unable to run latex. Please make sure latex is in the system PATH and can be run using the commandline.
    2007-10-14 15:36:30,027 DEBUG [TP-Processor3] [confluence.plugins.latex.LatexMacro] debugMsg java.io.IOException: Cannot allocate memory
     

  12. Oct 17, 2007

    River Tarnell says:

    i notice that this plugin allows any latex command, including ones like \input{}...

    i notice that this plugin allows any latex command, including ones like \input{}, which seems like a possible security issue... is there any way to disable that?

  13. Nov 21, 2007

    Tiffany Bartlett says:

    I'm using Confluence 2.6.0, and I'm getting weird spacing when I export LaTeX to...

    I'm using Confluence 2.6.0, and I'm getting weird spacing when I export LaTeX to PDF.  Any thoughts?

    Thanks! 

  14. Apr 30

    Jeff Tanner says:

    LaTeX: Fonts I am having problems with some LaTeX commands that deal with Fonts...

    LaTeX: Fonts

    I am having problems with some LaTeX commands that deal with Fonts

    This works:

    {latex}
    \Large\textsl{Hello}
    {latex}
    

    But these fail:

    Error in LaTeX formatting.

    This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) (format=latex 2008.4.11) 30 APR 2008 09:59
    entering extended mode
    %&-line parsing enabled.
    **/mnt/operations/backups/confluence/data-v251/temp/LaTeX23376.tex
    (/mnt/operations/backups/confluence/data-v251/temp/LaTeX23376.tex
    LaTeX2e <2005/12/01>

    {latex}
    \textcolor{red}{Hello}
    {latex}
    

    ! Undefined control sequence.
    l.13 \textcolor
    {red}
    {Hello}


    {latex}
    \usepackage{antiqua}
    \Large\textsl{Hello}
    {latex}
    

    ! LaTeX Error: Can be used only in preamble.
    l.13 \usepackage
    {antiqua}
    Your command was ignored.



    Ideas ???

  15. May 01

    Cliff Brown says:

    I am having trouble displaying large elements of LaTeX on my pages.&nbsp; Ater c...

    I am having trouble displaying large elements of LaTeX on my pages.  Ater comparing the image of my code rendered through an external LaTeX processor, to the code generated using this plugin, it appears that my rendered  LaTeX  takes up two pages and only the image of the second page is being displayed. Does anyone have suggestions as to why this would happen, and whether there is a solution to it.

    1. May 01

      Tiffany Bartlett says:

      The way the LaTeX plugin works is it turns the actual LaTeX output into a .png f...

      The way the LaTeX plugin works is it turns the actual LaTeX output into a .png file and inserts that into the page.  The maximum size of the image is about a page, so the easiest work around for this problem is to divide your page into two sections and wrap both in {latex}.

  16. Jun 20

    Fedor says:

    I'm trying to export a page with an inline latex expression. When I export to pd...

    I'm trying to export a page with an inline latex expression. When I export to pdf a new line is inserted after the rendered picture. Does anybody know how to avoid this?

    I have the following dvipng settings:
    dvipng.parameters=-T;tight;-bg;Transparent

  17. Jun 24

    Tiffany Bartlett says:

    Are there any plans now for changing this plugin so that the latex automatically...

    Are there any plans now for changing this plugin so that the latex automatically appears in exports to Word docs?  

    I raised a support ticket for this a while ago, and was told that the developers would need to fix this issue by reading this:  http://confluence.atlassian.com/pages/viewpage.action?pageId=107185152.

    Thanks! 

  18. Aug 01

    kubo44 says:

    How can i cache rendered images? I have more expressions on one page and it take...