\DeclareGraphicsRule
Synopsis:
\DeclareGraphicsRule{extension}{type}{size-file extension}{command}
Declare how to handle graphic files whose names end in extension.
This example declares that all files with names have the form filename-without-dot.mps will be treated as output from MetaPost, meaning that the printer driver will use its MetaPost-handling code to input the file.
\DeclareGraphicsRule{.mps}{mps}{.mps}{}
This
\DeclareGraphicsRule{*}{mps}{*}{}
tells LaTeX that it should handle as MetaPost output any file with an extension not covered by another rule, so it covers filename.1, filename.2, etc.
This describes the four arguments.
- extension
-
The file extension to which this rule applies. The extension is anything after and including the first dot in the filename. Use the Kleene star,
*
, to denote the default behavior for all undeclared extensions. - type
-
The type of file involved. This type is a string that must be defined in the printer driver. For instance, files with extensions .ps, .eps, or .ps.gz may all be classed as type
eps
. All files of the same type will be input with the same internal command by the printer driver. For example, the file types that pdftex recognizes are:jpg
,jbig2
,mps
,pdf
,png
,tif
. - size-file extension
-
The extension of the file to be read to determine the size of the graphic, if there is such a file. It may be the same as extension but it may be different.
As an example, consider a PostScript graphic. To make it smaller, it might be compressed into a .ps.gz file. Compressed files are not easily read by LaTeX so you can put the bounding box information in a separate file. If size-file extension is empty then you must specify size information in the arguments of
\includegraphics
.If the driver file has a procedure for reading size files for
type
then that will be used, otherwise it will use the procedure for reading .eps files. (Thus you may specify the size of bitmap files in a file with a PostScript style%%BoundingBox
line if no other format is available.) - command
-
A command that will be applied to the file. This is very often left empty. This command must start with a single backward quote. Thus,
\DeclareGraphicsRule{.eps.gz}{eps}{.eps.bb}{`gunzip -c #1}
specifies that any file with the extension .eps.gz should be treated as aneps
file, with the BoundingBox information stored in the file with extension .eps.bb, and that the commandgunzip -c
will run on your platform to decompresses the file.Such a command is specific to your platform. In addition, your TeX system must allow you to run external commands; as a security measure modern systems restrict running commands unless you explicitly allow it. See the documentation for your TeX distribution.
© 2007–2018 Karl Berry
Public Domain Software
http://latexref.xyz/_005cDeclareGraphicsRule.html