Allow pdf+latex export to make use of textext latex-sourcecode

Bug #727463 reported by Mark Edgington
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
In Progress
Wishlist
Håkon Marthinsen

Bug Description

The textext inkscape extension makes it possible to create 'latex' objects, which appear as rendered paths, but also possess the original LaTeX source metadata (which can be re-edited). It would be beneficial, when this extension is used, for Inkscape's pdf+latex export option to be smart about the metadata stored in these textext objects, and only place the source in the text overlay file (instead of the textext-rendered SVG graphics). Perhaps better would be to provide an additional switch/option which allows one to choose whether or not the textext sourcecode gets used in the pdf+latex output overlay file.

This offers two advantages: (1) the LaTeX is rendered on the canvas, so you see what the end-product really looks like, and (2) it allows "Export bitmap" to end up generating something that is visually the same as "export pdf+latex".

Currently, in order to create "x-squared" in the exported pdf+latex file, one needs to use an SVG text object containing $x^2$. This LaTeX code renders correctly with pdf+latex export, but remains unrendered if you export to a bitmap or print the SVG.

'Tex Text' Inkscape extension:
<http://pav.iki.fi/software/textext/>

su_v (suv-lp)
tags: added: exporting latex
Changed in inkscape:
importance: Undecided → Wishlist
description: updated
Revision history for this message
su_v (suv-lp) wrote :

Do you know if 'Tex Text' is still actively developed or maintained? (It's latest stable version (0.4.4) was based on Inkscape 0.46, and as far as I know (not using it myself), it doesn't work out-of-the-box with newer Python and/or Inkscape versions. The development repository hasn't seen recent activity either).

Revision history for this message
Mark Edgington (edgimar) wrote :

Seems to work fine (under Linux at least) on 0.48. I am using a version from the repository on bitbucket (https://bitbucket.org/pv/textext). (One small issue is that in Ubuntu Lucid, pstoedit is currently broken -- always segfaults).

But maybe just incorporating textext's functionality directly into Inkscape would make sense... (where it uses the code from the existing LaTeX renderer extension).

Revision history for this message
Håkon Marthinsen (hakonm) wrote :

I would also very much like this feature in Inkscape.

This would also make it possible to resize the resulting image from the LaTeX document without affecting the size of the LaTeX text in the image. Furthermore, it would be possible to change the font type and size without having to regenerate the image.

I have made a very crude patch/hack that works for me, but I'm afraid my code is not very good. (I'm unfamiliar with Inkscape's internals.) However, the fact that I managed to do it shows that it should be very easy for a programmer that is familiar with Inkscape.

Revision history for this message
Grumbel (dr-khong) wrote :

textext seems unsopported for latest versions of Inkscape. At least for windows, one needs to edit its source and add some libraries to make it work.

Still, such a feature would be highly appreciated. Right now, the workflow for including SVGs in PDF-LaTeX documents (using the Save-As-PDF feature of inkscape) produces high quality vector drawings. textext can be used to include formulars (often just labelling symbols) with the same font and format as in the LaTeX-document.

However, an elegant way of also ensuring the same font size as in the LaTeX-document would be highly appreciated. Håkon, would you like to maybe publish your code here, so others can use it or maybe include it in Inkscape?

Revision history for this message
Håkon Marthinsen (hakonm) wrote :

I'm sorry, I forgot about this bug. I have lost my modifications, but I'll try to replicate what I had and post it here.

Revision history for this message
Håkon Marthinsen (hakonm) wrote :

I've thought a bit more about this and I think the best thing to do is to make a new extension that does the desired PDF+LaTeX export. Here is the spec that I'm going to implement:

Inkscape Output extension: TexText -> PDF + LaTeX
-------------------------------------------------

INTRODUCTION:
The purpose of this extension is to export TexText objects as real LaTeX code, not just paths. This way, the typeface can be changed from the LaTeX document without having to regenerate all the TexText objects inside the figure in Inkscape. It also ensures consistency with the fonts used in the rest of the LaTeX document, and furthermore, it is possible to cross-reference other parts of the document from within the figure.

PREREQUISITES AND LIMITATIONS:
* Scale factor in TexText objects must be 1.25.
* LaTeX code in TexText objects must be in horizontal mode or math mode. I.e. no $$...$$ or \[...\], or whole paragraphs of text are allowed. For simulated displayed math, use $\displaystyle ...$.
* Only rotations, flat fill color and opacity are exported to LaTeX. All other effects and transformations are ignored.

CONVERSION ALGORITHM:
Make a temporary copy of the SVG drawing. All operations below are on the copy.
for each TexText object OBJ do
 Find basepoint coordinates of OBJ.
 Create text object containing the original LaTeX code.
 Move text object inside OBJ group.
 Substitute x and y attributes of the text with basepoint coordinates.
 In the style attribute of the text, replace fill, opacity and fill-opacity with the ones from the OBJ group.
 Delete the style attribute for the OBJ group.
 Delete group containing paths.
end for
Save as PDF+LaTeX with "Export area as page" checked.
Delete temporary copy of SVG drawing.

FIND BASEPOINT ALGORITHM:
Prefix LaTeX code with "\rlap{\rule{.00001pt}{.00001pt}}".
Regenerate TexText object.
Enter group containing the paths.
Return the final two numbers of the matrix in the transform attribute of the path object corresponding to the inserted invisible dot.

Revision history for this message
Håkon Marthinsen (hakonm) wrote :

And here is the result. Unpack the two extension files to ~/.config/inkscape/extensions and restart Inkscape. This will add an entry in Extensions > Export. Please note the assumptions and limitations noted in the spec in my previous post.

Let me know if it doesn't work.

This is my first contribution to an open source project, so I'm not sure how to proceed from here. All comments are welcome!

Changed in inkscape:
status: New → In Progress
assignee: nobody → Håkon Marthinsen (hakonm)
Revision history for this message
Håkon Marthinsen (hakonm) wrote :

I updated the extension to control file output better. The script will now show a save dialog for the pdf file. I have tested the script under Linux with pdf2svg installed. It will probably not work on other platforms (yet) since the file chooser depends on GTK.

Revision history for this message
Håkon Marthinsen (hakonm) wrote :
Revision history for this message
Håkon Marthinsen (hakonm) wrote :

The new extension now has its own Launchpad home page. See

https://launchpad.net/svgtextext-to-pdflatex

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.