Tags:
latex1Add my vote for this tag math2Add my vote for this tag create new tag
, view all tags

LatexModePluginDev Discussion: Page for developer collaboration, enhancement requests, patches and improved versions on LatexModePlugin contributed by the TWikiCommunity.
• Please let us know what you think of this extension.
• For support, check the existing questions, or ask a new support question in the Support web!
• Please report bugs below
• See LatexModePluginDevArchive for older discussions.

Feedback on LatexModePlugin

Known Issues

  • IE6 shows in-line images with a black-background: This is a problem with internet explorer's ability to display transparent PNGs (e.g. http://wordpress.org/support/topic/37134). The output of dvipng is compatible with IE6, but some versions of convert are not. There are two easy fixes: 1) turn off the tweakinline processing and use only the dvipng output, or 2) output GIFs instead of PNGs. -- ScottHoge - 01 Oct 2006
  • Plugin performance is degraded when using the WYSIWYG editor: The wysiwyg editor translates between html and tml on each edit. This can cause adverse effects with the latex markup, including loss of new-lines and translations of latex new-lines, \\, to extra spaces, \. Use of the WYSIWYG editor is discouraged for topics with latex markup.

Comments

Comments on versions 1.4 through 2.62 have been moved to LatexModePluginDevArchive.

Comments have been quiet here lately, so it must be time for a new release (with the potential for new bugs!) wink

v3.0 has been posted. It is a major rewrite of the plugin. It is much more mod_perl friendly now (although untested), and the old code has been split up into a number of modules. More significantly, compatibility has been expanded for a .tex to TML translator. See IncludeExistingLatexDocsInTWiki for details.

Enjoy!

-- ScottHoge - 30 Sep 2006

Hi, there is a small issue in line 359 of Render.pm. You treating an array of hashes as if it were a hash of arrays. Reverting those few lines to 2.62 works though.

  • Fixed in v3.1. v2.6 was broken at the same point as well, but in a different way. At should be functional now. -- SH 04 Oct 2006

-- MarkusBajones - 02 Oct 2006

Thanks for the catch. I forgot that the new 'attachment' piece was a bit incomplete as well. So, I'll upload a new corrected version after a bit, to allow for more testing.

-- ScottHoge - 02 Oct 2006

I have installed the latest version (v3.1) and it appears the behavior has changes with respect to the SCALE and DENSITY settings. Previously, we had changed the DENSITY to 232 and the scale to .5 to increase the quality when the page is printed. When I do that now, it appears that the default density is being used and the images onscreen become 1/2 the size.

-- RickMach - 05 Oct 2006

I figured out the problem. The variable has a typo in it on the LatexModePlugin topic that is included with the install. On the topic it is LATEXMODPLUGIN_DENSITY and it should be LATEXMODEPLUGIN_DENSITY. It is missing the 'E'.

-- RickMach - 05 Oct 2006

Rick. Wow. I can't believe I missed that one, and am glad to see it was an easy fix. Thanks.

-- ScottHoge - 05 Oct 2006

I installed the pluggin and it's dependancies, but I keep getting : Latex rendering error!! DVI file was not created. when I include a %BEGINLATEX% %ENDLATEX% in a topic Apache error log says: [Thu Oct 05 16:41:44 2006] [error] [client 157.159.50.197] File does not exist: /var/www/html/twiki/pub/Main/LatexTest, referer: http://www-public.int-evry.fr/twiki/bin/view/Main/LatexTest what's wrong ?

-- JehanProcaccia - 05 Oct 2006

I'm curious. Is there a setting that produces transparent formulas? This would make the rendering on darker backgrounds much cleaner (e.g. on the gray table rows produced by TablePlugin).

-- FranzJosefSilli - 05 Oct 2006

Franz, I'm not sure exactly what you mean. I've been able to render math in standard tables using the following construct:

%BEGINLATEX{color="white" bgcolor="Blue"}% Ax = b %ENDLATEX%
which renders readably in the blue/header rows (e.g. the last row of the first example of the TWiki:Plugins.TablePlugin). For the gray rows, try bumping up the gamma setting:
%BEGINLATEX{gamma="2.6" }% $\kappa < \gamma$ %ENDLATEX%

That should work well enough.

-- ScottHoge - 06 Oct 2006

A greater gamma correction doesn't work, it just produces darker output. Hm, the bgcolor feature doesn't seem to work on my installation and I would need something like bgcolor="none" for transparency regardless of the background anyway. Can convert create images with transparent background?

-- FranzJosefSilli - 06 Oct 2006

Franz,

It's not only your install that doesn't seem to work. The background color functionality in 2.61 didn't carry over to later releases. dvipng appears to be immune from this, but not convert. I've uploaded a new release that should correct the problem, and render the background color transparent no matter what the page color is.

-- ScottHoge - 06 Oct 2006

Great! It started to work, after I had installed the latest version of dvipng (1.8). Maybe you should mention the versions of the underlying tools under Other Dependencies. wink

-- FranzJosefSilli - 06 Oct 2006

Scott,

