Hello,
I was annoyed that the LaTeX equation insert mechanism didn't provide a way to control the size of the equation. This makes it needlessly difficult to match the size of the text in the body of a LaTeX document. So I modified that extension. Attached is a revised version that:
(a) Allows scaling by a specified factor; (b) Allows typesetting non-equations; (c) Allows customizing the preamble to the LaTeX document; (d) Properly scales the input using the 'viewBox' attribute, rather than relying on the structure of the document; and (e) Uses pdf2svg ( http://www.cityinthesky.co.uk/pdf2svg.html ) rather than pstoedit.
On point (e), pdf2svg seemed more reliable to me, though YMMV. I can easily switch it back to pstoedit, although it's harder to control just where the resulting formula ends up.
For point (c), I was annoyed by the very limited UI options: it seems hard to either embed newlines in the preamble or give a sufficiently large input area. Is there any hope of fixing this?
I could, I guess, have different input boxes for different lines, but that's really horrendously clunky.
Any comments are welcome. Of course I'd like to see a version of this in the next release, if possible.
Best, Dylan Thurston Assistant Professor, Barnard College
A few days ago I posted a revised LaTeX equation renderer. I don't know if anyone has taken a look at it yet, but there was a rather odd bug, that only shows up when you render more than one equation.
The program 'pdf2svg' uses the poppler and cairo libraries to produce SVG, and the SVG that it produces uses hrefs; these tags conflict with each other when I try to import more than one of them. Does Inkscape have a proper, approved way to include one SVG file in another that takes care of renaming node ids and hrefs to prevent overlap?
For instance, here is a somewhat abbreviated version of the SVG file for $\alpha_1$:
------------------------------------------------------------ <?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="11pt" height="8pt" viewBox="0 0 11 8" version="1.1"> <defs> <g> <symbol overflow="visible" id="glyph0-0"> <path style="stroke:none;" d=""/> </symbol> <symbol overflow="visible" id="glyph0-1"> <path style="stroke:none;" d="M 5.53125 -3.03125 C 5.53125 -4.1875 4.875 -5.265625 3.609375 -5.265625 [...] "/> </symbol> <symbol overflow="visible" id="glyph1-0"> <path style="stroke:none;" d=""/> </symbol> <symbol overflow="visible" id="glyph1-1"> <path style="stroke:none;" d="M 2.5 -5.078125 C 2.5 -5.296875 2.484375 [...] "/> </symbol> </g> <clipPath id="clip1"> <path d="M -139 722 L 456.277344 722 L 456.277344 -119.890625 L -139 -119.890625 L -139 722 Z M -139 722 "/> </clipPath> </defs> <g id="surface0"> <g clip-path="url(#clip1)" clip-rule="nonzero"> <g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> <use xlink:href="#glyph0-1" x="-0.372" y="6.123"/> </g> <g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> <use xlink:href="#glyph1-1" x="7.073" y="7.916"/> </g> </g> </g> </svg> ------------------------------------------------------------
This creates symbols 'glyph0-1' and 'glyph1-1' (one for the '\alpha' and one for the '1'), and then uses them both via hrefs. If I import another equation, it will also define 'glyph0-1', probably differently, and Inkscape will randomly pick which symbol to refer to.
Any comments or advice are welcome.
In any case, attached is a version of the scripts that uses pstoedit, which produces SVG files without this issue. (However, it also gets the bounding box wrong, which will make life difficult later.)
Best, Dylan Thurston
I have actually checked it, but I couldn't use it, since I'm on Windows. I assume pdf2svg and pdfcrop dependencies are the following:
http://www.cityinthesky.co.uk/pdf2svg.html http://pdfcrop.sourceforge.net/
Anyway, this version (with pstoedit) works good. Finally I don't have to manually scale all the equations. Now the only thing, which is missing is, that double clicking the equation would open the window for extension settings so that you could basically edit the equation...
However, I was wondering if it was possible to simply use Inkscape's internals to import PDF generated by LaTeX. That would leave only LaTeX as dependency.
Otherwise a really nice improvement.
Best regards, Rok
On Mon, Sep 6, 2010 at 8:22 PM, Dylan Thurston <dthurston@...2401...>wrote:
A few days ago I posted a revised LaTeX equation renderer. I don't know if anyone has taken a look at it yet, but there was a rather odd bug, that only shows up when you render more than one equation.
The program 'pdf2svg' uses the poppler and cairo libraries to produce SVG, and the SVG that it produces uses hrefs; these tags conflict with each other when I try to import more than one of them. Does Inkscape have a proper, approved way to include one SVG file in another that takes care of renaming node ids and hrefs to prevent overlap?
For instance, here is a somewhat abbreviated version of the SVG file for $\alpha_1$:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink=" http://www.w3.org/1999/xlink" width="11pt" height="8pt" viewBox="0 0 11 8" version="1.1">
<defs> <g> <symbol overflow="visible" id="glyph0-0"> <path style="stroke:none;" d=""/> </symbol> <symbol overflow="visible" id="glyph0-1"> <path style="stroke:none;" d="M 5.53125 -3.03125 C 5.53125 -4.1875 4.875 -5.265625 3.609375 -5.265625 [...] "/> </symbol> <symbol overflow="visible" id="glyph1-0"> <path style="stroke:none;" d=""/> </symbol> <symbol overflow="visible" id="glyph1-1"> <path style="stroke:none;" d="M 2.5 -5.078125 C 2.5 -5.296875 2.484375 [...] "/> </symbol> </g> <clipPath id="clip1"> <path d="M -139 722 L 456.277344 722 L 456.277344 -119.890625 L -139 -119.890625 L -139 722 Z M -139 722 "/> </clipPath> </defs> <g id="surface0"> <g clip-path="url(#clip1)" clip-rule="nonzero"> <g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> <use xlink:href="#glyph0-1" x="-0.372" y="6.123"/> </g> <g style="fill:rgb(0%,0%,0%);fill-opacity:1;"> <use xlink:href="#glyph1-1" x="7.073" y="7.916"/> </g> </g> </g> </svg> ------------------------------------------------------------
This creates symbols 'glyph0-1' and 'glyph1-1' (one for the '\alpha' and one for the '1'), and then uses them both via hrefs. If I import another equation, it will also define 'glyph0-1', probably differently, and Inkscape will randomly pick which symbol to refer to.
Any comments or advice are welcome.
In any case, attached is a version of the scripts that uses pstoedit, which produces SVG files without this issue. (However, it also gets the bounding box wrong, which will make life difficult later.)
Best, Dylan Thurston
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
On Mon, Sep 06, 2010 at 08:58:36PM +0200, Rock Star wrote:
I have actually checked it, but I couldn't use it, since I'm on Windows. I assume pdf2svg and pdfcrop dependencies are the following:
http://www.cityinthesky.co.uk/pdf2svg.html http://pdfcrop.sourceforge.net/
Yes, those are the dependencies. I didn't think to check if they were available on Windows; sorry. (But I think it should be possible to get them to run on windows without too much problem.)
Anyway, this version (with pstoedit) works good. Finally I don't have to manually scale all the equations. Now the only thing, which is missing is, that double clicking the equation would open the window for extension settings so that you could basically edit the equation...
Yes, that would be nice, but I think it's a more general Inkscape issue: Inkscape would have to store information about how an object was created (which extension, what parameters, etc.) I could see this being useful for several other plugins, as well.
However, I was wondering if it was possible to simply use Inkscape's internals to import PDF generated by LaTeX. That would leave only LaTeX as dependency.
One problem is the fonts. When I try to open a LaTeX'd PDF document in Inkscape, I get totally wrong fonts. This is probably fixable on my system, but I don't think we want to count on people having the appropriate version of the Computer Modern fonts installed.y
Otherwise a really nice improvement.
Thanks!
--Dylan
participants (2)
-
Dylan Thurston
-
Rock Star