Categories: Uncategorized<< | Page list | >>
Figures in LyX
How LyX handles figures
LyX has the ability to handle literally any graphics format in the known
universe so long as a conversion path from this graphics format to the
target output format can be created. If that sounds a little obtuse, consider how LyX handles Encapsulated PostScript® figures. LaTeX provides native support for this format, so LyX needs do nothing other than use the
To view the figure on the LyX screen, however, some additional work is required because neither the XForms nor the Qt GUI libraries can load PostScript® figures themselves. Thus, LyX must initiate a conversion from Encapsulated PostScript® to a loadable graphics format.
The XForms library can load figures in the following, widely used, graphics formats:
lyx -dbg graphics
If you're having problems with your figures, then it's almost certain that the reason why things are going wrong can be found in the output generated by the above command.
To view the figure on the LyX screen LyX must initiate a conversion from Encapsulated PostScript® to a loadable graphics format. It does this using the powerful, configurable converters mechanism exposed in the Converters section of the Edit→Preferences dialog. Adding a new converter will result in a line like
\converter "eps" "png" "my_ps2png $$i $$o" ""
being added to your
If LyX cannot create a conversion path (which might have many steps) from Encapsulated PostScript® to one of the loadable formats listed above, then it defaults to the use of a shell script
If, after all that, LyX still cannot load the figure, then it'll tell you so with a message "Error converting to loadable format" in place of an on-screen view of your figure. If you're presented with such a message, then you'll need to augment the list of known converters.
An example (for Mac OS X) of add EPS->PNG converter if "Error converting to loadable format" appears in Lyx on-screen view after insert a EPS graph.
Step 1: The idea is using external image conversion tool ImageMagick to convert from EPS to PNG. Then the first step is to install ImageMagick if ImageMagick has not been installed. After installation, check if the converter eps to png works properly by typing "covert /path/test.eps /path/test.png" in terminal (for Mac OS X).
Step 2: Add EPS to PNG converter in Lyx following Lyx->Preferences->File Handling->Converters. Choose EPS->PDF and change the 'to format' from PDF to PNG. In the converter line, type "convert $$i $$o" and then press add and save.
Step 3: Add the path where the convert command is located to Lyx. Such as /opt/ImageMagick/bin (for Mac OS X). Go to Lyx>Preferences>Paths>Path prefix add :/opt/ImageMagick/bin to the end of the paths. Save the paths and exit Lyx.
Step 4: Run Lyx again and open the file containing eps figures should display png figures in preview.
Problems loading PDF graphics
If you see the "Error converting to loadable format" message only with PDF files and you've verified that you have the converter tools mentioned above, check which version of GhostScript you are using. Version 8.7 has a known bug that prevents LyX from loading PDFs. Upgrade to Version 9, or do the following workaround:
if sys.argv[:4] == 'pdf:' and (version >= 0x060206 or gm): opts = '-define pdf:use-cropbox=true ' + opts
(If you're experiencing problems with previews after upgrading, you may wish to try to reset your personal settings. The default settings typically work fine, but seem to change over time...) Uncategorized
Problems loading PDF graphics #2:
If you see the "Error converting to loadable format" message only with PDF files : the problem may be ImageMagick's version (7), and its incompatibility with LyX conversion scripts, as mentioned here (https://firstname.lastname@example.org/msg194142.html). If you are using brew, you can fix this problem by removing imagemagic and installing the latest 6.x version: imagemagick@6 and then creating a symbolic link (in /user/local/bin) pointing to /usr/local/Cellar/imagemagick\@6/6.9.7-5/bin/convert .