Combined PDF/LaTeX export

Bug #172022 reported by Nct-users
26
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
Johan Engelen

Bug Description

If would be very nice if Inkscape could export in combined PDF/LaTeX as
XFig does. That way, graphics got exported in PDF and text as latex source,
positioned in overlay over the PDF graphics.

The lack of this feature keep at least several people from switching from
XFig to Inkscape.

Thanks, have a nice day.

Revision history for this message
Bug Importer (bug-importer) wrote :

May be by using latex's macro : PGF and TikZ ?

Revision history for this message
Bug Importer (bug-importer) wrote :

It might work, but I'm not sure PGF/TiKZ support advanced svg features
such as gradient including alpha. PDF 1.4 does. This is the rationale of my
suggestion.

nightrow (jb-benoit)
Changed in inkscape:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Tom Davidson (tjd-mit) wrote :

For reference, discussion of the use of PGF macros for latex export is at bug 172195

Revision history for this message
yannLC (yannlaiglechapuy) wrote :

if anyone find this usefull, here is a small tool to convert an inkscape svg file into a pdf_t and a pdf.
http://www-rocq.inria.fr/secret/Yann.Laigle-Chapuy/index.php?lg=fr&pg=ink2pdf_t

Revision history for this message
Richard Henwood (rjhenwood) wrote :

You may also want to have a look at an extension I wrote:
http://richard.henwood.googlepages.com/inkscapelatexextension

Revision history for this message
Oni (oni-lore) wrote :

I've written an extension too that is able to save the LaTeX file like xfig. The bad news is that you have to manually save the .tex file and the .pdf file:

1-- Draw something
2-- Save the LaTeX file with my extension (produces <filename>.tex)
3-- Delete all text from the drawing
4-- Save the PDF file (produces <filename>.pdf)

Now the question: is it possible to automate the process? The script itself can handle step 2 and 3. But I have no idea how to make inkscape save a PDF file after the LaTeX one.

Inkscape should warn the user if <filename>.tex or <filename>.pdf or both already exist and ask if he/she wants to overwrite them. Any clues?

Here it is the link to my script: http://github.com/Oni/svg2tex/tree/master (you don't need git: just hit "download"). There also is a doc file that explains how to install and use it.

Revision history for this message
Richard Henwood (rjhenwood) wrote : Re: [Bug 172022] Re: Combined PDF/LaTeX export

--- On Mon, 8/12/08, Oni <email address hidden> wrote:

> From: Oni <email address hidden>
> Subject: [Bug 172022] Re: Combined PDF/LaTeX export
> To: <email address hidden>
> Date: Monday, 8 December, 2008, 3:54 PM
> I've written an extension too that is able to save the
> LaTeX file like
> xfig. The bad news is that you have to manually save the
> .tex file and
> the .pdf file:
>
> 1-- Draw something
> 2-- Save the LaTeX file with my extension (produces
> <filename>.tex)
> 3-- Delete all text from the drawing
> 4-- Save the PDF file (produces <filename>.pdf)
>
> Now the question: is it possible to automate the process?
> The script
> itself can handle step 2 and 3. But I have no idea how to
> make inkscape
> save a PDF file after the LaTeX one.
>
> Inkscape should warn the user if <filename>.tex or
> <filename>.pdf or
> both already exist and ask if he/she wants to overwrite
> them. Any clues?
>

Hi Oni,

My current thoughts on this is that the whole process would be best handled by an external script.

Such a script could make a tempory file with text deleted and subsequently call 'inkscape --export-pdf=FILENAME' do to the PDF bit of the export.

I arrived at this conclusion after I experienced difficulties maintaining my plugin as Inkscape iterates versions.

