Latex formula does not work on Ubuntu Hardy

Bug #195052 reported by xylo
This bug report is a duplicate of:  Bug #55273: inkscape generates no latex formula. Edit Remove
12
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Undecided
Johan Engelen
inkscape (Fedora)
Fix Released
Unknown
inkscape (Ubuntu)
Confirmed
Low
Kees Cook

Bug Description

The latex formula extension does not work on Ubuntu Hardy. When I try to render the formula "$1-2$" a popup appears and says:
"Inkscape has received additional data from the script executed. The script did not return an error, but this may indicate the results will not be as expected."
And in the text field there is:
"pstoedit: version 3.45 / DLL interface 108 (build Nov 28 2007 - release build - g++ 4.2.3 20071123 (prerelease) (Ubuntu 4.2.2-3ubuntu4)) : Copyright (C) 1993 - 2007 Wolfgang Glunz"

CPU consumption is at 0%. Inkscape is just waiting for a click on the OK button.

The problem causing this popup is that pstoedit is printing to stderr instead of stdout.

If I change the following line in "eqtexsvg.py"
  os.system('pstoedit -f plot-svg -dt -ssp ' + ps_file + ' ' + svg_file + '> ' + out_file)
to
  os.system('pstoedit -f plot-svg -dt -ssp ' + ps_file + ' ' + svg_file + ' 2>&1 > ' + out_file)
the popup window does not appear anymore, but I still cannot see a formula in inkscape.

I've also changed the following lines ("#" inserter) to see what output files are generated:
            #os.remove(latex_file)
            #os.remove(aux_file)
            #os.remove(log_file)
            #os.remove(ps_file)
            #os.remove(dvi_file)
            #os.remove(svg_file)
            #os.remove(out_file)
            #os.rmdir(base_dir)

And everything looks fine. The eq.svg is created and contains my formula. Why is Inkscape not importing the file?

