Project

General

Profile

wiki-latex plugin

Added by Nils Israel over 15 years ago

Hi,

this plugin provides a wiki macro to render images from latex source. It was inspired by the graphviz-macro.
The requirements are: latex, dvips, convert (from ImageMagick).

You can find it here: http://github.com/nisrael/redmine-wiki_latex_plugin/tree/master

Nils


Replies (41)

RE: wiki-latex plugin - Added by Brian Schimmel over 14 years ago

Thanks for sharing the plugin. I've got two issues to report, one with a solution and one without:

  1. When downloading it from git, it ends up in a folder called redmine-wiki_latex_plugin, but to make it work, it has to be called just wiki_latex_plugin. Maybe you could edit the description at the top so that it tells the user to rename the folder before executing rake, since it causes some troube if you rename after rake.
  2. On my machine, image creation does not work. Details follow:

Just installed the plugin on Redmine 0.8.6.stable (MySQL), running with Ruby1.8 on Ubuntu 9.04. I've got latex, dvips and convert on my machine, and they all are at /usr/bin/. After some initial problems which are now fixed, the example {{latex($\sum_i c_i u$)}} now yields the output:

<p><img class="latexinline" src="/redmine/latex/80c38e89850226a52f670ebdab7eb5ff7713c4c23224992b883001986d0c0f70.png" alt="$\sum_i c_i u$">
</p>

on my wiki page. When requesting that image, an error 500 occurs, and in the production.log I get:

Processing WikiLatexController#image (for 88.84.151.135 at 2010-05-31 16:36:27) [GET]
  Session ID: dcff972ac1b5ca62d026d6ef589026d4
  Parameters: {"image_id"=>"80c38e89850226a52f670ebdab7eb5ff7713c4c23224992b883001986d0c0f70", "action"=>"image", "controller"=>"wiki_latex"}
Rendering template within layouts/base
Rendering common/404 (404)

