Project

General

Profile

Actions

Feature #1994

open

LaTEX support in Wiki, Forums and Issues

Added by Murat Ozkan about 16 years ago. Updated over 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Wiki
Target version:
-
Start date:
2008-10-06
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

Latex support could be included especially in Wiki pages, so that Latex expressions could be displayed as images in Wiki. Specifically, I want to use Redmine Wiki as means of documentation tool for mathematical methods that are used within a multi-precision library. I could not find a way to display equations in Wiki (Textile does not support mathematical expressions as far as I know)


Files

init.rb (1.49 KB) init.rb Save as vendor/plugins/latex_math/init.rb to support LaTeX math (note-12) Ling Li, 2011-03-30 00:28
screenshot.png (8.49 KB) screenshot.png Mauro Calderara, 2011-12-07 16:03
Actions #1

Updated by Thomas Lecavelier about 16 years ago

A new point for a redmine made of modules: since only few users could have need of LaTeX in redmine, it would be marvelous that redmine admins has choice between different plugin to act as wiki.

Actions #2

Updated by Murat Ozkan about 16 years ago

That would work I think. Another option may be a plugin which enables LaTeX if such a thing is needed. (such as TracMathPlugin)

Actions #3

Updated by Luiz Carlos Junior about 16 years ago

I am also interested in this functionality. For the implementation of mathematical models, it is essential to have Math/LaTeX support in Wiki.

Actions #4

Updated by Anh Kỳ Huỳnh about 16 years ago

Luiz Carlos Junior wrote:

For the implementation of mathematical models, it is essential to have Math/LaTeX support in Wiki.

I agree.

For one who will write the plugin please look at jsMath. It's fun and simple

Actions #5

Updated by Michael Aye about 16 years ago

+1 for general use of Latex
+1 for choosability as a switch-on/switch-off plugin (but previous +1 is more important. hehe :)

Actions #6

Updated by Yingbo Miao over 15 years ago

+1 for Latex.

Actions #7

Updated by Carlos de la Torre about 15 years ago

+1 to LaTeX support.

I'm new to Redmine and I really need this kind of feature. I cannot have Nisrael's redmine-wiki_latex_plugin to work.

Anyone knows if there's an important update in this sense?

Actions #8

Updated by Paul paul almost 15 years ago

+1 for Latex.

Actions #9

Updated by Andrzej Giniewicz almost 15 years ago

Anh Kỳ Huỳnh wrote:

Luiz Carlos Junior wrote:

For the implementation of mathematical models, it is essential to have Math/LaTeX support in Wiki.

I agree.

For one who will write the plugin please look at jsMath. It's fun and simple

I also think that jsMath is way to go!

Actions #10

Updated by Brian Schimmel over 14 years ago

There already seems to be a redmine plugin which implements this, see http://www.redmine.org/boards/3/topics/4987

I did not test it yet, but wanted to report it now in case I forget to do so after testing.

Actions #11

Updated by Peter Lawrence about 14 years ago

Regarding note 10. I've developed a plugin using jsmath and mathjax see http://github.com/PeterLawrence/redmine_jsequation_macros
Even thought this renders equations well in wiki pages and issues, it does not function for preview, pdf or atom feeds. It's only really a solution for when you have problems installing the latex plugin, for example on a windows based system.

Actions #12

Updated by Ling Li over 13 years ago

I like Peter's plugin that uses MathJax (note-11). With MathJax, the displayed equations are beautiful and scalable. I also made changes regarding points raised in note-1 and note-2.

The new plugin (attached as a single file) defines a macro that enables the LaTeX math support via MathJax on a page-by-page basis. For example,

{{EnableLaTeXMath}}
This is a math equation: \[  x_{1,2} = \frac{-b \pm \sqrt{b^2-4ac}}{2a} \]
The first line enables math on the page; after that one is free to write LaTeX equations.

Compared to the suggestions in note-10 and note-11, I think this
  • is simpler to use (no {{latex(...)}} or {{mathjax(...)}} every time an equation is needed),
  • doesn't have problems with line breaks or curly brackets in the equations, and
  • naturally supports both inline-style and display-style equations.

And I believe it works for preview too.

Actions #13

Updated by Phil Rutschman over 13 years ago

I successfully used Ling Li's plugin. While it does correctly working during preview the first time, subsequent previews do not. This appears to be because MathJax's onload handler is only invoked during initial configuration. Subsequent previews are running within the same DOM, and MathJax does not reconfigure itself.

I was able to work around this by explicitly enqueuing a typeset operation from within the script to dynamically load MathJax. This operation will fail (silently) in the usual case that MathJax is being loaded for the first time. There may well be a more elegant way to handle this, but it seems to work.

--- vendor/plugins/latex_math/init.rb    2011-04-11 00:48:43.000000000 -0700
+++ vendor/plugins/latex_math_preview_hack/init.rb    2011-04-11 00:48:29.000000000 -0700
@@ -48,6 +48,7 @@
                else {script.text = config}

   document.getElementsByTagName(\"head\")[0].appendChild(script);
+  try { MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]); } catch (err) {};
 })();
 //]]>
 </script>" 
