Using EPS and SVG images

My blogging frequency has gone done drastically so I thought I will post something about a basic feature of ConTeXt, which might not be well known.

How do you include an EPS image in ConTeXt MkIV?

\externalfigure[filename]

ConTeXt does the conversion behind the scenes (using ghostscript).

And how do you include a SVG image?

\externalfigure[filename]

Again, ConTeXt does the conversion behind the scenes using inkscape.

In both cases, a m_k_i_iv filename.pdf file is created in the current directory.

You do not need to include the file extension. ConTeXt will automatically try eps and svg extensions. The order in which different file formats are tried are:

  • pdf (.pdf )
  • mps (.mps and .\d+)
  • jpg (.jpg and .jpeg)
  • png (.png )
  • jbig (.jbig, .jbig2, and .jb2)
  • svg (.svg and .svgz)
  • eps (.eps and .ai)
  • gif (.gif)
  • mov (.mov and .flv)
  • buffer (.tmp, .buffer, .buf)
  • tex (.tex)

You may wonder, why allow tex as an extension. This is something which is useful for user manuals. If you want to show the output of an example file, you can just say

\externalfigure[example]

ConTeXt takes care of compiling the file and including the result. So, if you want to display the source code and the output of the example side-by-side, you can say

\placesidebyside
  {\framed[align=normal,width=0.5\textwidth]{\typefile{example}}}
  {\externalfigure[example][width=0.5\textwidth, frame=on]}

\placesidebyside is another one of those macros in ConTeXt that just work.

Advertisements

3 thoughts on “Using EPS and SVG images

  1. If I remember well, there is also .swf . You need at least Adobe Reader 9.3
    (under Linux could be necessary to set Preferences->3D&Multimedia->Preferred renderer to Software).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s