In Bugs:Item2965 I report a couple of modules which use the "forbidden" Perl variables $`, $& and $'. Among them is twikiplugins/LatexModePlugin/lib/TWiki/Plugins/LatexModePlugin/Parse.pm. I don't have any reasonable test cases for the plugin ready, but perhaps you can have a look at the attached patch (http://twiki.org/p/pub/Plugins/LatexModePluginDev/LatexModePlugin.Item2965.diff)?

-- HaraldJoerg - 06 Oct 2006

Harold,

Thanks for pointing this out. There certainly isn't any need for "slow" expressions. I'll update it promptly.

-- ScottHoge - 07 Oct 2006

Bug:

With {eqnarray}, the numbering get mixed up. Example:

The length %$y$% of the angled slope is %$\tan{\alpha}=De/y$%

%BEGINLATEX% \begin{eqnarray} 0<\frac{De}{\tan{\alpha_1}}+\frac{De}{\tan{\alpha_2}}+Du Pe<Pe \end{eqnarray}

%ENDLATEX%

Deviding by %$Pe$% we get two equations:

%BEGINLATEX% \begin{eqnarray} \frac{De}{Pe}\Big(\frac{1}{\tan{\alpha_1}}+\frac{1}{\tan{\alpha_2}}\Big)>-Du \ \frac{De}{Pe}\Big(\frac{1}{\tan{\alpha_1}}+\frac{1}{\tan{\alpha_2}}\Big)<1-Du \end{eqnarray} %ENDLATEX%

-- YuvalAviel - 08 Oct 2006

Yuval, this behavior is a consequence of how the images are created: one can't guarantee the order in which they are rendered.

My suggestion is to not use 'eqnarray', and let twiki handle the numbering:

The length %$y$% of the angled slope is %$\tan{\alpha}=De/y$%

%BEGINLATEX{label="eq:one"}% \begin{displaymath} 0<\frac{De}{\tan{\alpha_1}}+\frac{De}{\tan{\alpha_2}}+Du Pe<Pe \end{displaymath} %ENDLATEX%

Deviding by %$Pe$% we get two equations:

%BEGINLATEX{label="eq:two"}% \begin{displaymath} \frac{De}{Pe}\Big(\frac{1}{\tan{\alpha_1}}+\frac{1}{\tan{\alpha_2}}\Big)>-Du \end{displaymath} %ENDLATEX% %BEGINLATEX{label="eq:three"}% \begin{displaymath} \frac{De}{Pe}\Big(\frac{1}{\tan{\alpha_1}}+\frac{1}{\tan{\alpha_2}}\Big)<1-Du \end{displaymath} %ENDLATEX%

This allows you to cross-reference the equations in other parts of the topic, using %REFLATEX{eq:three}% for example.

-- ScottHoge - 08 Oct 2006

Thanks. It works fine now. To another issue: It seems like the WYSIWYG Plugin puts extra letters into the Latex text. The result is that Latex equation is ruined if page is edit with WYSIWYG.

To see the bug: 1. Write a Latex equation. 2. Edit the page in WYSIWYG mode, make some changes and 3. Save.

-- YuvalAviel - 10 Oct 2006

Thanks for the tip. I personally find that the WYSIWYG mode and this plugin are not well suited. But you are correct, extra <br /> characters can be inadvertently added in. A simple patch for the problem I saw:

Render.pm:
L119:    # remove latex-common HTML entities from within math env
++++:    $math_string =~ s/\<br\s*\/?\>//og;
L120:    $math_string =~ s/&amp;/&/og;

If this doesn't fix this problem, then I'll need to have a bit more information on exactly what you are seeing.

-- ScottHoge - 11 Oct 2006

I have a preference variable named GAMMA and it seems to really confuse this plugin. I made the following change and it seems to help

--- LatexModePlugin/Init.pm     2006-10-06 13:12:13.000000000 -0700
+++ lib/TWiki/Plugins/LatexModePlugin/Init.pm        2006-10-23 14:31:30.000000000 -0700
@@ -31,22 +31,18 @@
     my %LMPcontext = ();
 
     # Get preferences values
     $LMPcontext{'default_density'} = 
-        &TWiki::Func::getPreferencesValue( "DENSITY" ) ||
         &TWiki::Func::getPreferencesValue( "LATEXMODEPLUGIN_DENSITY" ) || 
         116;
     $LMPcontext{'default_gamma'} = 
-        &TWiki::Func::getPreferencesValue( "GAMMA" ) ||
         &TWiki::Func::getPreferencesValue( "LATEXMODEPLUGIN_GAMMA" ) ||
         0.6;
     $LMPcontext{'default_scale'} = 
-        &TWiki::Func::getPreferencesValue( "SCALE" ) ||
         &TWiki::Func::getPreferencesValue( "LATEXMODEPLUGIN_SCALE" ) ||
         1.0;
 
     $LMPcontext{'preamble'} = 
-        &TWiki::Func::getPreferencesValue( "PREAMBLE" ) ||
         &TWiki::Func::getPreferencesValue( "LATEXMODEPLUGIN_PREAMBLE" ) ||
         '\usepackage{latexsym}'."\n";
 
     # initialize counters

-- TroyGoodson - 23 Oct 2006

Reasonable changes. The lines you removed were left in for backwards compatibility with earlier versions of the plugin.

-- ScottHoge - 24 Oct 2006

Another comment: The use of \textcolor puts unfortunate restrictions on some of my code. I'm using tikz to make plots, like the code, below.

%BEGINLATEXPREAMBLE% \usepackage{tikz}  %ENDLATEXPREAMBLE%

<div style="float:left;">
| 1 | 0 |
| 2 | 1 |
| 3 | 1 |
| 5 | 2 |
</div>

%BEGINLATEX%
\begin{tikzpicture} 
\draw[help lines] (0,0) grid (6,6);
\pgfpathmoveto{\pgfpointorigin} 
\pgfplothandlerlineto 
\pgfplotstreamstart 
%CALC{"$LISTJOIN($n, $LISTMAP(\pgfplotstreampoint{\pgfpoint{$EVAL($T(R$index:C1))cm}{$EVAL($FORMAT(NUMBER, 1, $T(R$index:C2)))cm}}  $NOP($per), $LIST( R1:C1..R$ROW(0):C1 ) ) )"}%
\pgfplotstreamend 
\pgfusepath{stroke} 
\end{tikzpicture}
%ENDLATEX%
The problem is that if I put any blank lines in my tikzpicture for readability, I get this error message from latex
Runaway argument?! Undefined control sequence.
\endtikzpicture ...eline =\pgf@baseline \endscope 
                                                  \let \pgf@baseline =\pgf@s...
l.51 \end{tikzpicture}
? 
{ \begin {tikzpicture} \draw [help lines] (0,0) grid (6,6); \pgfpathmoveto \ETC
.
! Paragraph ended before \@textcolor was complete.
<to be read again> 
                   \par 
l.49 

-- TroyGoodson - 24 Oct 2006

Wow. Cool graphics package. And I see how the color.sty package interferes with it. Here is a simple fix that may work:

Render.pm:
++++:        $value =~ s/\n\s*?\n/\n/gs;
L477:        # disable commands flagged as 'do not render'

That is, strip off all blank lines before writing to twiki_math.tex. I'm not sure if this will interfere with other packages, though. (e.g. I know endfloat requires line breaks in certain places)

-- ScottHoge - 25 Oct 2006

Hi Scott and others, I have here a strange situation, that seems to be a bug. Just cut and past the lines between the **

*************************************

notice the "X=..." equation.

In the firest equation it is rendered correctly,

%BEGINLATEX{label="eq:one"}% Y^{flat}_A = \frac{Y^{led}_A}{Y^{led}_W} \cdot 100 \cdot (L^{led}/L^{flat}) ... X=\frac{Y^{flat}}{y}x %ENDLATEX%

but in the second equation, the \frac directive is not rendered correctly:

%BEGINLATEX{label="eq:two"}% X=\frac{Y^{flat}}{y}x %ENDLATEX%

*******************************

For some reasong the debug output is not written to data/debug.txt, so I can't see Latex's messages. Any idea what can I check?

-- YuvalAviel - 02 Nov 2006

rendering errors are typically reported only with preview. Maybe this should change, since it is a carryover from Cairo days?

After a cut-n-paste, the plugin returned the following on preview: ! Missing $ inserted.

If you add in a '\[' and '\]' around each of the equations, it should render properly. The %BEGINLATEX% macros don't assume a math environment, so that other markup can be used.

Hope this helps.

-- ScottHoge - 02 Nov 2006

Yeap, it helped.

I think it is good that rendering errors show only in preview, the reader shouldn't be bothered by such messages, but the writer should.

I never saw this error message ! Missing $ inserted. . I only get

Latex rendering error messages:

Content-type: text/plain

TWiki detected an internal error - please check your TWiki logs and webserver logs for more information.

exec failed: No such file or directory

even if everything is rendered correctly ...

Running: TWiki build 10807, Plugin API version 1.1, LatexModePlugin V3.2, Firefox 1.5.0.7, Fedora Core 5

-- YuvalAviel - 05 Nov 2006

I have a strange behaviour that whenever a page is visited which has latex code inside some images are re-rendered.

We noticed it because change notifications are sent whenever somebody visits that page. How could I avoid this?

Thanks

Running LatexModePlugin 3.1, $Rev: 11676$ with twiki 4.0.5

-- BalintMiklos - 28 Nov 2006

One way to avoid the effect is to enable the Cairo attachment code by adding to following line to lib/TWiki/LocalSite.cfg

$TWiki::cfg{Plugins}{LatexModePlugin}{bypassattach} = 1;
This won't stop the rerendering, but the rendering will at least not trigger a change notification. I'll add this to the bug list, and post when it is fixed.

-- ScottHoge - 28 Nov 2006

Thanks for the quick answer!

-- BalintMiklos - 29 Nov 2006

I just installed the plugin and am getting this error when I try to view the LatexModePlugin topic:

TWiki detected an internal error - please check your TWiki logs and webserver logs for more information.

Undefined subroutine &TWiki::Plugins::LatexModePlugin::Render::handleLatex called
The logs say that it was called at LatexModePlugin.pm line 210. I checked that the Render.pm file is present, with correct permissions and the file does not appear to be corrupted. Have I done something wrong? Any ideas?

-- BenWatts - 19 Dec 2006

Make sure the .pm file and lib dirs are world readable. Also make sure you have an absolute TWiki lib path defined in bin/LocalLib.cfg (with relative path, modules can't load if TWiki does a cd after init.)

-- PeterThoeny - 19 Dec 2006

Files and dirs are world readable. LocalLib.cfg has an absolute path for the lib dir. The logs mention nothing about permission denial, only code errors. I might download the files again and replace them (not that I am very confident that will fix it). Further, the InstalledPlugins page shows no errors and I have the TimeTablePlugin working on the same TWiki. Here is what gets written to my apache error log:

[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] Undefined subroutine &TWiki::Plugins::LatexModePlugin::Render::handleLatex called at /home/www/twiki/lib/TWiki/Plugins/LatexModePlugin.pm line 210.
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX]  at /home/www/twiki/lib/TWiki/Plugins/LatexModePlugin.pm line 210
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tTWiki::Plugins::LatexModePlugin::handleLatex('$\\int_{-\\infty}^\\infty e^{ -\\alpha x^2 } dx = \\sqrt{ \\frac{\\p...', 'inline="1"') called at /home/www/twiki/lib/TWiki/Plugins/LatexModePlugin.pm line 159
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tTWiki::Plugins::LatexModePlugin::commonTagsHandler('---+<nop>LatexModePlugin\\x{a}\\x{a}This <nop>LaTeX Mode TWiki Plugin a...', 'LatexModePlugin', 'TWiki', 0) called at /home/www/twiki/lib/TWiki/Plugin.pm line 225
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tTWiki::Plugin::invoke('TWiki::Plugin=HASH(0x14e6280)', 'commonTagsHandler', '---+<nop>LatexModePlugin\\x{a}\\x{a}This <nop>LaTeX Mode TWiki Plugin a...', 'LatexModePlugin', 'TWiki', 0) called at /home/www/twiki/lib/TWiki/Plugins.pm line 303
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tTWiki::Plugins::_dispatch('TWiki::Plugins=HASH(0x119cf30)', 'commonTagsHandler', '---+<nop>LatexModePlugin\\x{a}\\x{a}This <nop>LaTeX Mode TWiki Plugin a...', 'LatexModePlugin', 'TWiki', 0) called at /home/www/twiki/lib/TWiki/Plugins.pm line 439
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tTWiki::Plugins::commonTagsHandler('TWiki::Plugins=HASH(0x119cf30)', '---+<nop>LatexModePlugin\\x{a}\\x{a}This <nop>LaTeX Mode TWiki Plugin a...', 'LatexModePlugin', 'TWiki', 0) called at /home/www/twiki/lib/TWiki.pm line 2470
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tTWiki::handleCommonTags('TWiki=HASH(0x6054d0)', '---+!! <nop>%TOPIC%\\x{a}\\x{a}This <nop>LaTeX Mode TWiki Plugin allows...', 'TWiki', 'LatexModePlugin') called at /home/www/twiki/lib/TWiki/UI/View.pm line 322
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tTWiki::UI::View::_prepare('---+!! <nop>%TOPIC%\\x{a}\\x{a}This <nop>LaTeX Mode TWiki Plugin allows...', 'TWiki=HASH(0x6054d0)', 'TWiki', 'LatexModePlugin', 'TWiki::Meta=HASH(0x89f9f0)', 0) called at /home/www/twiki/lib/TWiki/UI/View.pm line 306
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tTWiki::UI::View::view('TWiki=HASH(0x6054d0)') called at /home/www/twiki/lib/TWiki/UI.pm line 109
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tTWiki::UI::__ANON__() called at /home/www/twiki/lib/CPAN/lib///Error.pm line 379
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \teval {...} called at /home/www/twiki/lib/CPAN/lib///Error.pm line 371
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tError::subs::try('CODE(0x1698660)', 'HASH(0xd0db80)') called at /home/www/twiki/lib/TWiki/UI.pm line 158
[Tue Dec 19 17:59:24 2006] [error] [client XXX.XXX.XXX.XXX] \tTWiki::UI::run('CODE(0x68df70)') called

-- BenWatts - 19 Dec 2006

I recommend that you check for compilation errors outside of the server. You can use perl -c Render.pm in the lib/TWiki/Plugins/LatexModePlugin/ directory to check syntax.

The current version uses eval to load the .pm files, which masks errors in compilation. This was chosen for two reasons: to allow the Parse module to be excluded from the standard release but still be easy to install; and to lazy-load the modules only when needed.

Alternatively, you could change L130 from eval( use ... ) to use ..., then compilation errors will show up in the apache logs.

Hope this helps.

-- ScottHoge - 20 Dec 2006

Thanks Scott. I used the perl -c Render.pm command and it told me that I had forgotten to install the Image::Info perl module (silly me!). I installed it and now the plugin works (no need to change code).

-- BenWatts - 28 Dec 2006

Today's release (v3.5) fixes a few minor things.

  • mimetex should now give results comparable to the other engines whether tweakinline is enabled or not.
    image comparing mimetex output with other options
  • previously, images from included topics were not generated. This is now changed, with the generated images now stored-in/attached-to the included topic. I'm not sure this is the best choice, but it's easy enough to change later if need be. On the one hand, if the markup is rendered the same in both views (say TopicA and the topic that includes TopicA), then storing the images from TopicA in the TopicA directory will save disk space. On the other hand, if the markup options are different (say DENSITY = 116 for TopicA and DENSITY = 300 for TopicThatIncludesTopicA), then it might make better sense to store the generated images in separate directories. Comments?
  • I have yet to confirm why re-rendering occasionally happens (see Nov 28 Comment), but one possibility is that a change in the listing order of the options for calculation of the md5 hash would produce a different hash. So now, the options are sorted. Time will show if this fixes the problem.

Enjoy.

-- ScottHoge - 30 Dec 2006

After installing this version, I tried to load a page with Latex and it failed due to an undefined called to attachmentExists. See the detail in Bugs Item3369. I have fixed the issue and uploaded v3.51

-- RickMach - 30 Dec 2006

Rick, Thanks for the catch, and the fix!

Thinking a bit more about where to store images from included topics, I'm inclined to change it a bit: if the image associated with a particular set of markup text and options exists on the included topic, then go ahead an use it; otherwise, generate a new image but store it on the current topic. This will keep both the number of image copies down but also not modify a topic (via attachment) that is only being included. Again, feel free to comment as it may take a bit of time to work this idea in to the code.

-- ScottHoge - 30 Dec 2006

No problem with the fix. Thanks for developing this useful plugin.

As for the included rendering, I believe the modification you describe in your last post is a reasonable approach to the problem and the best of the options described.

-- RickMach - 31 Dec 2006

Discovered some kind of Bug: tried to use a line which included

\begin{displaymath} \begin{array}{clrr} % 10x_1 &amp;amp; - 7x_2 &amp;amp; &amp;amp; = 7 \ -3x_1 &amp;amp; + 2x_2 &amp;amp; + 6x_3 &amp;amp; = 4 \ 5x_1 &amp;amp; + x_2 &amp;amp; + 5x_3 &amp;amp; = 6 \end{array} \end{displaymath}
This caused Latex to never stop processing the topic and consume 100% CPU. The page would not load until process was killed from the server, after that there was a note about "no dvi file created" or similar.

Wysiwyg edit probably replaced the & with &, and this caused the error, as the array rendered without problems before.

-- MikkoLaakso - 19 Jan 2007

The culprit in the latex markup appears to be the '%' char, which turns the rest of the statement into a comment in the latex file.

as for why the process never returns... not sure there is anything that can be done at the plugin level. One can configure the server to kill run away processes, e.g. in Apache via RLimit settings.

p.s. This plugin and the WYSIWYG editing generally don't go well together. In this case, it appears the WYSIWYG editor removes newlines, and in the process converts the array end-of-line commands, \\, to a single extra space command, \. One way around this is to add extra spaces after the array new-line commands. One also has to remove all comments in the latex markup if using the WYSIWYG editor.

-- ScottHoge - 20 Jan 2007

That's ok, btw thanks for this very good plugin. I just disabled Wysiwyg to solve these problems, it's really incomplete anyway.

-- MikkoLaakso - 22 Jan 2007

I see the plugin can render to png or gif. However I can't see in the documentation how that choice is made. What I am missing? Thanks!

-- RickMach - 02 Mar 2007

This choice is hard-coded in the Render.pm file, line 78. The documentation was written when the plugin was contained all in one file, and should be updated. Thanks for pointing it out.

-- ScottHoge - 05 Mar 2007

I'll update the documentation. I was also considering moving this into a real configuration option. What do you think the best approach would be? I was thinking something like the other engine configuration like: {Plugins}{LatexModePlugin}{extension} = 'png'. Thoughts?

-- RickMach - 09 Mar 2007

Sounds good to me. I think the id could be a bit more descriptive, however. Maybe {Plugins}{LatexModePlugin}{image-type} ? or {image-extension} ?

-- ScottHoge - 10 Mar 2007

Everything is now checked into Subversion (see revision 13128). I called the option {Plugins}{LatexModePlugin}{imagetype} as you can't use a '-' in the name. I didn't publish a new version of the plugin since I see you submitted changes that I wasn't sure you were ready to send out. I submitted the change against Item2933 you had open. I did update the version number to 3.6 from 3.51. I can push a new version to the website or it will be there in your next push.

-- RickMach - 12 Mar 2007

When I updated the code, I added 'jpg' as an option as I saw this in the source file comment. I just tried setting the option to jpg and it didn't work. Do you know if jpg is support or should I just pull that out of the new documentation?

-- RickMach - 13 Mar 2007

Whew. The 'jpg' option took me a bit by surprise as well.

One problem with selecting jpeg as an output is that although convert will support it, dvipng and mimetex will not. A second problem is that the compression algorithm used by jpeg is not well suited for text. The one place it would work well would be rendering of .eps or .pdf attachments. But .png appears to work well enough for that.

So, for now, I would remove jpeg as an option. Going forward, it might make sense to add it in as a rendering option to accompany the engine parameter. I don't have time to look in to much these days, though.

-- ScottHoge - 14 Mar 2007

I thought about adding it as an option for the rendering engine but I wasn't sure it was needed. I may take a look at that since you think it is worthwhile. Any feedback on if the other changes you made are ready to be released?

-- RickMach - 14 Mar 2007

Rick,

Thanks for waiting before release. I had forgotten that I checked in the new inline trim code. It mostly works, but it still needs a bit of polish. I enabled a wrapper to switch between the two now, so that a release won't cause new problems but folks can try the new code if they like.

Thanks for your help!

-- ScottHoge - 14 Mar 2007

It seems $TWiki::fgrepCmd should be read $TWiki::cfg{FgrepCmd} at Line 69 of Render.pm. It does not grab a proper configuration, but fallbacks to the default.

-- KyungdahmYun - 15 Apr 2007

Hello there!

I've installed the plugin, but I cannot make it work on my system. I used the installation script and the latest version provided on the webpage. When trying to open a page that has maths in it, the plugin does not compile. Looking through the warnings, I saw this:

"| 15 Apr 2007 - 15:16 | TWiki::Plugins::LatexModePlugin could not be loaded. Errors were: Bareword "TWiki::Plugins::LatexModePlugin::debug" not allowed while "strict subs" in use at [...]lib/TWiki/Plugins/LatexModePlugin/Init.pm line 27."

So I uncommented "use strict" (hopefully this does not break things too much). Thereafter I do not get any errors regarding that line. However, the module still does not compile. The error was somewhere at line 130 of [...]/lib/TWiki/Plugins/LatexModePlugin.pm (--> line 38 of Render.pm). I tried removing the "evals" to see where exactly it fails. It complains of Image/Info.pm not being in the @INC. It most certainly is there in the @INC path that's put into the warning file (I have checked many times and the installation script sees it too when checking the dependencies).

Any suggestions? Many thanks in advance!

-- DumitruErhan - 15 Apr 2007

Wow. two bugs on the same day! (whew)

  • fgrep: this section validates the API, but is a carry over from pre-Dakar days. It appears that the variable changes a bit from release to release though. I'll have to look in to it a bit more before fixing the problem. As a work around, one can always declare $TWiki::cfg{Plugins}{LatexModePlugin}{fgrep} in LocalSite.cfg
  • debug: This line should read:
my $debug = $TWiki::Plugins::LatexModePlugin::debug;
(with two dollar signs). I don't know how this slipped through for over a year.

It's generally always a good idea to 'use strict;', so that the perl compiler will catch subtle errors (such as this one).

I don't have much advice regarding the Image::Info package not loading. You could try printing @INC to STDERR just before the use Image::Info line, to confirm that the path you need is surviving all the way to Render.

Hope this helps.

-- ScottHoge - 16 Apr 2007

here is a nice one for you if i submit a eqn with out \end{array}, latex goes into interactive mode wanting to fix the equation. it doesnt terminate, just sits there.

i propose this command line arg is added: -halt-on-error

it seems to work for me. (changed every

-interaction=nonstopmode
to
 -interaction=nonstopmode -halt-on-error


mrt@here:/home/twiki/data# pdftex --version
pdfeTeX using libpoppler 3.141592-1.21a-2.2 (Web2C 7.5.4)
kpathsea version 3.5.4
Copyright (C) 1997-2004 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).

-- TerryRankine - 17 Apr 2007

Terry. Excellent suggestion. I'll wrap it in to the next release.

-- ScottHoge - 18 Apr 2007

This plugin works well! But, when I installed the tarball attached to LatexModePlugin, I discovered a couple of typos while running on our mod_perl setup.

  • Init.pm --- missing a leading dollar sign
27c27
< my $debug = TWiki::Plugins::LatexModePlugin::debug;
---
> my $debug = $TWiki::Plugins::LatexModePlugin::debug;

  • in LatexModePlugin.pm --- all references to &handleLatex() must be fully qualified.
159,161c168,170
<     $_[0] =~ s/%(\$.*?\$)%/&handleLatex($1,'inline="1"')/gseo;
<     $_[0] =~ s/%(\\\[.*?\\\])%/&handleLatex($1,'inline="0"')/gseo;
<     $_[0] =~ s/%MATHMODE{(.*?)}%/&handleLatex("\\[".$1."\\]",'inline="0"')/gse
o;
---
>     $_[0] =~ s/%(\$.*?\$)%/&TWiki::Plugins::LatexModePlugin::Render::handleLat
ex($1,'inline="1"')/gseo;
>     $_[0] =~ s/%(\\\[.*?\\\])%/&TWiki::Plugins::LatexModePlugin::Render::handl
eLatex($1,'inline="0"')/gseo;
>     $_[0] =~ s/%MATHMODE{(.*?)}%/&TWiki::Plugins::LatexModePlugin::Render::han
dleLatex("\\[".$1."\\]",'inline="0"')/gseo;
165,166c174,175
<     $_[0] =~ s!%BEGINLATEX{(.*?)}%(.*?)%ENDLATEX%!&handleLatex($2,$1)!giseo;
<     $_[0] =~ s!%BEGINLATEX%(.*?)%ENDLATEX%!&handleLatex($1,'inline="0"')!giseo
;
---
>     $_[0] =~ s!%BEGINLATEX{(.*?)}%(.*?)%ENDLATEX%!&TWiki::Plugins::LatexModePl
ugin::Render::handleLatex($2,$1)!giseo;
>     $_[0] =~ s!%BEGINLATEX%(.*?)%ENDLATEX%!&TWiki::Plugins::LatexModePlugin::R
ender::handleLatex($1,'inline="0"')!giseo;

Also, I put a "die($@) if( $@ );" after each eval in commonTagsHandler(), for sanity checking.

By the way, is there interest in a non-commonTagsHandler() version of this Plugin, something tailored for Dakar plugin interface. Could be enabled with a Config file setting. This would avoid the page scans for the majority of the pages without math symbols on them.

-- CraigMeyer - 19 Apr 2007

smile I'm happy to hear that the plugin works (after a few bug fixes) with mod_perl. smile

I've considered using the registered tag handler in Dakar, buy my understanding is that it only handles simple tags, like %EXAMPLE{ ... }%. Most of the tags here are of the BEGIN ... END type, so I don't think there is much opportunity to make it more efficient this way.

-- ScottHoge - 20 Apr 2007

Following up: I'm confused as to why the handleLatex calls need to be fully referenced as Craig has listed above. The released version calls a function of the same name in LatexModePlugin.pm, which subsequently calls the Render.pm version if the plugin is initialized. So the full reference shouldn't be necessary.

Is the initialization not happening under mod_perl? Or do the separate functions need to have different names, even in different name spaces?

-- ScottHoge - 20 Apr 2007

Scott, you are correct smile The problem with handleLatex() apparently was a side-affect of the other typo. I have removed the fully qualified name on my mod_perl version, and it is running fine. No Errors!

As for the registered tag handler, I have written several TAG handlers which take multi-line input without any problem. As an example:

%INDENT_CODE{"
 select field1, field2, count(*) 
 where field1 = "blah"
 from abaseuhts.protparm
 group by protid, protversionno, dicttablecode
"}%

Displays as:

 select field1, field2, count(*)   where field1 = "blah"  from abaseuhts.protparm  group by protid, protversionno, dicttablecode 

So we could create a TAG like =%LATEX{}% which could do the work of %$ ... $% and %[ ... ]% and BEGINLATEX, ENDLATEX. A second parameter "inline" would be set for in-line or multi-line....whatever.

-- CraigMeyer - 20 Apr 2007

I found a little bug inside Render.pm module. To those who have rendered png with blackborder around, you may try this fix. When I switch on tweakinline, the output png file always has a blackborder around. In order to align the output to other html content, it use latex command \fbox{}, but \fbox is a box with a frame, so change it to \mbox, it works for me.

  • This behavior from fbox implies that the 'shave' step in the tweak-inline post-processing is failing on your server. Changing to mbox will get rid of the box, but the rendered images will probably look no different from when you turn tweak-inline off. If you have the latest plugin version, try setting the tweakline setting equal to '2'. This approach may work better for you. -- SH

-- AnyiLi - 27 Apr 2007

I've tried to install the new version just from SVN, but it produced the same result, so I came out this idea to change \fbox to \mbox. But how the post-processing fail, it seems it worked well for me. At least I can see the difference between tweakinline on or off. BTW, I'ved tried set tweakinline to 2, but I got 2 dots around the rendering, do you know why ?

-- AnyiLi - 27 Apr 2007

Well, go with what works. wink

The tweakinline = 2 setting uses the two dots instead of the box. But they should be removed internally by the plugin before attaching the image to the topic. I'll have to look in to this more closely and see if I can replicate your observations.

-- ScottHoge - 27 Apr 2007

I added the following to LatexSymbols:

See also: http://equplus.net/ - Copy & paste science and math equations in TeX, MathML and MathType format

Possibly add this to the plugin topic if that makes sense?

-- PeterThoeny - 12 May 2007

Hello, I have just installed this plugin on my department's new TWiki site. For the most part everything is working, but I do not have any tmp directories created that contain the twiki_math.tex file or the associated dvi and png files. Why are these files not being created in the tmp directory?

-- EricNantz - 23 Sep 2007

Eric, I'm happy to try and help debug your installation. First, what operating system is TWiki installed on?

By default, the temporary files are deleted after the page is rendered. If you turn the debug mode on in a test topic, by setting

  • Set LATEXMODEPLUGIN_DEBUG =1
then, the temporary files will not be deleted. It will also log (in twiki/data/debug.txt) the location of the temporary directory (Render.pm:L692). If it has trouble accessing the directory, the debug mode will report this as well.

Another suggestion is to use the 'preview' button after editing. This will display more verbose error messages.

The most likely reason that files can't be created in the tmp directory is that the tmp directory does not have write access from the web server.

-- ScottHoge - 26 Sep 2007

Hi Scott, thank you very much for your response.

We have twiki installed on Ubuntu 6.06.

I did set the preference for the debug mode to be enabled in the specific topic and I did verify that the twiki/data/txt file is being written to. When I click preview, I do see a tmp directory created. I believe the problem was that I set the debug preference on the Plugin page incorrectly.

I have one other issue that I wanted to discuss. My purpose for using TWiki is to provide an interface for myself and our colleagues to edit an older textbook that was written entirely in LaTeX code. The issue is that if we upload the LaTeX code for a particular section, and if that section is outputted on more than one page, then we only see the first page displayed on the TWiki topic page. Is there any way to display the additional pages of the output on the topic page after processing the LaTeX code?

-- EricNantz - 02 Oct 2007

Eric, sounds to me like what you really need is the Parse engine. I haven't released this as an official part of the plugin, as it is less robust that I would prefer. You can get it in the SVN tree, however. Installation instructions are here.

This should fit your needs better than rendering an entire page of latex output as an image.

-- ScottHoge - 04 Oct 2007

Could you explain what this does

$TWiki::cfg{Plugins}{LatexModePlugin}{bypassattach} = 1;

We have seen that topics with latex are updated by TWikiGuest and have new attachments. Notifications are sent as the page has been updated. We don't want TWikiGuest to be the latest author. Does the above setting stop this?

-- PeterJones - 09 Nov 2007

I enable this setting. If you don't, you get all the image files as page attachments which can really clutter things up if you have real attachments on the page. I think this till fix your problem as well.

-- RickMach - 09 Nov 2007

Hi Devs, I have trouble getting the LatexModePlugin to run. Preview gives me a "Latex rendering error!! dvi file was not created.", with no further information, on the Latex-Sample of LatexModePlugin. Formulas are not rendered, but the Latex-Source text is converted to png images and displayed. Apache logs report a "... [error] ... File does not exist: /home/.../SimonHeinzlePersonal, referer: http://XXX.XXX.XXX/.../twiki/bin/view/XXX/SimonHeinzlePersonal". Unfortunately, twiki/data/warn200711.txt does not give any error at all. Also twiki/data/debug.txt does not seem to report something unusual: rendering starts with "::doInit()" and finishes with "::renderEquations".

How can I get more information from runtime, to find out why the dvi file cannot be created?

-- SimonHeinzle - 15 Nov 2007

Hi! I'm having problems with LatexModePlugin (laste version, 3.71, $Rev: 15599) with 'ps' engine. Simply, it does seems to me the setting in lib/LocalSite.cfg is ignored and LatexModePlugin does always fall back to 'dvipng', that I don't have installed in my system.

TWiki logs in data/warn200711.txt are saying:

data/warn200711.txt:| 15 Nov 2007 - 23:17 | exec failed: No such file or directory at /var/www/vhosts/bproofs.homeunix.org/httpdocs/twiki/lib/TWiki/Sandbox.pm line 389.

data/debug.txt is full of lines like this:

...
| 15 Nov 2007 - 23:41 | LatexModePlugin: $\{\cdot\}^H$ :: bgcolor=>white; color=>black; density=>116; engine=>dvipng; gamma=>0.6; inline=>1; scale=>1.0; topic=>LatexModePlugin; web=>TWiki
...

lib/LocalSite.cfg contains these lines:

$TWiki::cfg{Plugins}{LatexModePlugin}{latex} = '/usr/bin/latex';
$TWiki::cfg{Plugins}{LatexModePlugin}{dvips} = '/usr/bin/dvips';
$TWiki::cfg{Plugins}{LatexModePlugin}{convert} = '/usr/bin/convert';
$TWiki::cfg{Plugins}{LatexModePlugins}{engine}  = 'ps';
$TWiki::cfg{Plugins}{LatexModePlugin}{pdflatex} = '/usr/bin/pdflatex';

The paths are right, all tested with wich . Tryed even mode 'pdf' with same result. Seems the same error of earlier post of YuvalAviel , but he got no answer.

Please help me, thanks a lot!

-- FrancescoPretto - 15 Nov 2007

Ok, in LatexModePlugin page, "Plugin Installation Instructions", these 2 lines are wrong:

$TWiki::cfg{Plugins}{LatexModePlugins}{engine}
$TWiki::cfg{Plugins}{LatexModePlugins}{imagetype}

as Render.pm is refering to {LatexModePlugin} and NOT {LatexModePlugins}. Still, i'm having the same problem... Maybe lib/LocalSite.cfg is not read? Solution seems near.

-- FrancescoPretto - 16 Nov 2007

I considered the Plugins vs Plugin setting in Render a bug, which is what prompted the new release. (found it during an install on bluehost). But forgot to update the doc.

I'm confident the LocalSite.cfg is read on my installations, as I use the bypassattach setting there. I'll see if I can recreate your report.

-- ScottHoge - 16 Nov 2007

Thanks. Yes, lib/LocaleSite.cfg is read. I solved the path problem: documentation needs to point to set even fgrep location, as it could not be in /usr/bin/fgrep, like in my case. The variable to be put on lib/LocaleSite.cfg is:

$TWiki::cfg{Plugins}{LatexModePlugin}{fgrep}

Now i have a:

Latex rendering error!! dvi file was not created.

But no more exec failed: No such file or directory errors. I'll try to debug it more deeply. However, tetex v2.02 is still supported? Is the version i'm using now.

-- FrancescoPretto - 16 Nov 2007

I've attached debug.txt and 2 *.tex files contained in the latex workdir in /tmp. Calling latex on them seems to work. There's even a log file there, but it's empty (or almost, nothing useful). This trying to render the standard LatexModePlugin on my system. The error is the previous Latex rendering error!! dvi file was not created. . Similar one trying pdf engine. This is on my apache log:

[Fri Nov 16 17:31:29 2007] [error] [client 87.9.191.225] File does not exist: /var/www/vhosts/bproofs.homeunix.org/httpdocs/twiki/pub/TWiki/LatexModePlugin/l
atex29e60d6fae81d16fd6ae875e36a1622f.png, referer: http://bproofs.homeunix.org/twiki/bin/view/TWiki/LatexModePlugin

-- FrancescoPretto - 16 Nov 2007

Francesco,

The files you posted look unremarkable. (sorry). The apache error log just says that it can't find the images to serve, which is reasonable since the .dvi file failed.

the .dvi file not created problem can come from a number of causes. Trying to write to a directory without write permissions is one, but if the plugin is writing the .tex files you are probably ok. Another cause is not having the tex paths accessible from the server process, i.e. you can run latex just fine using your account, but the account running the web-server processes can't because the tex paths aren't set up.

One additional tool to debug this is to add a $sandbox->{TRACE} = 1; line in Render.pm just before the PATHTOLATEX/PATHTOPDFLATEX sysCommand. Then, the latex command used will show up in the apache error logs.

-- ScottHoge - 16 Nov 2007

Thanks, I'll try. Would be cool to have commands and output of them logged, in the future.

-- FrancescoPretto - 16 Nov 2007

Thanks for the hint! Found the problem, -halt-on-error is not a valid switch in tetex 2.0.2 (at least here in Centos4.5). It seems I'm still lacking some macros (the example graph is not exactly like the one in LatexModePlugin page smile ) but, hey!, render does finally work. Maybe a compatibility variable could be put on lib/LocalSite.cfg to still support old versions of tetex? However, that $sandbox->{TRACE} = 1; helped me a lot, thanks again!

-- FrancescoPretto - 16 Nov 2007

Wow! Thanks for the feedback. I'll update the release.

-- ScottHoge - 16 Nov 2007

I see the same problem with tweakinline = 2. I've looked into the problem, and found that the code would transform the latex output into XPM, and then expect that a "color" like "None" is used as background. Somehow this is not the case in my installation (Debian etch). I've modified it to use "gray100" as a fallback instead, which seems to work. Here is my patch.

--- Render.pm.orig      2007-11-15 12:03:12.000000000 +0000 +++ Render.pm   2007-11-29 11:25:16.000000000 +0000 @@ -1031,7 +1031,7 @@                           OUT => $out );        my ($pre, $xpm); -    my ($canvaschar,$cpp) = (' ',1); +    my ($canvaschar,$canvaschar2,$cpp) = ('',' ',1);      my ($col, $flag, $cnt) = (0,0,0);      my ($midu, $midl, $sum)  = (0,0,'');       @@ -1083,7 +1083,12 @@                  $canvaschar = substr($_,1,$cpp);                  # $canvaschar =~ s/([\*\,])/\\$1/g;              } +            if ($_ =~ m/gray100/) { +                $canvaschar2 = substr($_,1,$cpp); +                # $canvaschar =~ s/([\*\,])/\\$1/g; +            }          } +        $canvaschar ||= $canvaschar2,          $flag = 1 if m!/\*\spixels\s\*/!; # switch between 'pre' and the image      }      close(F); 

-- IsaacTo - 29 Nov 2007

Isaac, Thanks for the patch. I'll look to roll it into the next release.

-- ScottHoge - 29 Nov 2007

Fixes for both the halt-on-error bug and tweakinline bug for ps engine listed above have been released. Enjoy.

-- ScottHoge - 02 Dec 2007

Me again... I finally know why in my system it doesn't use "None": I didn't have dvipng installed; using dvips there is nowhere to pass the "-bg transparent" flag. I think it's a good idea to give dvipng a try, and... I see one cdot in tweaklines=2 mode at the right hand side! My initial feeling is that it might happen that the generated XPM has both a gray100 line and a None line, and the wrong one is selected. It does have both, but it seems to be in the right order that it shouldn't be a problem (but is it always that "right" ordering?).

Digging deeper I find the answer. The generated xpm file has one background pixel on the right, and the code finding the right cdot didn't expect it and missed it. Patch fixing it and trying to make it more robust follows.

--- Render.pm.orig      2007-12-02 12:45:55.000000000 +0000 +++ Render.pm   2007-12-03 15:14:09.000000000 +0000 @@ -1131,7 +1131,7 @@      # print $sum ."\n";      my ($frnt,$back) = (0,0);      $frnt = length($1)*$cpp if ($sum =~ m/^(1+0+)/); # from the left  -    $back = length($1)*$cpp if ($sum =~ m/(0+1+)$/); # and from the right +    $back = length($1)*$cpp if ($sum =~ m/(0+1+0{0,2})$/); # and from the right      # print "frnt: $frnt back: $back\n";        $pre =~ m/\"$col\s+$cnt/; 

-- IsaacTo - 03 Dec 2007

I've ended up understanding the whole trimInlineImage_v2 subroutine, and in the way refactor it so that I can more easily understand it fully. If interested, see the patch in LatexModePluginRenderRefactoring.diff that I've created.

-- IsaacTo - 03 Dec 2007

Hi

Can't seem to get this plugin to work outside of my Sandbox or TWiki Web. Can't understand why a plugin should work for one web, but not another. Anyway, my debug file says:

exec failed(/usr/bin/fgrep -A 1 ! %LOG|F%): No such file or directory at /usr/share/perl5/TWiki/Sandbox.pm line 359.

Can anyone please help me? Thanks

-- ChrisCauser - 04 Jan 2008

Hmmm. I can't say right off why it would work on one web but not another.

The error is complaining that it can't find 'fgrep'. You can over-ride the the plugin default by adding a line to LocalSite.cfg, setting $TWiki::cfg{Plugins}{LatexModePlugin}{fgrep} to the path of the grep-like search program. That should solve the error you report.

-- ScottHoge - 04 Jan 2008

Thanks for the swift reply

This is what I have in LocalSite.cfg:

$TWiki::cfg{Plugins}{LatexModePlugin}{fgrep} = '/usr/bin/fgrep';
$TWiki::cfg{Plugins}{LatexModePlugin}{latex} = '/usr/bin/latex';

I editted Sandbox.pm line 359 so it now reads:

throw Error::Simple( "exec failed($template): ".$! );
and in preview, it gives the error message:
TWiki detected an internal error - please check your TWiki logs and webserver logs for more information.

exec failed(path -A 1 ! %LOG|F%): No such file or directory

Thanks for any help.

-- ChrisCauser - 05 Jan 2008

OK, I can answer my own problem: my pub directory didn't have the right permissions to create different Web directories. So, basically, there were Main, TWiki and Sandbox web directories there already so Latex could work for them, but not for my own Webs.

Cheers again Scott. Great plugin!

-- ChrisCauser - 06 Jan 2008

There's a strange interaction with %TOC% (TWiki 4.1.2): disabling a TOC entry by putting a !! after the heading is ignored if there's a %$$% in the text.

---+!! Fits of SSD Data to HRMA Contamination
%TOC%
%$A = 0$%

The TOC should be empty, but isn't: the heading is still shown. It works fine if there's a %MATHMODE%.

-- DiabJerius - 02 Apr 2008

This is for Version 02 Dec 2007 (v 3.72, SVN:15839)

-- DiabJerius - 02 Apr 2008

Hmmm. This is probably due to an overload of syntax. To do cross references of sections, the plugin scans characters after all heading markup. I'll look into this and see if I can find an easy fix. Thanks for bringing it up.

-- ScottHoge - 05 Apr 2008

Diab, thanks for catching this bug. Here is the fix: Line 40 of CrossRef.pm should read

    my $ret = '---'.$l.$e.' '.$text." \n"
In the release version, the $e is missing. That should fix it. I'll update the release sometime within the next week.

-- ScottHoge - 07 Apr 2008

A couple of problems I'm seeing:

In Render.pm is causing an error during the check for "halt-on-error":

[Sun Apr 20 12:31:23 2008] [error] [client 192.168.1.102] Use of uninitialized value in pattern match (m//) at c:\\PROGRA~1\\TWiki\\twiki\\lib/TWiki/Plugins/LatexModePlugin/Render.pm line 578., referer: http://192.168.1.119/twiki/bin/edit/WebEngr/EngrTest1?t=1208708000;nowysiwyg=1
Not sure what's wrong with it, but commenting it out works (I know that halt-on-error exists in my installation).

More importantly, I'm having total failures running this, getting the usual "Latex rendering error!! dvi file was not created." Debug is turned on for the test topic, but debug.txt doesn't show any source of error (or anything showing latex commands/results - only items related to commonTagsHandler). I'm pretty sure latex/convert/dvips is set up properly, but I am at a loss of how to track this down further. I don't think anything is even written to /tmp, but I don't know if they appear/disappear too quickly for me to see.

-- JohnLStone - 20 Apr 2008

Hi John,

We'll try to help as best we can to get you up and running.

In some installs, I've seen that setting debug true in the topic/web doesn't translate through to Render.pm, so try to hard code the debug flag in the perl files themselves. With debug mode on, at the very least a twiki_math.tex file should be created in the tmp directory, and won't be erased during rendering cleanup.

Based on the error you cited above, I would guess that latex is not being called. I would first double check the path settings and/or permissions.

You can report here if more help is needed. Best luck.

-- ScottHoge - 21 Apr 2008

Scott, thanks for the TOC fix.

-- DiabJerius - 21 Apr 2008

Thanks Scott, I gave up and used the MathML method instead. Works great, and while I wish I had full LaTeX, it'll do for now.

-- JohnLStone - 25 Apr 2008

Why is the plugin's preferences page, like LatexModePlugin, in the section Plugin Settings the name called LATEXMODEPLUGIN_DEBUG? If I read the docs getPreferencesFlag then following their example the name has to be DEBUG. If I use DEBUG the thing worked as expected, but if I use LATEXMODE_DEBUG in the Plugin Settings section the value is ignored.

  • Well, you're right. Thanks for raising the issue, and my apologies for any confusion. Personally, I rarely change the plugin topic on my wikis, and instead set these settings at the WebPreferences level. In this case, you do need the LATEXMODEPLUGIN_ prefix. I'll update the plugin docs to reflect this next chance I get. -- ScottHoge - 30 May 2008

-- ChristianLudwig - 19 May 2008

How can I put multiple \includegraphics in one %BEGINLATEX% ... %ENDLATEX% block please?

  • Currently, this isn't possible. In order to make the syntax simple yet flexible, something had to give, and that something was the ability to declare multiple attachments for a single markup tag. So,
    This for example won't work:
    %BEGINLATEX{attachment="fig1.eps,fig2.eps"}%
    \includegraphics{fig1}
    
    \includegraphics{fig2}
    %ENDLATEX%
    
    whereas this will:
    %BEGINLATEX{attachment="fig1.eps"}%
    \includegraphics{fig1}
    %ENDLATEX%
    
    %BEGINLATEX{attachment="fig2.eps"}%
    \includegraphics{fig2}
    %ENDLATEX%
    

    There is nothing stopping the attachment syntax from being expanded. It may be awhile before I have time to do it properly, however.
    -- ScottHoge - 30 May 2008

  • Thank you for your answer and, especially, for your plugin for LaTeX.

    I have another question or request concerning attachment. How can I refer to an attachment in another topic?


-- WangMeng - 31 May 2008

-- WangMeng - 28 May 2008

re: using attachments from a different topic.

Like the previous request, this would be a good feature to add in to the plugin. Currently, the plugin assumes the attachment is coming from the rendered topic. I'll put this, and the multiple attachment declaration on the TODO list.

Thanks for the feedback!

p.s. I'll plan follow the syntax attachment="TOPIC1/fig1.eps;TOPIC2/fig2.eps". Please give feedback if this conflicts with something I'm unaware of. Thanks.

-- ScottHoge - 02 Jun 2008

Thanks in advance! I hope the new syntax will also support topics from another web.

-- WangMeng - 03 Jun 2008

On attachment, your proposed syntax works and is understandable, although it is not the TWiki convention. If there is just one attachment you could specify attachment="fig1.eps" topic="AnotherTopic", whereas topic could be also "Otherweb.OtherTopic" or "Otherweb.Subweb.OtherTopic". However, this convention does not work if want to point to multiple attachments. Not sure what an intuitive extension of the syntax is for that. Possibly the one you propose.

-- PeterThoeny - 04 Jun 2008

Questions: Hello, My first ever post, so I appreciate I may be "doing something wrong", but, you know, relax, it's only software! I've installed TWiki personal to create an offline wiki to collate and present all my engineering notes and stuff, and I'd like to install LaTeX on it to display all my equations and worked solutions etc... Is it possible to use these maths plugins in this way please? I'm a bit confused about the first step in installation in this case:

"First, confirm that the external software needed by the plugin is installed on the TWiki server. This includes: * The Digest::MD5 and Image::Info perl modules. "

Please could someone advise?

Cheers,

-- JackMacDaddy - 16 Jun 2008

Hi Jack,

These modules need to be downloaded from http://www.cpan.org and placed in the twiki/lib/CPAN/lib/ tree. If you are running TWiki personal on a usb key, or don't have LaTeX natively installed, then I recommend using mimetex as the rendering engine. Then if you find you need fancier rendering, you can install a full LaTeX package at a later time.

Best wishes for a smooth install, and enjoy.

-- ScottHoge - 17 Jun 2008

Hi Scott,

Thanks for that, I really appreciate it.

I actually installed both Dokuwiki, and Twiki on my laptop to give 'em both a go; but I'd very much like to get Twiki working due to all the plugins... just on the laptop for now, but the USB MemStick idea sounds very interesting.

I went to that mimetex site, but it talks about "server" and "cgi", and so I'm not sure what I need to do. I've got MySQL 5.0 and Wampserver on my laptop, but I don't use them; I've also downloaded ImageMagick, as well as the mimetex, and a couple of other plugin and tex zipfiles.

I thought perhaps, you might have to somehow set up the Wampserver in offline mode and do something with the cgi in there. I've played around with CGI before - setting up mambo on my website, and editing the odd tiny little bit of php on tsWebEditor, but frankly i'm a bit out of my depth.

I was hoping someone here might be willing to add some idiot-proof step-by-step instructions for doing this set up, as I think this way of using Twiki (as a notetaking/life organising application for science & engineering students at all levels, could catch on - wikis are brilliant for getting your thoughts down fast in a nicely presented way).

Please could you offer some instructions for setting up mimetex on an offline version of TWiki?

cheers,

Jack

-- JackMacDaddy - 19 Jun 2008

Sorry, what I mean is... following these instructions: http://www.forkosh.com/mimetex.html Where's my cgi-bin directory if I'm doing it as an offline thing? is it here: C:\Documents and Settings\...\My Documents\...\TWiki\twiki\htdocs\cgi-bin

Is this the location where I'd put LaTeX?

(sorry if i'm not explaining myself very well!)

-- JackMacDaddy - 19 Jun 2008

...there seems to be more than one "Digest MD5" file...

-- JackMacDaddy - 19 Jun 2008

Ahhh: 'idiot proof' setup instructions (present company excluded). Prior to the mimetex support, having some web server / system admin experience was a bit necessary with this plugin---and the install instruction reflect that. I can make a point of describing a simpler setup sometime over the weekend. Check back on Monday.

as a preview: to 'install' mimetex, all that is required is to put the binary file in the twiki/cgi-bin/ directory, Then, set the plugin preferences with the correct directory path to mimetex and set mimetex as the default engine. (Installing a full LaTeX program is much more work.) I should have more details by Monday if you need more. Thanks for your patience.

BTW. I use TWiki extensively for exactly what you are looking for: meeting notes (with the ActionTrackerPlugin), quick discussion outlines, reading notes, etc... The ability to cross-link, summarize, and search across projects make it an invaluable tool.

-- ScottHoge - 20 Jun 2008

I think I can cope with that... I do electronics at uni, so I'm supposed to be able to!!! Frankly, I can't wait to get stuck into some of those plugins... the graph ones (can I make smith charts, circuit diagrammes and bode plots i wonder?!) look ace. My first objective (by way of a sort of test) is to type up a lot of my electronics course notes... maths worked solutions, circuit analysis steps and the like. We have to do a final year degree project, and I reckon it would be a pretty nifty and slick way of doing it as a wiki-on-a-stick with lush graphviz images on along with smooth latex, and bibtex.

Cheers for your help... I'll certainly be recommending it and pointing my mates to the site.

-- JackMacDaddy - 20 Jun 2008

I'd already put the mimetex.exe in: "C:\twiki\htdocs\cgi-bin"

Just to report, although the TWiki page loads up and functions fine so far (apart from not displaying the maths I tapped in) I get a couple of error messages:

1. When I double click the run.bat, the little black DOS window gets as far as: C:\twiki\logs>start\ C:\twiki\tools\start.url (though I get "Yen" signs instead of backslashes!)

I then get a pop-up with: "C\twiki\tools\start.URL" (in the header) "There was a problem sending the command to the programme" (in the body) (and an "OK" button).

2. I tried double-clicking the "tinyweb.exe" for a laugh, and I got a pop-up with the following: "TinyWeb/1.94" (in the header)

and... "Path to home directory is absent! See README.TXT for details" "TinyWeb/1.94 service failed to start" "Usage: tinyweb.exe [ ]" "Example: tinyweb.exe C:\www 8000 127.0.0.1 .pl C:\tools\perl\bin\perl.exe" (and an "OK" button, of course!)

I dunno what this means, but I imagine it might have someaught to do with why I can't see any maths displayed.

BTW, I've input them in the following formats:

Maths test:

x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}

[tex] f(x)=\int_{-\infty}^xe^{-t^2}dt [/tex]

Any ideas?

Cheers,

-- JackMacDaddy - 20 Jun 2008

Jack. I have the quick-start doc almost done, but it needs a bit of polishing. In the meantime, I found a bug in the mimetex portion of the rendering code which is probably the reason you have been unable to see any math images. Around line 943 or so, Render.pm should read:

                open(OI,">$outimg");
      binmode(OI);
                print OI $data;
                close(OI);
The binmode line is new. Try adding that line in to see if it cleans things up for you.

And, thanks for the feedback.

-- ScottHoge - 23 Jun 2008

When you say "add"... do you mean "open in tsWebEditor" (a php editing prog) and change and save it?

  • SH: Yep, edit the source file Render.pm in your favorite text editor (Notepad works, if nothing else is available). Or wait a bit and I'll have a new version on SVN, followed by a new release that fixes the bug.

I take it that this process is identical with a TOASt (Twiki-On-A-STick) install - except that on your PC/laptop you're sticking it in C:\Twiki whereas on a memstik you don't need to create any folders, just DLoad the .exe and click through the installation process (copying the mimetex binary into "C:\twiki\htdocs\cgi-bin"?

Is it that straightforward?

  • SH: Well, it should be that straightforward, but the reality is less easy. Because the TOAST (Great acronym, BTW) install is supposed to be super easy, many of the tools most of us use for plugin installation are either missing or hard to use. Once I post the install guide, this should all make more sense.

cheers.

-- JackMacDaddy - 23 Jun 2008

Loooong overdue new release posted. All minor bug fixes from the last six months are now included.

-- ScottHoge - 24 Jun 2008

Sounds great.

So, have the conflicts between the maths rendering and WYSIWYG resolved? I know we're encouraged to learn the TWiki markup, but I'm hoping to build an "offline family wiki", and make it accessible for all.

This leads onto another query... Say you had a sprawling offline wiki on your computer or home network, and wanted to slice off one part of it, e.g.: your family album; your CV; your academic or professional notes; or some other project, and whop it onto a separate blank TWiki either as a TWOn (Online TWiki !?!?!? - I realise I'm pushing the acronym onvelope there!) or as a TOAST... is that easy to do as long as you divide up your TWOff (Offline Twiki !?!?!?) sensibly into the sections you might want to "breed" new smaller TWikis from?

-- JackMacDaddy - 24 Jun 2008

When I did a search on the C:\TWiki folder, I found FOUR of these "render.pm" files (transcribed verbatim):

"C:\twiki\lib\TWiki" (65K)

"C:\twiki\twiki\lib\TWiki" (65K)

"lib/TWiki/Plugins/LatexModePlugin" (48K)

"C:\twiki\lib\TWiki\Plugins\lib\TWiki\Plugins\LatexModePlugin" (48K)

I mean, I wasn't sure whether I'd double installed it, or "onionskinned" it... hmmm... does it matter?! More to the point, which "render.pm" wants seeing to?!

Cheers for all the time you're putting into this, it's genuinely appreciated!

-- JackMacDaddy - 24 Jun 2008

C:\twiki\lib\TWiki\Plugins\lib\TWiki\Plugins\LatexModePlugin\Render.pm is the file you want to change. It does appear that you have multiple installations, though.

And no worries about the support. Bugs are only fixed when good feedback is provided. So thanks for pointing out the trouble you've had.

-- ScottHoge - 25 Jun 2008

Jack, detailed install instructions for TWiki Personal are now located at the topic LatexModePluginOnTWikiPersonal

Thanks again for the feedback.

-- ScottHoge - 25 Jun 2008

Hi Scott,

I've tried to generate some more explicit step-by-step (albeit messy) installation instructions... but I've reached an impasse on installing one of the perl modules: the "file::basenames" one, as you can view on the LatexModePluginOnTWikiPersonal page.

In addition there's the small matter of a funny pop-up that I've put on the support page.

If you do get time, I'd be grateful if you'd have a look at the installation instruction ideas I've put on the page, and clear up the issue of the perl module install - I dunno really what to do to get that bit installed; so I'm stuck without being able to complete the LaTex plugin installation.

cheers,

JackMacDaddy

-- JackMacDaddy - 28 Jun 2008

Hi Jack.

I'll take a look at your changes to the install notes. But I'm confused as to why you have to install File::Basename and Digest::MD5. Both of those are already included in TWiki-WP. Even though they are listed are pre-requisites on the plugin, you shouldn't need to install them again.

Update: How did you get perl Makefile.PL to work? On my test install, none of the perl lib paths were visible to perl by default. You must have a second installation of perl installed somewhere that is visible on the path. This may also explain why File::Basename wasn't visible. I recommend starting from scratch, and doing a test install on a usb drive. When writing my instructions, I used a very clean (aka: rarely used) Windows XP partition, so they should work OK.

-- ScottHoge - 29 Jun 2008

-- JackMacDaddy - 30 Jun 2008

I installed Indigo perl on the system (I've got Python, WAMP, and MS VisualC++ installed as well FWIW). I did nothing special - just did as I said in my additions to the instructions.

When you say, "start from scratch", do you mean uninstall Indigo perl from the computer completely?

I installed File::Basename and Digest::MD5, because that's what it says to do on the installation instructions for T4WP 4.05

-- JackMacDaddy - 30 Jun 2008

-- JackMacDaddy - 30 Jun 2008

Sorry Scott; I meant, that's what it says to do on the LatexModePlugin installation instructions (apologies if I've got my "mords wuddled", I'm dyslexic.)

[i]Plugin Installation Instructions First, confirm that the external software needed by the plugin is installed on the TWiki server. This includes:

The Digest::MD5 and Image::Info perl modules. [/i]

I'll try it on a USB stick, but I'm keen to get the thing set up as an offline thing on the comp, launchable from the desktop (and one day on a home intranet... but I digress!).

An afterthought... is it easy to gather and save all your TWiki content in case you have to (or want to) re-install TWiki from scratch?

-- JackMacDaddy - 30 Jun 2008

Jack,

Well, your report confirms what I suspected: the TWiki Personal version is calling the installed indigo perl version instead of the version included with T4WP. So by 'from scratch' I mean to start with as clean a machine as possible (disable or uninstall indigo perl, etc).

And backing up or moving TWiki data is trivial: just compress-and-save the data and pub sub-directories

-- ScottHoge - 01 Jul 2008

Right, well, I've uninstalled Indigo perl... I still get the same error message... it still loads up... and it still doesn't display maths. I'll try doing it afresh on a USB stick... once I've got to grips with your instructions.

However, I don't follow your "quick hack" instructions... where do you copy these .pm files from? are there loads, and it's just all of them that you can see? Or are we talking about those perl files? You said that only one of these needed isn't there? What's it called please?

(I might be able to work it out myself, but I think the instructions ought to be a bit more explicit).

-- JackMacDaddy - 01 Jul 2008

Sorry, correction: "You said that only one of these FILES IS needed" - you only have to install the image :: info .pm file, is that right?

-- JackMacDaddy - 01 Jul 2008

Jack, I added explicit commands to the instructions.

If TWiki is running, check Plugin diagnostics at http://127.0.0.1:8765/cgi-bin/view.pl/TWiki/InstalledPlugins Perl module errors (if any) would be reported there. If there are no errors, then the problem is with the rendering engine.

-- ScottHoge - 02 Jul 2008

Cheers Scott, I'll play with it over the weekend and report back.

-- JackMacDaddy - 02 Jul 2008

Right, I've extracted it on a USB memory stick, and again (as mentioned in my latest support question), when I double click run.bat to start it up, I get this "there was a problem sending the command to the program" error message; and when I put "http://127.0.0.1:8765/twiki/bin/configure.pl" into the IE7 window, I get a "403" error! Any ideas?

-- JackMacDaddy - 05 Jul 2008

I've got as far as pasting the lines in the "LocalSite.cfg" (although it wasn't obvious that of the two files called "LocalSite", it was the one with the MS Office icon, rather than the one with the name "LocalSite.cfg" which was apparently the actual LocalSite.cfg file where you put those lines. I shifted the final "1;" to the end after the LaTex enable line, and the the two pasted lines for mimetex and gif.

I'm close, but it still doesn't display... at least I get the display of a graphic image that hasn't displayed, rather than just the text formatting (if you catch my drift?!).

I didn't install the .pm files via the DOS window, as I realised that just copying and pasting them did the same thing.

As said, this is all on a USB memory stick.

-- JackMacDaddy - 05 Jul 2008

I think I've tried everything in terms of set-up now; in my sandbox, I get the following error message: -- TWikiGuest - 05 Jul 2008 Latex rendering error!! dvi file was not created.

Any ideas please?

-- JackMacDaddy - 05 Jul 2008

Jack, It sounds like you've made some good progress: the perl side of things appear to be running OK. the dvi error is occuring because either,

  1. mimetex isn't declared as the default engine (double check the LocalSite.cfg file),
  2. the path to mimetex is not correct
  3. the web-server doesn't have permission to run mimetex (unlikely, on TWiki-WP)

To debug this, you can try calling mimetex from the DOS box. Calling it without any arguments should give an ASCII dump of an equation. Then, double-check that the mimetex path in the DOS box is the same as you declared in the LocalSite.cfg file. That should be all that is needed.

(crossing fingers)

-- ScottHoge - 06 Jul 2008

I just want to doublecheck with you (i.e.: I think this ought to go in some installation instructions) which is the LocalSite.cfg file...

You see, there are two files called "LocalSite": one is described as a cfg file (when you look at Preferences) with an Outlook icon, called "LocalSite"; the other is a textfile called "LocalSite.cfg" - you can see where the uncertainty arises!

I'm pretty sure the path to the mimetex binary is correct; I feel sure that I've declared it in the LocalSite file (in fact, both of them!).

In short, it seems like there shouldn't be an error!

-- JackMacDaddy - 07 Jul 2008

\twiki\twiki\lib\LocalSite.cfg is the only file I know of.

Try copying and running mimetex from the cgi-bin directory, through the web browser.

Not sure how else I can help.

-- ScottHoge - 07 Jul 2008

Two observations from working with a very large document divided into multiple topics:

  1. It seems that there's a problem with SECLABEL{.} if LATEXMODEPLUGIN_MAXSECDEPTH is set to a value greater than zero and a heading isn't followed by an empty line (cf. subsection "Additional Resources (external)" on the LatexModePlugin page) in which case the next 'markup element' is made part of the heading
  2. (Parts of) other Topics included using the INCLUDE{.} directive which contain headings with SECLABEL{.} seem to get consecutively numbered a second time and also seem to 'lose' empty lines following headings on the included pages. (REFLATEX{.} references get resolved only once, but also already at the time the include directive is processed.)

E.g., the included fragment
---++++ Topic Maps

<!--
...
-->

Die nachfolgende ‹bersicht zeigt die aktuelle TM-Standardfamilie:
is rendered as follows:

(The second problem may be a side effect of the specified order in which plugins get executed, though the local setting GluePlugin,IfDefinedPlugin,SpreadSheetPlugin,AliasPlugin seems unsuspicious at first glance.)

Update: In order to solve the second problem, INCLUDE{ " mytopic " pattern="...(...)..." [raw="on"] } has to be replaced by EXTRACT{ topic=" mytopic " expand="off" pattern="...(...)..." format="$1" } (cf. FilterPlugin); this also prevents the 'removal' of empty lines following headings in the included parts of a topic.

-- MarkusUeberall - 08 Jul 2008 / 11 Jul 2008

I just tried running it again after a couple of days with no changes... it now won't load off the USB stick... I just get "there was a problem sending the command to the program"!

I dunno if it's too warm or what... can't think... what a shame. I might have another go next weekend if there's time, but I might have to shelve it, and hope that some later version works next time I visit.

-- JackMacDaddy - 13 Jul 2008

The test in the commonTagsHandler of LatexModePlugin.pm has some problems and cannot reliable detect, if TeX-Code is in the page. That's because in the tests like

  ($_[0] =~ m/%(\\\[.*?\\\])%/) 
you use other regexp modifiers than later (especially the modifier 's' is of intereset).

Example: If you have a test page where only %\[ … \]% formulas are inside and all formulas have line breaks in them, then the initial if in the commonTagsHandler doesn't match:

---+ Example topic
Wir haben hier eine Seite mit nur
%\[
x
\]%
asdas

My suggestion: 's' modifier is too expensive (at this position) only to detect if there is TeX-Code inside. But the if has only to be a neccessary condition, so use e.g.

($_[0] =~ m/%\\\[/)
Yes, there are rare cases where this reg exp matches and there is no formula inside, but that doesn't hurt. But the current test hurts.

-- ChristianLudwig - 19 Jul 2008

Christian,

Thanks for the good catch. And I agree with your suggestion... I'll update the code shortly.

-- ScottHoge - 21 Jul 2008

Hi guys just updated to 4.2.2 and latest mod_perl from http://twiki.org/cgi-bin/view/TWiki/ApacheConfigGenerator and now i get this.

https://www.seegrid.csiro.au/twiki/bin/view/TWiki/LatexModePlugin

Any ideas?

-- TerryRankine - 20 Aug 2008

fixed, not sure what was wrong.

I also re-wrote installer based on tools/extender.pl

Can someone please verify it for me?

-- TerryRankine - 21 Aug 2008

I'm trying to install the plugin on a fresh install of 4.2.3. The version appears to be:

$VERSION = '$Rev: 16332$';
$RELEASE = '3.73';

When using bin/configure to install it, I get the following error:

Error: Installer returned errors:

Subroutine install redefined at /data.loss/www/default/htdocs/Murk-20081021/LatexModePlugin_installer.pl line 639.

You may be able to resolve these errors and complete the installation from the command line, so I will leave the installed files where they are.
Installation finished.

When I try to install it manually, I get the following:

% perl LatexModePlugin_installer.pl

### LatexModePlugin Installer ###

This installer must be run from the root directory of your TWiki
installation.
    * The script will not do anything without asking you for
      confirmation first.
    * You can abort the script at any point and re-run it later
    * If you answer 'no' to any questions you can always re-run
      the script again later
Hit <Enter> to proceed with installation

##########################################################
Checking dependency on Image::Info....
##########################################################
Checking dependency on File::Basename....
##########################################################
Checking dependency on File::Copy....
##########################################################
Checking dependency on File::Temp....
##########################################################
Checking dependency on Digest::MD5....
Can't locate object method "findUser" via package "TWiki::Users" at LatexModePlugin_installer.pl line 563, <STDIN> line 1.

-- DiabJerius - 21 Oct 2008

There's a serious incompatiblity between LatexModePlugin and ActionTrackerPlugin if

$TWiki::cfg{Plugins}{LatexModePlugin}{bypassattach} = 0;

The problem occurs when LatexModePlugin saves an image as an attachment. ActionTrackerPlugin has a beforeSaveHandler, which does something to cause TWiki to call afterCommonTagsHandler, which gets you into a recursive spiral.

The calling sequence goes like this (abbreviated)

  1. LatexModePlugin::afterCommonTagsHandler
  2. LatexModePlugin::Render::renderEquations
  3. LatexModePlugin::Render::makePNGs
  4. TWiki::Func::saveAttachment
  5. TWiki::Store::saveTopic
  6. TWiki invokes the beforeSaveHandler(s)
  7. ActionTrackerPlugin::beforeSaveHandler
  8. TWiki::Func::expandCommonVariables
  9. TWiki::handleCommonTags
  10. TWiki::Plugins::afterCommonTagsHandler
  11. start over at 1.

Thus, you get recursive calls to LatexModePlugin::Render until something blows up (you eventually get a bad hash error). In the debugger, Perl eventually starts whining about the depth of function calls when it gets > 100. The images get created, but the topic doesn't get the correct META information, and of course it's dog slow due to the massive number of calls to exapandCommonVariables, not to mention getting a nasty Perl error message at the end.

Here's a dump of the first such cyle when trying to view LatexSymbols4. I apologize for the verbosity.

TWiki::Plugins::LatexModePlugin::afterCommonTagsHandler('| Assigned to | Due date | State | Notify |', 'LatexSymbols4', 'TWiki', undef) called from file `lib/TWiki/Plugin.pm' line 266
TWiki::Plugin::invoke(ref(TWiki::Plugin), 'afterCommonTagsHandler', '| Assigned to | Due date | State | Notify |', 'LatexSymbols4', 'TWiki', undef) called from file `lib/TWiki/Plugins.pm' line 344
TWiki::Plugins::_dispatch(ref(TWiki::Plugins), 'afterCommonTagsHandler', '| Assigned to | Due date | State | Notify |', 'LatexSymbols4', 'TWiki', undef) called from file `lib/TWiki/Plugins.pm' line 494
TWiki::Plugins::afterCommonTagsHandler(ref(TWiki::Plugins), '| Assigned to | Due date | State | Notify |', 'LatexSymbols4', 'TWiki', undef) called from file `lib/TWiki.pm' line 2903
TWiki::handleCommonTags(ref(TWiki), '| Assigned to | Due date | State | Notify |', 'TWiki', 'LatexSymbols4', undef) called from file `lib/TWiki/Func.pm' line 2054
TWiki::Func::expandCommonVariables('| Assigned to | Due date | State | Notify |', 'LatexSymbols4', 'TWiki') called from file `lib/TWiki/Plugins/ActionTrackerPlugin/Options.pm' line 42
TWiki::Plugins::ActionTrackerPlugin::Options::load('TWiki', 'LatexSymbols4') called from file `lib/TWiki/Plugins/ActionTrackerPlugin.pm' line 436
TWiki::Plugins::ActionTrackerPlugin::_lazyInit('TWiki', 'LatexSymbols4') called from file `lib/TWiki/Plugins/ActionTrackerPlugin.pm' line 324
TWiki::Plugins::ActionTrackerPlugin::beforeSaveHandler('%META:TOPICINFO{author="DiabJerius" date="1224625813" format="1.1" reprev="1.4" version="1.4"}%^J---+ Latex Symbols (4 of 5)^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J---++ Symbols for Sets and Analytic Equations^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   %$ \\wp $%        | \\wp (prime numbers)     |   %$ \\emptyset $%   | \\emptyset |^J| ... called from file `lib/TWiki/Plugin.pm' line 266
TWiki::Plugin::invoke(ref(TWiki::Plugin), 'beforeSaveHandler', '%META:TOPICINFO{author="DiabJerius" date="1224625813" format="1.1" reprev="1.4" version="1.4"}%^J---+ Latex Symbols (4 of 5)^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J---++ Symbols for Sets and Analytic Equations^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   %$ \\wp $%        | \\wp (prime numbers)     ... called from file `lib/TWiki/Plugins.pm' line 344
TWiki::Plugins::_dispatch(ref(TWiki::Plugins), 'beforeSaveHandler', '%META:TOPICINFO{author="DiabJerius" date="1224625813" format="1.1" reprev="1.4" version="1.4"}%^J---+ Latex Symbols (4 of 5)^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J---++ Symbols for Sets and Analytic Equations^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   %$ \\wp $%        | \\wp (prime numbers)    ... called from file `lib/TWiki/Plugins.pm' line 661
TWiki::Plugins::beforeSaveHandler(ref(TWiki::Plugins), '%META:TOPICINFO{author="DiabJerius" date="1224625813" format="1.1" reprev="1.4" version="1.4"}%^J---+ Latex Symbols (4 of 5)^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J---++ Symbols for Sets and Analytic Equations^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   %$ \\wp $%        | \\wp (prime numbers)     |   %$ \\emptyset $%... called from file `lib/TWiki/Store.pm' line 866
TWiki::Store::saveTopic(ref(TWiki::Store), 'TWikiAdminGroup', 'TWiki', 'LatexSymbols4', '---+ Latex Symbols (4 of 5)^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J---++ Symbols for Sets and Analytic Equations^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   %$ \\wp $%        | \\wp (prime numbers)     |   %$ \\emptyset $%   | \\emptyset |^J|   %$ \\Re $%        | \\Re (real ... called from file `lib/TWiki/Store.pm' line 1036
TWiki::Store::__ANON__[lib/TWiki/Store.pm:1038]() called from file `lib/CPAN/lib//Error.pm' line 379
eval {...} called from file `lib/CPAN/lib//Error.pm' line 371
Error::subs::try(ref(CODE), ref(HASH)) called from file `lib/TWiki/Store.pm' line 1040
TWiki::Store::saveAttachment(ref(TWiki::Store), 'TWiki', 'LatexSymbols4', 'latexf2cfb2f1f75e6f6e4d9f1b9076fa8517.png', 'TWikiAdminGroup', ref(HASH)) called from file `lib/TWiki/Func.pm' line 1801
TWiki::Func::__ANON__[lib/TWiki/Func.pm:1805]() called from file `lib/CPAN/lib//Error.pm' line 379
eval {...} called from file `lib/CPAN/lib//Error.pm' line 371
Error::subs::try(ref(CODE), ref(HASH)) called from file `lib/TWiki/Func.pm' line 1807
TWiki::Func::saveAttachment('TWiki', 'LatexSymbols4', 'latexf2cfb2f1f75e6f6e4d9f1b9076fa8517.png', ref(HASH)) called from file `lib/TWiki/Plugins/LatexModePlugin/Render.pm' line 1021
TWiki::Plugins::LatexModePlugin::Render::makePNGs(ref(HASH), 'LatexSymbols4', 'TWiki', '/tmp/XnIV7CZOZu/latexlogt7aVO2yA', '/tmp/XnIV7CZOZu') called from file `lib/TWiki/Plugins/LatexModePlugin/Render.pm' line 790
TWiki::Plugins::LatexModePlugin::Render::renderEquations('------+ Latex Symbols (4 of 5) ^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J------++ Symbols for Sets and Analytic Equations ^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   <img style="vertical-align:middle;" align="middle"  src="/Murk-20081021/pub/TWiki/LatexSymbols4/latexe25419063dbcb818cd05919fc4136ea7.png" alt="$ \\wp $" />        | \\wp (pri... called from file `lib/TWiki/Plugins/LatexModePlugin.pm' line 245
TWiki::Plugins::LatexModePlugin::afterCommonTagsHandler('------+ Latex Symbols (4 of 5) ^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J------++ Symbols for Sets and Analytic Equations ^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   <img style="vertical-align:middle;" align="middle"  src="/Murk-20081021/pub/TWiki/LatexSymbols4/latexe25419063dbcb818cd05919fc4136ea7.png" alt="$ \\wp $" />        | \\wp (pri... called from file `lib/TWiki/Plugin.pm' line 266
TWiki::Plugin::invoke(ref(TWiki::Plugin), 'afterCommonTagsHandler', '------+ Latex Symbols (4 of 5) ^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J------++ Symbols for Sets and Analytic Equations ^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   <img style="vertical-align:middle;" align="middle"  src="/Murk-20081021/pub/TWiki/LatexSymbols4/latexe25419063dbcb818cd05919fc413... called from file `lib/TWiki/Plugins.pm' line 344
TWiki::Plugins::_dispatch(ref(TWiki::Plugins), 'afterCommonTagsHandler', '------+ Latex Symbols (4 of 5) ^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J------++ Symbols for Sets and Analytic Equations ^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   <img style="vertical-align:middle;" align="middle"  src="/Murk-20081021/pub/TWiki/LatexSymbols4/latexe25419063dbcb818cd05919fc41... called from file `lib/TWiki/Plugins.pm' line 494
TWiki::Plugins::afterCommonTagsHandler(ref(TWiki::Plugins), '------+ Latex Symbols (4 of 5) ^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J------++ Symbols for Sets and Analytic Equations ^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   <img style="vertical-align:middle;" align="middle"  src="/Murk-20081021/pub/TWiki/LatexSymbols4/latexe25419063dbcb818cd05919fc4136ea7.png" alt="$ \\wp $" ... called from file `lib/TWiki.pm' line 2903
TWiki::handleCommonTags(ref(TWiki), '---+ Latex Symbols (4 of 5)^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J---++ Symbols for Sets and Analytic Equations^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   %$ \\wp $%        | \\wp (prime numbers)     |   %$ \\emptyset $%   | \\emptyset |^J|   %$ \\Re $%        | \\Re (real numbers)      |   %$ \\forall $%     | \\forall   | ... called from file `lib/TWiki/UI/View.pm' line 392
TWiki::UI::View::_prepare('---+ Latex Symbols (4 of 5)^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J^J---++ Symbols for Sets and Analytic Equations^J^J| *Symbols* | *Latex Command* | *Symbols* | *Latex Command* |^J|   %$ \\wp $%        | \\wp (prime numbers)     |   %$ \\emptyset $%   | \\emptyset |^J|   %$ \\Re $%        | \\Re (real numbers)      |   %$ \\forall $%     | \\forall   |           ^J... called from file `lib/TWiki/UI/View.pm' line 373
TWiki::UI::View::view(ref(TWiki)) called from file `lib/TWiki/UI.pm' line 159
TWiki::UI::__ANON__[lib/TWiki/UI.pm:160]() called from file `lib/CPAN/lib//Error.pm' line 379
eval {...} called from file `lib/CPAN/lib//Error.pm' line 371
Error::subs::try(ref(CODE), ref(HASH)) called from file `lib/TWiki/UI.pm' line 197
TWiki::UI::run(ref(CODE), 'view', 1) called from file `view' line 32

-- DiabJerius - 22 Oct 2008

There's a lazy-loading optimization that can be made in commonTagsHandler. It implements what the code looks like it's trying to do, which is to load the LatexModePlugin modules at run time rather than compile time.

*** lib/TWiki/Plugins/LatexModePlugin.pm   2008-06-23 23:29:45.000000000 -0400
--- /data/loss/www/default/htdocs/Murk-20081021/lib/TWiki/Plugins/LatexModePlugin.pm   2008-10-22 10:46:57.000000000 -0400
***************
*** 127,136 ****
               ($_[0] =~ m/%(\$.*?\$)%/) ||
               ($_[0] =~ m/%(\\\[.*?\\\])%/) 
               ) 
!         {   use TWiki::Plugins::LatexModePlugin::Init;
!             use TWiki::Plugins::LatexModePlugin::Render;
!             use TWiki::Plugins::LatexModePlugin::CrossRef;
!             eval(" use TWiki::Plugins::LatexModePlugin::Parse;");
              $initialized = &TWiki::Plugins::LatexModePlugin::Init::doInit(); 
          }
          else 
--- 127,136 ----
               ($_[0] =~ m/%(\$.*?\$)%/) ||
               ($_[0] =~ m/%(\\\[.*?\\\])%/) 
               ) 
!         {   require TWiki::Plugins::LatexModePlugin::Init;
!             require TWiki::Plugins::LatexModePlugin::Render;
!             require TWiki::Plugins::LatexModePlugin::CrossRef;
!             eval ( "use TWiki::Plugins::LatexModePlugin::Parse;" );
              $initialized = &TWiki::Plugins::LatexModePlugin::Init::doInit(); 
          }
          else 

-- DiabJerius - 22 Oct 2008

Wow. Thanks for the great feedback, Diab. I'll look to confirm this.

(and, my apologies for being non-responsive during your efforts.)

-- ScottHoge - 27 Oct 2008

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatdiff LatexModePlugin.Item2965.diff r1 manage 1.2 K 2006-10-06 - 23:26 HaraldJoerg Patch to replace "slow" perlvars by $1, $2, $3
Unknown file formatdiff LatexModePluginRenderRefactoring.diff r1 manage 7.0 K 2007-12-03 - 19:04 IsaacTo Refactoring for the Render.pm file for tweakline=2 mode
Unknown file formatEXT LatexModePlugin_installer r1 manage 3.3 K 2008-08-21 - 05:45 TerryRankine updated installer based on tools/extener.pl
Texttxt debug.txt r1 manage 6.8 K 2007-11-16 - 16:22 FrancescoPretto Debug informations, "Latex rendering error"
PNGpng mimetex-ex.png r1 manage 29.2 K 2006-12-30 - 00:47 ScottHoge example comparing mimetex output with dvipng and dvips
Unknown file formattex pdf_twiki_math.tex r1 manage 0.9 K 2007-11-16 - 16:21 FrancescoPretto Debug informations, "Latex rendering error"
Unknown file formattex twiki_math.tex r1 manage 2.0 K 2007-11-16 - 16:14 FrancescoPretto Debug informations, "Latex rendering error"
Edit | Attach | Watch | Print version | History: r235 < r234 < r233 < r232 < r231 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r235 - 2008-10-27 - ScottHoge
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.