Actions #14

Updated by Marton Danoczy over 13 years ago

I tried Ling's plugin with Phil's patch and it works absolutely great, thanks! What about packaging it up, publishing it on http://www.redmine.org/plugins and closing this ticket?

Actions #15

Updated by Marton Danoczy over 13 years ago

Btw, is it possible to enable MathJax by default in every page, i.e. without having to type {{EnableLaTeXMath}} each time?

Actions #16

Updated by Michael Boratko about 13 years ago

I have created a simple plugin which enabled MathJax for all pages (without typing {{EnableLaTeXMath}}) and also works on previews.

https://github.com/process91/redmine_latex_mathjax

It is admittedly fairly crude in the way that it updates previews; essentially there is a jQuery function which watches the preview div for changes and makes a call to MathJax when it is changed. The inclusion of jQuery could be avoided, I'm only using it for this one purpose, but the bigger performance hit (though it's really theoretical, I don't notice any actual decrease in performance) is that jQuery has to poll repeatedly for changes to the preview box.

Notes about the plugin / things you can modify:
  • I wanted the default LaTeX modifiers, so $ and $$ represent inline and display code respectively. You can change this, along with any other configuration options by editing the file within the hooks/redmine_latex_mathjax/ folder.
  • If you don't care about LaTeX in the previews and want to avoid loading jQuery and having the constant polling, simply remove the last three javascript tags from the file within the hooks/redmine_latex_mathjax/ folder.
Actions #17

Updated by Michael Boratko about 13 years ago

I forgot to mention, this plugin also styles text in the subject line of issues, comments of commits, basically any text on the whole site. The dollar signs are actually convenient for this, as they are not used frequently otherwise. If you do want to enter a dollar sign explicitly, you can always escape it by putting a backslash before it, but even this is not needed unless two dollar signs appear on the same line.

I really would like to remove the jQuery, however. If anyone knows of a hook that I am unaware of which allows you to modify the text which appears in the body of an issue, I would be able to strip out the jQuery and this plugin (for all uses I can think of anyway) would be complete.

Actions #18

Updated by Mauro Calderara about 13 years ago

The code seems to work in the preview but not after saving a wiki page. For some reason backslashes get quoted using another backslash, so '\sum' is turned into '\\sum' when saving the page. Any hints on why that is or what needs to be changed in order to avoid it?

Actions #19

Updated by Michael Boratko about 13 years ago

Mauro - Was this using the code from my Git repo? What other plugins do you have installed, if any? As you can see below, it is working:

Actions #20

Updated by Michael Boratko about 13 years ago

Whoops, here's the screenshot:

Actions #21

Updated by Mauro Calderara about 13 years ago

Michael - yes, the code used is a fresh clone from your git repo. Other plugins installed are:

  • stuff_to_do_plugin
  • timesheet_plugin
  • redmine_tab

I uploaded a screenshot here. The markup used for this is:

$\sum x_i$

In the preview it is show correctly but whenever I save it, it looks like on the screenshot. I suspect something to escape the '\' when clicking save since when editing the page again the markup saved seems to be

$\\sum x_i$
Actions #22

Updated by Michael Boratko about 13 years ago

That is interesting. When I get a chance, I will install those plugins and see if I get the same result. What version of Redmine are you using?

If you could also test some other things for me, I would appreciate it. Try writing the markup described here:

$\int$

\sum x_i

(on the second one I have intentionally not wrapped it in dollar signs)

As you can see here, the wiki itself does not normally automatically escape backslashes, so I would be interested to see what your wiki does by default. If you could even uninstall my plugin and try writing $\sum x_i$ to see if the backslash is escaped, that would be most helpful.

As a workaround (though I would really like to fix this entirely) you can try wrapping the entire thing within < notextile >< /notextile > tags (without the spaces of course).

Actions #23

Updated by Mauro Calderara about 13 years ago

Where should I look to see what these plugins do with respect to the formatting of the wiki/textile input? Here's what testing revealed:

  • The markup
    $\int$
    is again saved as
    $\\int$
    even though it displays correctly in the preview.
  • With
    \sum x_i
    (without the enclosing dollar sign) it also gets stored as
    \\sum x_i
  • The same happens with the notextile tags

The version of redmine installed here is 1.2 stable as of this morning, i.e. r8108

It seems that for some reason my wiki really just puts a '\' in front of every '\\' while the normal wiki doesn't do so (as one can see here). I just wonder what causes this. google didn't reveal anything so far, so I'll try asking in IRC.

Actions #24

Updated by Mauro Calderara about 13 years ago

Michael, after having been unsuccessful on IRC I continued playing around with the plugin and got it fixed. One reason for the phenomenon might have been that I used an old postgres-connector gem. I also uninstalled and reinstalled your plugin, now everything seems to work fine. Alas I can't tell whether it was the database connector or the reinstall but I suspect the database connector to have been the cuplrit.

Either way, for me things seem to work now. Thanks a lot for writing the plugin!

Actions #25

Updated by Michael Boratko about 13 years ago