Alternatively, if you could write a 'save as' object for Inkscape, and get it into the codebase with good test coverage - then that would be excellent (and would probably maintain it's self.

I didn't get very far with that approach though...

please let me know if you make any progess - I watch the launchpad bug report...

best wishes,
Richard

Revision history for this message
Oni (oni-lore) wrote :

There is a problem with the first approach (external script).

When you hit save, inkscape creates a temp file that is passed to the script. The script can process it (of course) and then writes the final result in standard output.

Inkscape saves that into the proper file.

So, as far as I know, the problem is simple: the script doesn't know the final file name and destination. It's only aware of the temp file with a fuzzy name (like "xcYecvVFS.svg"). So it cannot save a PDF file with the same name and in the same directory of the final TEX file.

But I think that this problem could be solved by the inx file. Maybe it's possible to say "run svg2tex and save FILE.tex" then, "run PDF exporter and save FILE.pdf". Maybe it can be done with multiple command tags. I couldn't find useful (and complete) documentation around the inx files. All I did so far was reverse engineering existing inx files. But none of them are facing my "dual saving" problem. Also I don't know if it's possible to run the PDF exporter from a command tag.

Regarding the second approach: I don't know much about C++ so I'd like to solve the problem using the first approach for now.

I'm going to learn more about inx files and do some tests.

Revision history for this message
Richard Henwood (rjhenwood) wrote :

--- On Sat, 13/12/08, Oni <email address hidden> wrote:

> From: Oni <email address hidden>
> Subject: [Bug 172022] Re: Combined PDF/LaTeX export
> To: <email address hidden>
> Date: Saturday, 13 December, 2008, 3:36 PM
> There is a problem with the first approach (external
> script).
>
> When you hit save, inkscape creates a temp file that is
> passed to the
> script. The script can process it (of course) and then
> writes the final
> result in standard output.
>
> Inkscape saves that into the proper file.
>
> So, as far as I know, the problem is simple: the script
> doesn't know the
> final file name and destination. It's only aware of the
> temp file with a
> fuzzy name (like "xcYecvVFS.svg"). So it cannot
> save a PDF file with the
> same name and in the same directory of the final TEX file.
>
> But I think that this problem could be solved by the inx
> file. Maybe
> it's possible to say "run svg2tex and save
> FILE.tex" then, "run PDF
> exporter and save FILE.pdf". Maybe it can be done with
> multiple command
> tags. I couldn't find useful (and complete)
> documentation around the inx
> files. All I did so far was reverse engineering existing
> inx files. But
> none of them are facing my "dual saving" problem.
> Also I don't know if
> it's possible to run the PDF exporter from a command
> tag.
>
> Regarding the second approach: I don't know much about
> C++ so I'd like
> to solve the problem using the first approach for now.
>
> I'm going to learn more about inx files and do some
> tests.

Learning about inx file will be helpful I feel like what I would really want should be doable with enough knowlege of inx...

To clarify; my typical workflow is:
1: draw picture in inkscape, save as inkscapeSVG.
2: include picture in latex document.
3: decide that picture isn't quite right and tinker with it.

...my requirements are specific to my work-flow. Once I have a picture saved from Inkscape in svg, it would be great if I could repeatedly regenerate a version of it which (pdf)latex could ingest.

In this scenario, a solution to is re-save my picture file after tinkering with it in inkscape, run an external script to generate a '*.tex' and corresponding '*.[eps|pdf]' and then run 'pdflatex mydoc.tex'.

so I envisage a external script which would be (manually) run after I press 'save' in inkscape and before I type 'pdflatex mydoc.tex'.

Revision history for this message
Oni (oni-lore) wrote :

Ok, I did some research on INX files. The doc files says more than once that extensions can be chained. After some testing (since that point isn't discussed anywhere AFAIK) I've found out that the "helper_extension" tag inside "script" tag lets you do that.

But the problem is always the same: the output of the first extension is used as the input of the second one etc. Finally everything is printed in a single (and unknown to the script) file.

Long story short, I'm now pretty sure that the only solution would be editing Inkscape internals. But I'm not a C++ programmer, so I can't do that.

By the way my extension can be used as a standalone script. There is a doc file that explains how to use it. It's also quite useful for batch processing files.

Revision history for this message
JS (j5) wrote :

Just a comment regarding the workflow issues. I would like to point out that using an external tool (fig2dev) works great with Xfig. My typical workflow is this:

1. Edit the figure in Xfig.

2. Save the *.fig file in Xfig by hitting alt-S.

3. Re-run "rubber -Wall foo.tex".

That's all. Rubber takes care of running fig2dev for all figures that have changed (with suitable command line flags, to produce, e.g., a pair of pdf + pdf_t files for each *.fig file that has changed) and running pdflatex or whatever is needed. (Naturally you could write Makefiles for that as well.) The final PDF version of the document is updated. And then a decent PDF viewer such as Evince automatically re-loads the PDF file. Edit-compile-preview cycle takes just a second.

I do not see why this couldn't work with Inkscape equally well. You do not need Inkscape extensions or special export formats or anything. All that is needed is a good command-line tool; integrating the command-line tool with other tools (such as rubber) is not that hard.

Revision history for this message
Richard Henwood (rjhenwood) wrote :

A small update: I've decoupled my script so it runs 'stand-alone'. However, it still depends on an external program (Inkscape) to render the SVG into PDF.

./svg2latex.py -f ./drawing.svg -l ./drawing.tex
will convert drawing.svg to drawing.tex and drawing.pdf.

I was not familiar with rubber until now, and as you say, the rule files look simple enough. When I next write something in latex I'll give it a try and look into writing a rule for my script.

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

I have added an option to PDF/EPS/PS save dialog that does what is described here.
Please read this PDF document describing the new feature. It also includes text on how to automate this, such that you can tinker the image in inkscape, save it, rerun latex and have the image automatically exported to pdf/latex again, etc.
http://wiki.inkscape.org/wiki/images/SVG_in_LaTeX.pdf

Changed in inkscape:
status: Confirmed → Fix Committed
assignee: nobody → Johan Engelen (johanengelen)
Revision history for this message
Alex Valavanis (valavanisalex) wrote :

This feature was added in Inkscape 0.48

Changed in inkscape:
milestone: none → 0.48
status: Fix Committed → Fix Released
su_v (suv-lp)
tags: added: latex
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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