Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

LyX /

FiguresInLyX

Categories: Uncategorized
<< | Page list | >>

Figures in LyX

How LyX handles figures

The LyX Team

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 \includegraphics LaTeX command to insert the figure in the final document.

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: bmp, gif, jpeg, pbm, pgm, ppm, tif, xbm whilst the Qt library can also handle mng, png and xpm format figures. This information and much more about the conversion process can be obtained by running LyX from the command line as

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 .lyx/preferences file. This line defines a converter from Encapsulated PostScript® to PNG format using the external program my_ps2png. The placeholders $$i and $$o are replaced by LyX by the names of the input and output files, respectively.

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 convertDefault.sh. This latter is a simple wrapper for ImageMagick's convert utility. Clearly, therefore, it can work only if you have convert installed and if convert can handle the conversion from one format to the other.

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:

  1. Find script convertDefault.py
  2. Edit the script and comment out two lines:
if sys.argv[1][:4] == 'pdf:' and (version >= 0x060206 or gm):
opts = '-define pdf:use-cropbox=true ' + opts

Reference: http://www.mail-archive.com/lyx-users@lists.lyx.org/msg80148.html

(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://www.mail-archive.com/lyx-devel@lists.lyx.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 .

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2017-01-23 20:43 UTC