Mauro, glad to hear that it works now. I also suspect the postgres-connector gem, especially since the backslash was escaped even outside the confines of the dollar signs, and escaping backslashes would not be out of the question with regard to a database connector. Good luck to you!

Actions #26

Updated by Luiz Carlos Junior about 13 years ago

Plugin installed and running perfectly.
Thanks for this very nice plugin, Michael Boratko.

Actions #27

Updated by Carsten Koenig over 12 years ago

Have installed Michael Boratkos plugin. Worked fine, but hat to add a try-catch to line 52 to make preview work:

File: view_layouts_base_html_head_hook.rb
in plugins/redmine_latex_mathjax/lib/redmine_latex_mathjax/hooks/

Line 52:
-                $('#preview').contentChange(function() { MathJax.Hub.Typeset(); } );
+                $('#preview').contentChange(function() { try { MathJax.Hub.Typeset(); } catch (err) {}} );

Now it works fine. Thanks for the plugin, Michael.

Actions #28

Updated by Michael Boratko over 12 years ago

Thanks for the updated code, Carsten. I have applied your changes to the repo.

Actions #29

Updated by Billy T over 12 years ago

Michael Boratko wrote:

Thanks for the updated code, Carsten. I have applied your changes to the repo.

Is this plugin working on 2.x?

Actions #30

Updated by Michael Boratko over 12 years ago

Billy T wrote:

Is this plugin working on 2.x?

Unfortunately I don't have the time to test it out. I imagine it would be, but I don't have a 2.x setup right now. Perhaps you could try it and let us know?

Actions #31

Updated by hannes wader about 12 years ago

Using MathJax

The most easy way to integrate Latex with Redmine is to integrate MathJax

You just need to paste these two lines into the file app/layouts/base.html.erb

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" 
  src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

and it works perfectly!

I am not familiar with Plugin development, but if its possible to extend the main layout this way, that it would be a very nice, simple and small plugin. :)

Actions #32

Updated by Michael Boratko about 12 years ago

Billy T wrote:

Is this plugin working on 2.x?

It now works on 2.x https://github.com/holidayworking/redmine_latex_mathjax

Actions #33

Updated by C Tibirna about 12 years ago

Michael Boratko wrote:

Billy T wrote:

Is this plugin working on 2.x?

It now works on 2.x https://github.com/holidayworking/redmine_latex_mathjax

No, it doesn't. The original source is still https://github.com/process91/redmine_latex_mathjax , but it was not updated to 2.x. It only needs

(09:52:38) [tibirnao@walter]:redmine_latex_mathjax> git diff
diff --git a/init.rb b/init.rb
index d19303c..f3d5be1 100644
--- a/init.rb
+++ b/init.rb
@@ -1,5 +1,5 @@
 require 'redmine'
-RAILS_DEFAULT_LOGGER.info 'Redmine LaTeX MathJax'
+::Rails.logger.info 'Redmine LaTeX MathJax'

 Redmine::Plugin.register :redmine_latex_mathjax do
   name 'Redmine Latex MathJax'

I sent a pull request.

Actions #34

Updated by Michael Boratko about 12 years ago

Thank you, merged.

Actions #35

Updated by C Tibirna over 11 years ago

And all of a sudden, MathJax stopped working on Redmine 2.3.1.

Other versions: Ruby 1.8.7, Rails 3.2.13, redmine_latex_mathjax 0.1.0.

I didn't notice immediately that it doesn't work anymore. It might be due to one of the updates in the last 7 months. There is no error in the redmine log, nor anywhere else I could look at.

Does anybody use MathJax successfully with Redmine 2.3.1?

Actions #36

Updated by C Tibirna over 11 years ago

And all of a sudden, MathJax stopped working on Redmine 2.3.1.

Other versions: Ruby 1.8.7, Rails 3.2.13, redmine_latex_mathjax 0.1.0.

I didn't notice immediately that it doesn't work anymore. It might be due to one of the updates in the last 7 months. There is no error in the redmine log, nor anywhere else I could look at.

Does anybody use MathJax successfully with Redmine 2.3.1?

Actions #37

Updated by C Pacher over 11 years ago

MathJax also stopped working on our Redmine 1.4.4 (approx two weeks ago).

So it might be related to MathJax itself?

Actions #38

Updated by Michael Boratko over 11 years ago

I believe this is fixed now. The problem was that I had used an unofficial link for the MathJax javascript (I'm not sure why I had done that). In any event, it seems this unofficial source no longer hosts MathJax. A user "crax" on GitHub had pointed this out and corrected the link to use the official CDN, and I just merged his changes so things should now be working. Please update the plugin and let me know if there is still an issue. Sorry for the latency in my reply.

Actions #39

Updated by Tobias Verbeke almost 11 years ago

For the record, and as reported on Github, there seems to be an issue (?) with redmine 2.4.2. Anyone has it working with 2.4.2?

Actions #40

Updated by Marius BĂLTEANU over 6 years ago

  • Private changed from No to Yes
Actions #41

Updated by Marius BĂLTEANU over 6 years ago

  • Private changed from Yes to No
Actions

Also available in: Atom PDF