My system:
Ubuntu Hardy
Python 2.5.2a0
python-lxml 1.3.6-1
pstoedit: version 3.45 / DLL interface 108 (build Nov 28 2007 ...
Inkscape 0.45.1+0.46pre1, built Feb 20 2008

See also
  bug 179770 - latest changes to the extension interface
  bug 194310 - problem on Windows XP

Aaron C Spike (acspike)
Changed in inkscape:
assignee: nobody → acspike
Revision history for this message
Aaron C Spike (acspike) wrote :

' 2>&1 > ' + out_file

You don't want to do that. That redirects stderr into stdout. out_file is now an invalid SVG file with whatever pstoedit bits thrown in. If pstoedit has a --quiet option or something similar this would be better.

Inkscape is designed to return stderr from an extensions in that popup. This aids greatly in debuging. Please trust that the popup is not prohibiting the extension from working.

I'm not sure I'll be able to troubleshoot this issue because I have the problem with 100% cpu usage on gusty.

Revision history for this message
xylo (stefan-endrullis) wrote :

out_file isn't used as svg file. There is also a svg_file which is returned to Inkscape at the end of the script. It doesn't matter if you redirect any output stream of pstoedit to a file.

But OK, all files are generated properly. The problem seems to be the line
  svg_open(self, svg_file)
It's not crashing (print commands before and after this line worked) but I don't know if it's doing something. This is also the only extension using this command. Maybe thats the problem why only the latex extension is affected.

PS: Once I had also the problem of 100% CPU usage, but I forgot how to solve it. Maybe you need to update pstoedit to version 0.45, but I'm not sure.

Revision history for this message
xylo (stefan-endrullis) wrote :

For those who are able to produce the eq.svg file with the latex extension, I have attached my eq.svg (with formula "$1-2$").
If you can import them using
  svg_open(self, svg_file)
please tell me.

Revision history for this message
Aaron C Spike (acspike) wrote : Re: [Bug 195052] Re: Latex formula does not work on Ubuntu Hardy

Oh, sure enough. You are correct. But I still think redirecting stderr
could cause us to miss important info for debugging.

svg_open is defined at the beginning of the file. Perhaps we are
creating invalid svg?

Revision history for this message
Aaron C Spike (acspike) wrote :

thanks for the output, I'll see if I can get this working.

Revision history for this message
xylo (stefan-endrullis) wrote :

Yes, I have remove the "2>&1" for debugging purpose. I just wanted to point out, that pstoedit isn't the problem.

And thanks for the hint with svg_open. Haven't seen that it is defined at the beginning. I thought it would be a native function provided by Inkscape. So I will take a look at this method now.

I'm also not sure if this svg file is completely valid. Firefox and Konqueror can show the file.

Revision history for this message
xylo (stefan-endrullis) wrote :

OK, I think I've found the problem. The svg file is containing a default xmlns. And the xml library used to navigate through the file saves the name space of each tag in the tag name. If the old library version returned "svg" as node_in.tag, the new version is now returning "{http://www.w3.org/2000/svg}svg".

Is this a problem of python-lxml 1.3.6-1?

Revision history for this message
xylo (stefan-endrullis) wrote :

OK, it's not a problem. Other extensions like barcode or gears already now about the name space in the tag name and work correctly with it.
I have added the name space everywhere a comparison between a tag name and a string was made (most string look like '{http://www.w3.org/2000/svg}g' now).
Finally a group is added to the current layer, but I still cannot see the formula. No elements are added to the XML tree.

Revision history for this message
Tom Davidson (tjd-mit) wrote :

BTW, pstoedit does have a quiet mode: just pass the '-quiet'
argument... Important errors will still be output to stderr, but this
way you don't get that annoying copyright message everytime you run it
(this makes live preview quite useless, e.g.)

Revision history for this message
Stéphane Bonnet (bonnetst) wrote :

Indeed the script does not like the namespace to be prepended to each tag. I added some code to remove the namespace from the input tags before adding them to the group, and the LaTeX formula appears correctly. I know almost nothing about Python, so there must be a better way to do it, but it now works with the patch included. My version of pstoedit doesn't support the '-quiet' argument by the way, so I did not include Tom's idea.

Revision history for this message
xylo (stefan-endrullis) wrote :

Thanks for this patch! Now the formula also appears on my system. Thus removing the namespace is better than adding the namespace to all strings, because in my test the generated svg could not be imported automatically.

Revision history for this message
Kraftig (kraftig) wrote :

@Stéphane Bonnet:
Thanks for the patch, I REALLY need LaTeX equations in Inkscape. XD

@Tom Davidson:
My pstoedit (from the repos) also does not accept -quiet. :-(
Are you using the available 3.45? Or is there a trick? ;-)

Changed in inkscape:
status: Unknown → Fix Committed
Revision history for this message
milady (kami-amaterasu) wrote :

Hello,

I have almost the same problem on Fedora 8 with inkscape 0.46. The difference is that not only is the formula not included in the document, but there isn't any eq.svg in /tmp either.
Should I be looking elsewhere?

For the moment I switched back to inkscape 0.45, but I'd like to be able to use this in the current version.

Revision history for this message
xylo (stefan-endrullis) wrote :

@milady
If you apply Stéphane's patch, the latex extension should work with inkscape 0.46. And if you run the extension a temporary directory (something like /tmp/inkscape-zjafc1/) is created where you can also find the eq.svg.
To apply the patch, download the eqtexsvg.py.patch, go to the directory there the file eqtexsvg.py is located (on ubuntu it's /usr/share/inkscape/extensions) and run:
patch -p0 < eqtexsvg.py.patch

Revision history for this message
xylo (stefan-endrullis) wrote :

@milady
You're right. The temporary directory is removed after the operation. You can find the lines responsible for removing in eqtexsvg.py and comment them out as described in the bug description, but that's not necessary as the extension is working as expected with the patch.

Revision history for this message
xylo (stefan-endrullis) wrote :

I would like to change the status to "Fix Committed" but I'm unsure if the patch was already committed to the version control.

Changed in inkscape:
status: New → Confirmed
Revision history for this message
Aaron C Spike (acspike) wrote :

This hasn't been committed yet.

Revision history for this message
Johan Engelen (johanengelen) wrote :

I committed this to trunk and 046_release_branch as well.

Changed in inkscape:
assignee: acspike → johanengelen
status: Confirmed → Fix Released
Revision history for this message
milady (kami-amaterasu) wrote :

Youpi! It's working again!
Thanks for your comments and for the patch.

Revision history for this message
Kees Cook (kees) wrote :

Since Hardy is frozen for release, this isn't going to be fixed, I'm afraid. It will certainly get fixed for Intrepid, and will likely get included in a micro-release update, if that goes through SRU.

In the meantime, for people that want to fix it manually, do the following:

  cd /usr/share/inkscape/extensions
  curl -s 'http://launchpadlibrarian.net/12978623/eqtexsvg.py.patch' | sudo patch -p0

Changed in inkscape:
assignee: nobody → keescook
milestone: none → later
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
xtknight (xt-knight) wrote :

Here is a debdiff for Stéphane Bonnet's patch.

Changed in inkscape:
status: Fix Committed → Fix Released
Revision history for this message
John Dong (jdong) wrote :

Ok, since Hardy released, we need to do this as a SRU. xtknight, since you prepared a debdiff already, would you mind mangling the version to be SRU compliant and targeting it at hardy-proposed? I'll approve the SRU afterwards.

Revision history for this message
Rygle (rygle) wrote :

Hi guys, are you aware that there's a more complete patch happening in another bug? I think it includes everything from this patch and a bit more that has made it into SVN/dev versions since this patch. There is an updated ubuntu patch procedure based on the one Kees did on April 22 in the other bug.

https://bugs.launchpad.net/inkscape/+bug/55273

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.