Changes

Jump to navigation Jump to search
1,288 bytes added ,  19:18, 1 August 2022
m
context.externalfigure({"memstream:///inline"})
\stopluacode
</texcode>
 
== Custom Processing ==
 
The following example changes the width of images based on file name extensions:
 
<texcode>
\setupexternalfigures[
location={local,global,default},
width=\textwidth
]
\defineexternalfigure[svg][width=1cm]
\defineexternalfigure[jpg][width=2cm]
\defineexternalfigure[png][width=4cm]
 
% Won't be applied because there's no process action.
% Default (\textwidth) is used, as defined above.
\defineexternalfigure[pdf][width=6cm]
 
\starttexdefinition includegraphics #1
\splitfilename{#1}
 
\processaction[\splitofftype][
jpg=>{\externalfigure[#1][jpg]},
png=>{\externalfigure[#1][png]},
svg=>{\externalfigure[#1][svg][conversion=mp]},
default=>{\externalfigure[#1]},
unknown=>{\externalfigure[#1]}
]
\stoptexdefinition
 
\starttext
\includegraphics{kitten.jpg}
\includegraphics{mill.png}
\includegraphics{cow.pdf}
\includegraphics{tiger.svg}
\stoptext
</texcode>
 
It's also possible to use {{cmd|setfigureconversion}} to instruct ConTeXt to use MetaPost when rendering SVG files. Such as:
 
<texcode>
\setfigureconversion[svg][mp]
 
\starttext
\externalfigure[kitten.jpg][width=2cm]
\externalfigure[mill.png] [width=4cm]
\externalfigure[cow.pdf] [width=6cm]
\externalfigure[tiger.svg] [width=1cm]
\stoptext
</texcode>
419

edits

Navigation menu