ActionView::TemplateError (Mysql::Error: Lost connection to MySQL server during query: SELECT count(DISTINCT `members`.id) AS count_all FROM `members`  LEFT OUTER JOIN `projects` ON `projects`.id = `members`.project_id  LEFT OUTER JOIN `roles` ON `roles`.id = `members`.role_id WHERE (`members`.user_id = 3 AND (projects.status=1)) ) on line #37 of layouts/base.rhtml:
34:         <%= link_to l(:label_search), {:controller => 'search', :action => 'index', :id => @project}, :accesskey => accesskey(:search) %>:
35:         <%= text_field_tag 'q', @question, :size => 20, :class => 'small', :accesskey => accesskey(:quick_search) %>
36:         <% end %>
37:         <%= render :partial => 'layouts/project_selector' if User.current.memberships.any? %>
38:     </div>
39:     
40:     <h1><%= h(@project && !@project.new_record? ? @project.name : Setting.app_title) %></h1>

    vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:147:in `log'
    vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:302:in `execute'
    vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:537:in `select'
    vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
    vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:59:in `select_all'
    vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:80:in `cache_sql'
    vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:59:in `select_all'
    vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:13:in `select_one'
    vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:19:in `select_value'
    vendor/rails/activerecord/lib/active_record/calculations.rb:225:in `execute_simple_calculation'
[...many more stack trace lines...]

Please not that I did not yet apply the parser changes that were recommended above, because I believe that the basic example should work independent from that. I'm not able to recognize the problem from that log. I've searched my redmine directory for *.png, but only the standard images are found, nothing generated from latex.

I'm not sure if the SQL error has anything to do with the failing image generation. The query in the log has an extra closing brace ")" at the end, not sure if this is a logging issue or a real error in the query. , When I execute that statement manually without that brace, I get a proper result.

RE: wiki-latex plugin - Added by John Marsden over 14 years ago

I have played with this plugin and have slightly different requirements. I want to be able to do whole algorithms as well as inline chunks of latex. I started to build it on this plugin and have it mostly working.

The two things I am uncomfortable with in this method,

  1. Changing the base of Redmine is not ideal.
  2. It will always be limited as a Redmine Macro because the macro end delimiter is matched by '}}'. This combination is likely to occur in Latex. I dont want to change the latex format to circumvent this.

Anyway, I have started a new plugin that decides what to markup in latex similar to the way the code syntax highlighting works in the standard markup. It supports all of the standard textile markup so all your existing pages should be fine.

As I write this its totally still an alpha, but I have it working in my own Redmine instance you can look at. The source is in Github here. I need to figure out a lot more about Redmine and Ruby before I can finish it. Right now I am just happy to have the markup syntax sorted so I can keep making pages with it :-)

John

RE: wiki-latex plugin - Added by John Marsden over 14 years ago

Sorry, posted the wrong link to the example in the previous post.

You can check it out here

RE: wiki-latex plugin - Added by Мишка Половнев about 14 years ago

If nothing works, try compiling the following .tex-file using "latex"

\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{color}
\usepackage[active,displaymath,textmath,graphics]{preview}
\begin{document}
$a_b$
\end{document}

Helped me finding my problem :]

RE: wiki-latex plugin - Added by Christopher Jones almost 14 years ago

For users that see the red-box with an mysql error, you likely forgot to follow the redmine plugin installation procedure:

http://www.redmine.org/projects/redmine/wiki/Plugins

In particular ...

"2. If the plugin requires a migration, run the following command to upgrade your database (make a db backup before):

rake db:migrate:plugins RAILS_ENV=production"

Also, the user above that recommending storing the miniature document below to a file (for instance 'test.tex'):

\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{color}
\usepackage[active,displaymath,textmath,graphics]{preview}
\begin{document}
$a_b$
\end{document}

and then running

latex test.tex
dvipng test.png

provides a good check for your latex installation since this is the source format generated by the plugin. Your latex installation might appear to be 'Ok' at first in that it compiles a latex equation that you might have fed it (for instance $sum_i c_i$, but the default linux installation may not include 'preview.sty' file which is instantiated in all latex files created by the plugin and is needed to prevent a latex compile-time error.

RE: wiki-latex plugin - Added by Alexei Galanov almost 14 years ago

I got this error, when latex text contains commas
"
Internal error

An error occurred on the page you were trying to access.
If you continue to experience problems please contact your redMine administrator for assistance."

I think its need to do fix in ./lib/redmine/wiki_formatting/textile/formatter.rb
like this
if macro == 'latex'
args = $5
else
args = ($5 || '').split(',').each(&:strip)
end

but i can find this code in Redmine 1.0.4.stable
Please help.
Thank you.

RE: wiki-latex plugin - Added by Alexei Galanov almost 14 years ago

Problem with commas solved in lib/redmine/wiki_formatting.rb
in def execute_macros
$
if macro == 'latex'
args = $5
else
args = ($5 || '').split(',').each(&:strip)
end$

RE: wiki-latex plugin - Added by Alexei Galanov almost 14 years ago

Still have two great problem:
1. if latex text is to big, i got "Internal error"
2. if more than 6 latex macro on page, some of them not displayed

any ideas ?

RE: wiki-latex plugin - Added by Jonathan Doyle over 13 years ago

I am having a problem with displaying the image produced by the plugin.

I migrated the db, and changed the name from nisrael-redmine-wiki_latex_plugin-28000b9 to wiki_latex_plugin as per comments on this forum.

The image display is just a broken link.

I am using the version of redmine included in the Ubuntu 10.04 package manager

RE: wiki-latex plugin - Added by Rodrigo Braz over 13 years ago

Jonathan Doyle wrote:

I am having a problem with displaying the image produced by the plugin.

I migrated the db, and changed the name from nisrael-redmine-wiki_latex_plugin-28000b9 to wiki_latex_plugin as per comments on this forum.

The image display is just a broken link.

I am using the version of redmine included in the Ubuntu 10.04 package manager

I'm having the exact same problem, anyone knows a fix for this?

RE: wiki-latex plugin - Added by Konstantin A over 13 years ago

In last commit author changed convert to dvipng, so probably you must install dvipng.

RE: wiki-latex plugin - Added by Thimios Dimopulos over 12 years ago

Nils Israel wrote:

Loot at this: http://www.redmine.org/issues/3061
or use this MACROS_RE in ./lib/redmine/wiki_formatting/textile/formatter.rb to

 MACROS_RE = /
 (!)?                        # escaping
 (
 \{\{                        # opening tag
 ([\w]+)                     # macro name
 (\((.*?)\))?             # optional arguments
 \}\}                        # closing tag
 )
 /xm unless const_defined?(:MACROS_RE)
> 

There is no MACROS_RE = line on Redmine 1.3. Has anyone managed to make the plugin work with redmine 1.3?

thanks!

RE: wiki-latex plugin - Added by Thimios Dimopulos over 12 years ago

An alternative to using this plugin, is using the MathJax (http://www.mathjax.org/) plugin: https://github.com/process91/redmine_latex_mathjax

Just installed it on Redmine 1.3 stable and it works fine.

RE: wiki-latex plugin - Added by Herman Fries about 12 years ago

I've updated the code to work with redmine 2.1
https://github.com/baracoder/wiki_latex

RE: wiki-latex plugin - Added by Михаил Марков about 12 years ago

Trying to install from last post (for 2.1) and get an error.
Error executing the latex macro (uninitialized constant WikiLatexHelper)

RE: wiki-latex plugin - Added by Mega ZET about 3 years ago

Hello!

I've updated the plugin: https://github.com/megazet404/redmine_plugin_wiki_latex. Mainly for making it work on Windows and for adding SVG rendering of LaTeX formulas. But there are other small improvements and fixes. The code is completely reworked.

(26-41/41)