Hello all,
For all who use LaTeX, please read the text below from the Release Notes 0.48. Or read http://wiki.inkscape.org/wiki/images/SVG_in_LaTeX.pdf . (the new feature will be available in development test builds from this evening on)
===New LaTeX export for PDF/EPS/PS===
Similar to GNUPlot's `epslatex' output terminal, Inkscape can now export graphics to PDF with an accompanying LaTeX file that overlays the text over the PDF when inputted in LaTeX. The image's text is typeset by LaTeX, so for example mathematical expressions are rendered correctly, and all text will be in the font and style of the LaTeX document (even when changing the document's font afterwards).
''(the following description assumes export to PDF, but will work the same for EPS and PS)'' Two files will be created: a PDF file containing all graphics, without text; and a LaTeX file with the same name, containing all text, and code to include the PDF and overlay the text. To include the exported image in LaTeX, one writes
\begin{figure} \centering \def\svgwidth{\columnwidth} % sets the image width, this is optional \input{image.tex} \end{figure}
A more thorough description of how to use the new feature (and automate the exporting/inclusion of the image in LaTeX) is given in this PDF: http://wiki.inkscape.org/wiki/images/SVG_in_LaTeX.pdf
====From the GUI==== When exporting to PDF/EPS/PS from Inkscape's GUI, the usual dialog pops up after selecting to which PDF/EPS/PS file to export to. In this dialog, you can find the PDF/EPS/PS+LaTeX option.
====Command line option==== When exporting to PDF/EPS/PS from the command line, adding --export-latex will turn the LaTeX export on. For example
inkscape image.svg -z -D --export-pdf=image.pdf --export-latex
Cheers! Johan Engelen
Hello Johan,
It is very nice to see this export option in Inkscape. Up till now I have been using svgfrags from the pydvi2svg package [1]. It processes all the <text> that appears in an SVG file according to some rules. I am using LyX to typeset LaTeX documents. LyX is able to display SVG files (I don't know whether internally by QT SVG support or externally with the aid of some converter) and has a nice feature called "File Handling", specifically "Converters". Whenever it encounters a non-native LaTeX file format, it looks for the converters defined for that type of file and then converts it to a native format. I have defined an "SVG to PS" converter and configured it to use Inkscape's --export- ps option. LyX also handles the "file changed" stuff. It keeps a cache of conversion results and updates it whenever the included file (image) changes. Basically my workflow was: 1. "$ some equation $" in Inkscape drawings. 2. Apply svgfrags.py to convert the equations by means of LaTeX->dvi->SVG conversions (relying on pydvi2svg). 3. Include the result into the LyX document. 4. Repeat step 2 everytime an image is changed.
I became quite used to this flow, but was considering writing another TeX Render extension using svgfrags, as it provided the possibility to massively convert LaTeX equations. This was something I need because I keep a library of basic figures (electronic components) which already have LaTeX text (equations), and it would be very tedious to convert manually every single LaTeX equation using the existing TeX render extension.
I tried to use your extension in LyX. Here are some difficulties I'm having:
- my LaTeX doesn't detect correctly whether or not "\svgwidth" is defined. It doesn't detect it as "@empty" when I don't define it. On the other hand testing it like this: "\ifx \svgwidth \undefined" works correctly. I don't really know much about LaTeX/TeX syntax/programming. Would it affect other users if you would use "\undefined" instead of "@empty" ? - my ps output differs from the pdf output. In my pdf output everything is ok, but in the ps output the text is shifted down. Is there something wrong with my LaTeX install (I use Ubuntu Jaunty packages) ? Or maybe for ps to work correctly I have to include some more packages? Actually this might also be related to the way LyX invokes LaTeX.... - is it right to undefine the "\svgwidth" variable (\global\ let \svgwidth @empty) ? I mean, if I set a global value (by putting at the beginning a "\def \svgwidth{...}", wouldn't it get reset after an "\input{some_file.tex}" (this is what happens to me - including twice the same drawing results in different sizes because "\svgwidth" is reset).
I added the necessary templates for LyX for using Inkscape's LaTeX export capability automatically. In the close future I could share in the wiki the necessary steps to configure LyX for this (or would it be better to do that on the LyX website?). Also, in LyX, you have the command "edit externally" for an image in the document, so it is quite comfortable to use, as it automatically invokes Inkscape (the sole unconvenience is that it loads quite slowly).
[1] http://wm.ite.pl/proj/pydvi2svg/index.html
Thank you, Arcadie Cracan
În data de Vineri 26 Februarie 2010 12:40:13 am J.B.C.Engelen@...1578... a scris:
Hello all,
For all who use LaTeX, please read the text below from the Release Notes 0.48. Or read http://wiki.inkscape.org/wiki/images/SVG_in_LaTeX.pdf . (the new feature will be available in development test builds from this evening on)
===New LaTeX export for PDF/EPS/PS===
Similar to GNUPlot's `epslatex' output terminal, Inkscape can now export graphics to PDF with an accompanying LaTeX file that overlays the text over the PDF when inputted in LaTeX. The image's text is typeset by LaTeX, so for example mathematical expressions are rendered correctly, and all text will be in the font and style of the LaTeX document (even when changing the document's font afterwards).
''(the following description assumes export to PDF, but will work the same for EPS and PS)'' Two files will be created: a PDF file containing all graphics, without text; and a LaTeX file with the same name, containing all text, and code to include the PDF and overlay the text. To include the exported image in LaTeX, one writes
\begin{figure} \centering \def\svgwidth{\columnwidth} % sets the image width, this is optional \input{image.tex} \end{figure}
A more thorough description of how to use the new feature (and automate the exporting/inclusion of the image in LaTeX) is given in this PDF: http://wiki.inkscape.org/wiki/images/SVG_in_LaTeX.pdf
====From the GUI==== When exporting to PDF/EPS/PS from Inkscape's GUI, the usual dialog pops up after selecting to which PDF/EPS/PS file to export to. In this dialog, you can find the PDF/EPS/PS+LaTeX option.
====Command line option==== When exporting to PDF/EPS/PS from the command line, adding --export-latex will turn the LaTeX export on. For example
inkscape image.svg -z -D --export-pdf=image.pdf --export-latex
Cheers! Johan Engelen
--- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
-----Original Message----- From: Arcadie Cracan [mailto:acracan@...400...] Sent: vrijdag 26 februari 2010 15:44 To: inkscape-devel@lists.sourceforge.net; Engelen, J.B.C. (Johan) Subject: Re: [Inkscape-devel] NEW: LaTeX export for PDF/EPS/PS
I tried to use your extension in LyX. Here are some difficulties I'm having:
- my LaTeX doesn't detect correctly whether or not
"\svgwidth" is defined. It doesn't detect it as "@empty" when I don't define it. On the other hand testing it like this: "\ifx \svgwidth \undefined" works correctly. I don't really know much about LaTeX/TeX syntax/programming. Would it affect other users if you would use "\undefined" instead of "@empty" ?
Indeed, I found the same problem today and also found your fix. It has been fixed now, thanks!
- my ps output differs from the pdf output. In my pdf
output everything is ok, but in the ps output the text is shifted down. Is there something wrong with my LaTeX install (I use Ubuntu Jaunty packages) ? Or maybe for ps to work correctly I have to include some more packages? Actually this might also be related to the way LyX invokes LaTeX....
I haven't tried EPS/PS export extensively, I'll look into it.
- is it right to undefine the "\svgwidth" variable
(\global\ let \svgwidth @empty) ? I mean, if I set a global value (by putting at the beginning a "\def \svgwidth{...}", wouldn't it get reset after an "\input{some_file.tex}" (this is what happens to me - including twice the same drawing results in different sizes because "\svgwidth" is reset).
Yes indeed. But this is done on purpose. I had to invent a way to specify the width of one image, without specifying the width of the next image. That is why the exported tex file contains code to "forget" the \svgwidth value. Consider the following situation:
\begin{figure} \def\svgwidth{10cm} \input(image.tex} \end{figure} Lots of text in between. \begin{figure} \input(image2.tex} \end{figure}
The width of image2 is not specified, hence the original width should be taken, and *not* 10cm.
Thanks for testing! Johan
-----Original Message----- From: J.B.C.Engelen@...1578... [mailto:J.B.C.Engelen@...1578...] Sent: vrijdag 26 februari 2010 22:25
-----Original Message----- From: Arcadie Cracan [mailto:acracan@...400...] Sent: vrijdag 26 februari 2010 15:44
- my ps output differs from the pdf output. In my pdf output
everything is ok, but in the ps output the text is shifted down. Is there something wrong with my LaTeX install (I use Ubuntu Jaunty packages) ? Or maybe for ps to work correctly I have to
include some
more packages? Actually this might also be related to the way LyX invokes LaTeX....
I haven't tried EPS/PS export extensively, I'll look into it.
I just tried, and for me EPS and PS both work fine, with good text alignment. (only the centred alignment looks a bit off)
Ciao, Johan
This extension sounds really cool :) I'll definitely give it a try in near future.
However, now the only thing I'd need is a way to define compression for JPEGs (or PNGs) when exporting to PDF. I often use Inkscape to annotate figures, which are then exported to PDF and used in LaTeX documents. And the problem is that exported PDFs with embedded bitmaps are really huge. OK, I usually solve the "problem" by running figures through ghostscript, where I can define compression etc., but it would be much handier if this step was not needed at all.
Thanks for this extension :)
Rok
I just tried, and for me EPS and PS both work fine, with good text alignment. (only the centred alignment looks a bit off)
I think I found the source of my problem:
** (inkscape:6043): WARNING **: EPS cannot have its bounding box extend beyond its content, so if your drawing is smaller than the page, --export-area-page will clip it to drawing.
Even when I export with the "-D" option the results are different for pdf and eps. I attach an example of an SVG drawing that produces different results (also attached).
How can this be fixed (aside from adding an invisible rectangle that would enclose the entire drawing)?
Cheers, Arcadie
On Sat, 2010-02-27 at 10:48 +0200, Arcadie M. Cracan wrote:
I just tried, and for me EPS and PS both work fine, with good text alignment. (only the centred alignment looks a bit off)
I think I found the source of my problem:
** (inkscape:6043): WARNING **: EPS cannot have its bounding box extend beyond its content, so if your drawing is smaller than the page, --export-area-page will clip it to drawing.
This is a "feature" of the Cairo library that is used for EPS export. We would need to convince the Cairo developers to add an option to set the bounding box larger than the drawing size. While they adhere to the letter of the standard, in practice it is much more useful (and normal in the software I have used) to be able to set the bounding box freely.
Even when I export with the "-D" option the results are different for pdf and eps. I attach an example of an SVG drawing that produces different results (also attached).
Maybe a bug.
How can this be fixed (aside from adding an invisible rectangle that would enclose the entire drawing)?
Workarounds for EPS export include exporting to PS then converting to EPS (simply changing the file extension from .ps to .eps may work) or editing the BoundingBox line in the EPS file.
Tav
participants (5)
-
unknown@example.com
-
Arcadie Cracan
-
Arcadie M. Cracan
-
Rock Star
-
Tavmjong Bah