Edit Links |
Tips /
UseInkscapeSVGImages
<< Using LyX with Tgif | Page list | WordCount >>
As of version 1.6.6 LyX directly supports SVG files - only librsvg or Inkscape needs to be installed on your computer. To enable the default support on Windows, edit preferences and add the path to Inkscape to the paths section (it appears that the path entry may be case sensitive, so use the correct letter casing on the path, even on Windows). Then use Tools | Reconfigure. If you open up the Converters preference again, you should see new entries there for SVG to PNG, SVG to EPS, and SVG to PDF. Once you have them, everything should work fine. You do NOT have to add the converters yourself; they will be automatically added when LyX detects Inkscape on the path during a reconfigure operation. If they're not there, check the path you entered and ensure that you have matched the case perfectly, and that the target directory exists, and that inkscape.exe is there. Include SVG Images in LyXThe are three possibilities based on Inkscape, Apache Batik and librsvg. Please read details below about first of these two techniques. InkscapeInkscape from http://www.inkscape.org/ can be used to configure LyX to directly include .svg images and automatically generate PNG preview images in LyX, PDF for pdflatex, and EPS for latex. Just add an SVG file type and conversion rules as described below (this is #3349 enhancement request in LyX's Trac.) I use those settings for several months now and I am very happy with that solution, because inkscape is a great tool to draw vector graphics with and I don't have to keep the eps files up to date manually to match the svg files - LyX does that for me! Another great thing is, that Inkscape exports text to eps as a whole and not single characters (you may not resize text blocks with the mouse to be sure about that). This is useful for psfrag.
WindowsWhen installing LyX using the alternative installer, Inkscape is automatically used to convert and display SVG images. Alternatively you can add support for SVG manually:
Finally you need to reconfigure LyX. LinuxYou can configure LyX in a few steps:
In my experience, this is the only configuration change that is truly necessary to make LyX-1.6.1 work together with SVG and Inkscape. The Converter options described below are not strictly necessary, but they may improve the quality of output obtained in pdf and postscript. These settings may make a difference because Inkscape might generate more suitable pdf or eps output.
The following steps add these lines in the CONVERTERS section of $/.lyx/preferences
\converter "svg" "eps" "inkscape $$i --export-eps=$$o" ""
\converter "svg" "png" "inkscape $$i --export-png=$$o" ""
\converter "svg" "pdf" "inkscape --export-area-drawing $$i --export-pdf=$$o" ""
You need to restart and maybe reconfigure LyX. MacOS XUnder MacOS X, it should work just as described in the Linux section. You need to provide the full path to the Inkscape executable, on my system, this is: /Applications/Multimedia/Inkscape.app/Contents/Resources/bin/inkscape because I have Inkscape.app installed in /Applications/Multimedia. Hints
You can also use convert with Windows. Replace "inkscape PNG" with "convert" in the converter section.
Make sure you do not use the
-T (--export-text-to-path) option when converting from SVG to EPS with Inkscape. Likewise, when exporting figures by hand via the Inkscape GUI, the checkbox labeled "Convert text to path" should be unchecked. See the Inkscape manual page for details.
Get the right sizeIf the SVG is converted to EPS, the size of the resulting graphic is automatically set to the size of the content.
For both, bitmap and PDF output, by default the size is set to the "paper-size" of the canvas (letter or A4).
In order to get a graphic that can be input in a LyX document,
the Inkscape drawing must be sized right. Either add
Correction 18/05/08: setting the figure size in Inkscape's File->Document_Properties seems to be mandatory, while the Correction 11/25/09: Categories |