Edit Links |
Tips /
UseInkscapeSVGImages
<< | Page list | >>
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. Note that as of version 2.0.0 LyX is capable of displaying SVGs without configuring Inkscape as converter (i.e. without doing the procedure above) but in some cases (e.g. SVG containing text, LyX running on Windows), the rendering will be buggy (see http://www.lyx.org/trac/ticket/7657). Using Inkscape as converter with the procedure described below solves the issues. Include SVG Images in LyXThe are three possibilities based on Inkscape, Apache Batik and librsvg(approve sites). 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.) Inkscape has to be in the PATH in order to have LyX automatically configure the right converters. MacOS X
Then the correct entries should be automatically added: SVG -> EPS inkscape --file=$$p/$$i --export-area-drawing --without-gui --export-eps=$$p/$$o SVG -> PDF (ps2pdf) inkscape --file=$$p/$$i --export-area-drawing --without-gui --export-pdf=$$p/$$o SVN -> PNG inkscape --without-gui --file=$$i --export-png=$$o
Editor: Custom: open -a Inkscape (Note the capital I is important. OS X will open the App with the -a option) Then you can right-click on an svg and choose "Edit externally...." If you encounter errors using the MacOS X integration, see the Correction of 13/05/16 near the bottom of this page. Inkscape Mac OSX SVG Converter WindowsYou 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. 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: Correction 13/05/16: On MacOS El Capitan (10.11), you may need to add the path to the inkscape binary (/Applications/Inkscape.app/Contents/Resources/bin) to your shell PATH environment variable. Also, confirm that the EPS, PDF and PNG conversion entries include both the path and file variables, for instance: --file=$$p/$$i. In at least some cases, this in missing the $pp/ as set up after the Reconfigure step described above. Categories |