https://wiki.contextgarden.net/api.php?action=feedcontributions&user=Zsd&feedformat=atomWiki - User contributions [en]2024-03-28T21:19:15ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Command/externalfigure&diff=34390Command/externalfigure2024-03-05T20:48:41Z<p>Zsd: Add \definegraphictypesynonym to 'See also'</p>
<hr />
<div><noinclude><br />
<br />
{{Reference<br />
|name=externalfigure<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>externalfigure</syntax><br />
<br />
</noinclude><br />
<br />
== Description == <br />
<br />
The <code>\externalfigure</code> command is used to include an external figure/movie inside ConTeXt. Includes both local files or remote files hosted on HTTP servers. <br />
<br />
The simplest way to insert an image is to use:<br />
<br />
<context source="yes" mode="mkiv"><br />
\externalfigure[cow.pdf]<br />
</context><br />
<br />
This command places the PDF image <code>cow.pdf</code> in a<br />
<code>\vbox</code>; the width and height of the image are equal to the natural dimensions of the image.<br />
<br />
To set the width of the image to a specific size, say <code>1cm</code>, use:<br />
<context source="yes" mode="mkiv" text="which gives"><br />
\externalfigure[cow.pdf][width=1cm]<br />
</context><br />
<br />
Similarly, to set the height of the image to a specific size, say <code>2cm</code>, use:<br />
<context source="yes" mode="mkiv" text="which gives"><br />
\externalfigure[cow.pdf][height=2cm]<br />
</context><br />
<br />
If only the <code>width</code> or <code>height</code> of the image is specified, the other dimension is scaled appropriately to keep the aspect ratio.<br />
<br />
To include a specific page, say page 5, of a multi-page PDF file, use:<br />
<texcode><br />
\externalfigure[filename.pdf][page=5]<br />
</texcode><br />
<br />
These four variations cover 90% of the use cases.<br />
<br />
<br />
=== How the filetype is determined ===<br />
<br />
* '''File extension''': Normally, the type of file is determined by the extension of the file (in a case-insensitive manner).<br />
* '''<code>method=type</code>''' If the file uses a non-standard extension, specify the file type using <code>method=type</code> where type is any of the file extensions that is recognized by {{cmd|externalfigure}}.<br />
* '''auto''': When the file extension is <code>.auto</code> or <code>method=auto</code> is used, ConTeXt reads the first few bytes of the file to determine the filetype. Such an auto-discovery is useful for remote images that do not have a file extension.<br />
<br />
If the extension of the file is not specified, ConTeXt searches for all possible extensions in the order given below.<br />
<br />
Historically, when postscript output was used, the order in which the file extensions were searched depended on the output format (PDF or PS). With recent releases of ConTeXt, PDF is the default output format, so for all practical purposes, the order in which the file extensions are searched is fixed.<br />
<br />
=== Natively supported image formats ===<br />
<br />
The following image formats are supported natively in MkIV:<br />
<br />
* '''[http://en.wikipedia.org/wiki/Portable_Document_Format PDF]''': File extension <code>.pdf</code>. By default, ''mediabox'' is used to determine size. Use <code>size=artbox</code> to use ''artbox''.<br />
* '''MPS (MetaPost Output)''': File extension <code>.mp</code>, <code>.mps</code> or <code>.[digits]</code>.<br />
<!-- Converted to PDF on the fly using MPtoPDF. --><br />
* '''[http://en.wikipedia.org/wiki/JPEG JPEG]''': File extension <code>.jpg</code> and <code>.jpeg</code><br />
* '''[http://en.wikipedia.org/wiki/Portable_Network_Graphics PNG]''': File extesion <code>.png</code><br />
* '''[http://en.wikipedia.org/wiki/JPEG_2000 JPEG 2000]''': File extesion <code>.jp2</code><br />
* '''[http://en.wikipedia.org/wiki/JBIG JBIG]''' and '''[http://en.wikipedia.org/wiki/JBIG2 JBIG2]''': File extension <code>.jbig</code>, <code>.jbib2</code>, and <code>.jb2</code><br />
<br />
Additionally supported natively in LMTX:<br />
<br />
* '''[http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG]''': File extension <code>.svg</code> and <code>.svgz</code> via an internal Metapost conversion; use <code>conversion=mp</code><br />
<br />
=== Image formats supported through external converters ===<br />
<br />
The following formats are converted to PDF by external programs before being included. The conversion generates a new file with a prefix <code>m_k_i_v_</code> and a suffix <code>.pdf</code> added to the name of the original file (the original extension is not removed). The result is cached, and the conversion is rerun only if the timestamp of the original file is newer than the converted file.<br />
<br />
<br />
* '''[http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG]''': File extension <code>.svg</code> and <code>.svgz</code>. Converted to PDF using [http://en.wikipedia.org/wiki/Inkscape Inkscape]. <br />
<br />
: For the conversion to work, <code>inkscape</code> should be in the <code>PATH</code>. The following command is used for conversion:<br />
<br />
inkscape [inputfile] --export-dpi=600 -A [outputfile] <br />
<br />
: (Note: Conversion to PNG is also possible, but I don’t know the details on how to active that -- 03:32, 29 November 2012 (CET)).<br />
<br />
* '''[http://en.wikipedia.org/wiki/PostScript PS]''' and '''[http://en.wikipedia.org/wiki/Encapsulated_PostScript EPS]''': File extension <code>.eps</code> and <code>.ai</code>. Converted to PDF using [http://en.wikipedia.org/wiki/Ghostscript Ghostscript]. <br />
<br />
<br />
: For the conversion to work, on Windows <code>gswin32c</code> must be in the <code>PATH</code>; on other platforms <code>gs</code> must be in the <code>PATH</code>. The following command line options are passed to Ghostscript<br />
<br />
gs -q -sDEVICE=pdfwrite -dNOPAUSE -dNOCACHE -dBATCH [resolution] -sOutputFile=[outputfile] [inputfile] -c quit<br />
<br />
: By default, the <code>[resolution]</code> is ''prepress''. Use <code>resolution=low</code> to change the <code>[resolution]</code> to ''screen'' and <code>resolution=meidum</code> to change the <code>[resolution]</code> to ''ebook''.<br />
<br />
* '''[http://en.wikipedia.org/wiki/GIF GIF]''': File extension <code>.gif</code>. Converted to PDF using [http://en.wikipedia.org/wiki/GraphicsMagick GraphicsMagick].<br />
<br />
: For the conversion to work, <code>gm</code> should be in the <code>PATH</code>. The following command is used for the conversion:<br />
<br />
gm convert [inputfile] [outputfile]<br />
<br />
* '''[http://en.wikipedia.org/wiki/Tagged_Image_File_Format TIFF]''': File extensions <code>.tiff</code> and <code>.tif</code>. Converted to PDF using [http://en.wikipedia.org/wiki/GraphicsMagick GraphicsMagick].<br />
<br />
: For the conversion to work, <code>gm</code> should be in the <code>PATH</code>. The following command is used for the conversion:<br />
<br />
gm convert [inputfile] [outputfile]<br />
<br />
=== Supported movie formats ===<br />
<br />
The following movie formats are supported.<br />
<br />
* '''[http://en.wikipedia.org/wiki/QuickTime QuickTime]''': File extension <code>.mov</code>. <br />
* '''[https://en.wikipedia.org/wiki/Flash_Video Flash Video]''': File extension <code>.flv</code><br />
* '''[https://en.wikipedia.org/wiki/MPEG-4 MPEG 4]''': File extension <code>.mp4</code><br />
<br />
{{ note| Movie inclusion only works in a few PDF viewers }}<br />
<br />
=== Support for special TeX formats ===<br />
<br />
The following special formats are supported:<br />
<br />
* '''buffer''': Typeset the buffer with the given name and include the result as a PDF file.<br />
<br />
* '''tex''': Typeset the TeX file using <code>context</code> and include the result as a PDF file<br />
<br />
* '''cld''': Typeset the [[CLD|ConTeXt Lua document]] using <code>context</code> and include the result as a PDF file.<br />
<br />
== Command options ==<br />
<br />
=== <code>interaction</code> ===<br />
<br />
By default, the interactive elements of the included PDF file are discarded. To enable the interactive elements of the included PDF file, use<br />
<br />
<texcode>\externalfigure[filename.pdf][interaction=yes]</texcode><br />
<br />
== Example ==<br />
<br />
=== Including a local image ===<br />
<br />
In the example below, no file name extension is used. ConTeXt searches for an image file in the following order: <code>cow.pdf</code>, <code>cow.mps</code>, <code>cow.1</code>, <code>cow.2</code>, etc., <code>cow.jpg</code>, <code>cow.png</code>, <code>cow.jp2</code>, <code>cow.jbig</code>, <code>cow.jbig2</code>, <code>cow.jb2</code>. The file <code>cow.pdf</code>, which is distributed as part of the ConTeXt distribution, is found and displayed.<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[cow][width=4cm]<br />
</context><br />
<br />
ConTeXt distribution also includes a sample image <code>hacker.jpg</code>. To include it use:<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[hacker][height=3cm]<br />
</context><br />
<br />
=== Include a remote image ===<br />
<br />
<context source="yes" mode="mkiv"><br />
\externalfigure[http://placekitten.com/g/200/300][method=jpg]<br />
</context><br />
<br />
=== Rotate an image ===<br />
<br />
* '''Rotate by 90, 180, or 270 degrees''': Use <code>orientation=90|180|270</code> to rotate an image in multiples of 90. For example:<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[mill][orientation=180]<br />
</context><br />
<br />
<br />
* '''Rotate by an arbitrary angle''': Use {{cmd|rotate}} command.<br />
<br />
<context source="yes" mode=mkiv><br />
\rotate[rotation=45]{\externalfigure[mill]}<br />
</context><br />
<br />
=== Flip an image ===<br />
<br />
Use {{cmd|mirror}} to horizontally flip an image<br />
<br />
<context source=yes mode=mkiv><br />
\mirror{\externalfigure[cow][width=3cm]}<br />
</context><br />
<br />
== Error Messages ==<br />
<br />
When a file is specified by its full name, and is not found, no error message is displayed in the log; rather a gray box is shown in the generated PDF which indicates that the figure was not found. For example (note that <code>cat.pdf</code> should '''not''' exist in the current directory)<br />
<br />
<context source=yes><br />
\externalfigure[cat.pdf]<br />
</context><br />
<br />
== Tracking ==<br />
<br />
The following trackers are available for {{cmd|externalfigure}} (MkIV only) <br />
<br />
* '''graphics.locating''': Gives details about where the image files are searched, what strategy was used to infer the file format, and what was the inferred file format.<br />
<br />
* '''graphics.conversion''': Gives details about the conversion from one file format to another<br />
<br />
* '''graphics.inclusions''': Gives details of including a movie<br />
<br />
The trackers are enabled using<br />
<br />
\enabletrackers[...tracker...]<br />
<br />
or <br />
<br />
context --trackers=list [filename]<br />
<br />
When the '''graphics.locating''' tracker is enabled, including a known file displays the following information on the terminal:<br />
<br />
graphics > inclusion > locations: local,global<br />
graphics > inclusion > path list: . .. ../..<br />
graphics > inclusion > strategy: unknown format, prefer quality<br />
graphics > inclusion > found: ./cow.pdf -> /opt/context-minimals/texmf-context/tex/context/sample/cow.pdf<br />
graphics > inclusion > format natively supported by backend: pdf<br />
<br />
If the requested file does not exist, the following information is displayed:<br />
<br />
graphics > inclusion > locations: local,global<br />
graphics > inclusion > path list: . .. ../..<br />
graphics > inclusion > strategy: forced format pdf<br />
graphics > inclusion > not found: cat.pdf<br />
graphics > inclusion > not found: ./cat.pdf<br />
graphics > inclusion > not found: ../cat.pdf<br />
graphics > inclusion > not found: ../../cat.pdf<br />
graphics > inclusion > format not supported: %s<br />
<br />
When the '''graphics.conversion''' tracker is enabled and a file type that requires conversion (e.g., PS) is included, the following message is displayed on the terminal:<br />
<br />
graphics > inclusion > checking conversion of './tiger.ps' (./tiger.ps): old format 'ps', new format 'pdf', conversion 'default', resolution 'default'<br />
graphics > inclusion > no need to convert './tiger.ps' (tiger.ps) from 'ps' to 'pdf'<br />
graphics > inclusion > new graphic, hash: m_k_i_v_tiger.ps.pdf->1->crop->unknown->unknown->unknown-><br />
<br />
When the '''graphics.inclusion''' tracker is enabled and a movie is included, the following message is displayed on the terminal:<br />
<br />
graphics > inclusion > including movie 'clip.mov': width 5594039.4330709, height 5594039.4330709<br />
<br />
<br />
<noinclude><br />
<br />
== See also ==<br />
* {{cmd|defineexternalfigure}} to define a collection of settings<br />
* {{cmd|setupexternalfigure}} to define a different collection of settings<br />
* {{cmd|useexternalfigure}} to define an image+settings combination<br />
* {{cmd|definegraphictypesynonym}} to map a file extension to a particular image type handler<br />
* [[Using Graphics]]<br />
* [[Multimedia Inclusion]] to add audio and video contents.<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
</noinclude><br />
<br />
[[Category:Command/FiguresImages|externalfigure]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/definegraphictypesynonym&diff=34389Command/definegraphictypesynonym2024-03-05T20:46:34Z<p>Zsd: </p>
<hr />
<div><cd:commandgroup name="definegraphictypesynonym" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"><br />
<cd:shortdesc><!-- a short command summary goes here --><br />
The command <tt>\definegraphictypesynonym</tt> is used to map an additional file suffix to a image type handler.<br />
</cd:shortdesc><br />
<cd:variants><br />
<cd:command category="graphics" file="grph-inc.mkiv" interfacedate="2020-07-14T09:24" interfacefile="i-graphics.xml" level="system" name="definegraphictypesynonym" variantnumber="1"><br />
<cd:arguments><br />
<cd:keywords ordinal="1"><br />
<cd:keywordsdoc>file suffix</cd:keywordsdoc><br />
<cd:constant type="cd:name"></cd:constant><br />
</cd:keywords><br />
<cd:keywords ordinal="2"><br />
<cd:keywordsdoc>name of image type handler</cd:keywordsdoc><br />
<cd:constant type="cd:name"></cd:constant><br />
</cd:keywords><br />
</cd:arguments><br />
</cd:command><br />
</cd:variants><br />
<cd:description><!-- the long description of the command goes here --><br />
</cd:description><br />
<cd:examples><cd:example title="">You can register additional suffixes like this:<br />
<br />
<texcode><br />
\definegraphictypesynonym[jbig] [jb2]<br />
</texcode></cd:example></cd:examples><br />
<cd:notes></cd:notes><br />
<cd:seealso><br />
<cd:source file="grph-inc.mkiv" originator="system"></cd:source><br />
<cd:wikipage originator="system" page="Category:Graphics"></cd:wikipage><br />
<cd:commandref name="setupexternalfigure"></cd:commandref></cd:seealso><br />
</cd:commandgroup></div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/definegraphictypesynonym&diff=34388Command/definegraphictypesynonym2024-03-05T20:45:35Z<p>Zsd: </p>
<hr />
<div><cd:commandgroup name="definegraphictypesynonym" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"><br />
<cd:shortdesc><!-- a short command summary goes here --><br />
The command <tt>\definegraphictypesynonym</tt> is used to map an additional file suffix to a image type handler.<br />
</cd:shortdesc><br />
<cd:variants><br />
<cd:command category="graphics" file="grph-inc.mkiv" interfacedate="2020-07-14T09:24" interfacefile="i-graphics.xml" level="system" name="definegraphictypesynonym" variantnumber="1"><br />
<cd:arguments><br />
<cd:keywords ordinal="1"><br />
<cd:keywordsdoc>file suffix</cd:keywordsdoc><br />
<cd:constant type="cd:name"></cd:constant><br />
</cd:keywords><br />
<cd:keywords ordinal="2"><br />
<cd:keywordsdoc>name of image type handler</cd:keywordsdoc><br />
<cd:constant type="cd:name"></cd:constant><br />
</cd:keywords><br />
</cd:arguments><br />
</cd:command><br />
</cd:variants><br />
<cd:description><!-- the long description of the command goes here --><br />
</cd:description><br />
<cd:examples><cd:example title="">You can register additional suffixes like this:<br />
<br />
<texcode><br />
\definegraphictypesynonym[jbig] [jb2]<br />
</texcode></cd:example></cd:examples><br />
<cd:notes></cd:notes><br />
<cd:seealso><br />
<cd:source file="grph-inc.mkiv" originator="system"></cd:source><br />
<cd:wikipage originator="system" page="Category:Graphics"></cd:wikipage><br />
<cd:commandref name="setupexternalfigure"></cd:commandref><br />
<cd:commandref name="definegraphictypesynonym"></cd:commandref></cd:seealso><br />
</cd:commandgroup></div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/setupexternalfigure&diff=34387Command/setupexternalfigure2024-03-05T20:44:54Z<p>Zsd: Add \definegraphictypesynonym to 'See also'</p>
<hr />
<div><cd:commandgroup name="setupexternalfigure" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"><br />
<cd:shortdesc><!-- a short command summary goes here --><br />
The command <tt>\setupexternalfigure</tt> sets up {{cmd|externalfigure}}<br />
</cd:shortdesc><br />
<cd:variants><br />
<cd:command category="graphics" file="grph-inc.mkvi" interfacedate="2020-07-14T09:24" interfacefile="i-graphics.xml" level="style" name="setupexternalfigure" variantnumber="1"><br />
<cd:arguments><br />
<cd:keywords list="yes" optional="yes" ordinal="1"><br />
<cd:keywordsdoc></cd:keywordsdoc><br />
<cd:constant type="cd:name"></cd:constant><br />
</cd:keywords><br />
<cd:assignments list="yes" ordinal="2"><br />
<cd:assignmentsdoc></cd:assignmentsdoc><br />
<cd:parameter name="width"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:dimension"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="height"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:dimension"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="label"><br />
<cd:paramdoc>internal name</cd:paramdoc><br />
<cd:constant type="cd:name"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="page"><br />
<cd:paramdoc>Page number of PDF.</cd:paramdoc><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="object"><br />
<cd:paramdoc>Reuse this image file as an object, i.e. embed it only once in PDF if it’s used several times? </cd:paramdoc><br />
<cd:constant default="yes" type="yes"></cd:constant><br />
<cd:constant type="no"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="prefix"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:text"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="method"><br />
<cd:paramdoc>force a file type (and processing), e.g. if there are different versions</cd:paramdoc><br />
<cd:constant type="pdf"></cd:constant><br />
<cd:constant type="mps"></cd:constant><br />
<cd:constant type="jpg"></cd:constant><br />
<cd:constant type="png"></cd:constant><br />
<cd:constant type="jp2"></cd:constant><br />
<cd:constant type="jbig"></cd:constant><br />
<cd:constant type="svg"></cd:constant><br />
<cd:constant type="eps"></cd:constant><br />
<cd:constant type="gif"></cd:constant><br />
<cd:constant type="tif"></cd:constant><br />
<cd:constant type="mov">is removed from LMTX</cd:constant><br />
<cd:constant type="buffer"></cd:constant><br />
<cd:constant type="tex"></cd:constant><br />
<cd:constant type="cld"></cd:constant><br />
<cd:constant type="auto">strips suffix and uses "order"</cd:constant><br />
</cd:parameter><br />
<cd:parameter name="controls"><br />
<cd:paramdoc>Show media controls (for movies)</cd:paramdoc><br />
<cd:constant type="yes"></cd:constant><br />
<cd:constant default="yes" type="no"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="preview"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="yes"></cd:constant><br />
<cd:constant default="yes" type="no"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="mask"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="none"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="resolution"><br />
<cd:paramdoc>Set the image resolution (after scaling) for automatic downsampling</cd:paramdoc><br />
<cd:constant type="cd:number">dpi</cd:constant><br />
</cd:parameter><br />
<cd:parameter name="color"><br />
<cd:paramdoc>Colorize the image. Works only with some greyscale pictures (no channels, no additional tables, ...?) and only with toned (<tt>p=</tt>) or [[Spot_Colors|spot colors]]. Use with <cd:iref name="object" type="no"/></cd:paramdoc><br />
<cd:constant type="cd:color">color name</cd:constant><br />
</cd:parameter><br />
<cd:parameter name="cmyk"><br />
<cd:paramdoc>Force CMYK conversion</cd:paramdoc><br />
<cd:constant type="yes"></cd:constant><br />
<cd:constant default="yes" type="no"></cd:constant><br />
<cd:constant type="auto"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="arguments"><br />
<cd:paramdoc>used for converters</cd:paramdoc><br />
<cd:constant type="cd:text"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="repeat"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="yes"></cd:constant><br />
<cd:constant default="yes" type="no"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="factor"><br />
<cd:paramdoc>If both <tt>width</tt> and <tt>height</tt> are set, the <tt>factor</tt> is important.<br />
<br />
If <cd:iref name="factor"/> is empty, the image is deformed accordingly.</cd:paramdoc><br />
<cd:constant type="fit">aspect ratio is kept, the image is scaled to the smaller (fitted) variant</cd:constant><br />
<cd:constant type="broad"></cd:constant><br />
<cd:constant type="max">aspect ratio is kept, the image is scaled to the bigger (oversized) variant</cd:constant><br />
<cd:constant type="auto"></cd:constant><br />
<cd:constant type="default"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="hfactor"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="fit"></cd:constant><br />
<cd:constant type="broad"></cd:constant><br />
<cd:constant type="max"></cd:constant><br />
<cd:constant type="auto"></cd:constant><br />
<cd:constant type="default"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="wfactor"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="fit"></cd:constant><br />
<cd:constant type="broad"></cd:constant><br />
<cd:constant type="max"></cd:constant><br />
<cd:constant type="auto"></cd:constant><br />
<cd:constant type="default"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="maxwidth"><br />
<cd:paramdoc>maximum width</cd:paramdoc><br />
<cd:constant type="cd:dimension"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="maxheight"><br />
<cd:paramdoc>maximum height</cd:paramdoc><br />
<cd:constant type="cd:dimension"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="equalwidth"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:dimension"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="equalheight"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:dimension"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="scale"><br />
<cd:paramdoc>1000 is original size (100%); to get 72%, use scale=720.</cd:paramdoc><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="xscale"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="yscale"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="s"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="sx"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="sy"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="lines"><br />
<cd:paramdoc>Height in lines</cd:paramdoc><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="location"><br />
<cd:paramdoc>Where to find figure files. Multiple comma-separated options are allowed, and the default value is <code>local,global</code><br />
</cd:paramdoc><br />
<cd:constant default="yes" type="local">search in the current directory</cd:constant><br />
<cd:constant default="yes" type="global">search path specified with the <cd:iref name="directory"/> key</cd:constant><br />
<cd:constant type="default">search in the texmf tree</cd:constant><br />
</cd:parameter><br />
<cd:parameter name="directory"><br />
<cd:paramdoc>comma-separated directories to search for figure files</cd:paramdoc><br />
<cd:constant type="cd:path"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="option"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="test"></cd:constant><br />
<cd:constant type="frame"></cd:constant><br />
<cd:constant type="empty">don’t include actual image (“draft mode”)</cd:constant><br />
</cd:parameter><br />
<cd:parameter name="foregroundcolor"><br />
<cd:paramdoc>probably synonymous to "color"</cd:paramdoc><br />
<cd:constant type="cd:color"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="reset"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="yes"></cd:constant><br />
<cd:constant default="yes" type="no"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="background"><br />
<cd:paramdoc>like {{cmd|setupframed}}</cd:paramdoc><br />
<cd:constant type="color"></cd:constant><br />
<cd:constant type="foreground"></cd:constant><br />
<cd:constant type="cd:name"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="frame"><br />
<cd:paramdoc>Show frame around image. Most(?) options of {{cmd|setupframed}} are usable!</cd:paramdoc><br />
<cd:constant type="on"></cd:constant><br />
<cd:constant default="yes" type="off"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="backgroundcolor"><br />
<cd:paramdoc>like {{cmd|setupframed}}, used if <tt>background=color</tt></cd:paramdoc><br />
<cd:constant type="cd:color"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="xmax"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="ymax"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="frames"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="on"></cd:constant><br />
<cd:constant default="yes" type="off"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="interaction"><br />
<cd:paramdoc>How to handle the interaction (links etc.) of included PDFs – default is to disable all of them.</cd:paramdoc><br />
<cd:constant type="yes">keep all(?)</cd:constant><br />
<cd:constant type="all">keep all</cd:constant><br />
<cd:constant default="yes" type="none">disable all</cd:constant><br />
<cd:constant type="reference">keep references</cd:constant><br />
<cd:constant type="layer">keep PDF layers (viewer layers, optional content groups)</cd:constant><br />
<cd:constant type="bookmark">keep bookmarks</cd:constant><br />
</cd:parameter><br />
<cd:parameter name="bodyfont"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:dimension"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="comment"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:command"></cd:constant><br />
<cd:constant type="cd:text"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="size"><br />
<cd:paramdoc>Use specified box of PDF (MediaBox, CropBox, TrimBox, ArtBox). (No BleedBox?)</cd:paramdoc><br />
<cd:constant type="none"></cd:constant><br />
<cd:constant type="media"></cd:constant><br />
<cd:constant type="crop"></cd:constant><br />
<cd:constant type="trim"></cd:constant><br />
<cd:constant type="art"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="cache"><br />
<cd:paramdoc>Set location of cache for conversions</cd:paramdoc><br />
<cd:constant type="cd:path"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="resources"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="cd:path"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="display"><br />
<cd:paramdoc>alternative figure, e.g. lowres; used with movie and 3D contents, probably obsolete</cd:paramdoc><br />
<cd:constant type="cd:file"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="conversion"><br />
<cd:paramdoc>see {{src|grph-con.lua}}.<br />
<tt>conversion=mp</tt> activates internal processing of [[SVG]] via [[MetaPost]]</cd:paramdoc><br />
<cd:constant type="cd:text"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="order"><br />
<cd:paramdoc>Sets the order in which the individual file types are looked up.<br />
<br />
</cd:paramdoc><br />
<cd:constant type="cd:list"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="crossreference"><br />
<cd:paramdoc></cd:paramdoc><br />
<cd:constant type="yes">use counter for referencing</cd:constant><br />
<cd:constant type="no"></cd:constant><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="transform"><br />
<cd:paramdoc>Rotation in 90˚ steps (otherwise use {{cmd|rotate}}); does not always work (?) `orientation=90|180|270` works</cd:paramdoc><br />
<cd:constant default="yes" type="auto"></cd:constant><br />
<cd:constant type="cd:number"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="userpassword"><br />
<cd:paramdoc>Access to encrypted PDFs</cd:paramdoc><br />
<cd:constant type="cd:text"></cd:constant><br />
</cd:parameter><br />
<cd:parameter name="ownerpassword"><br />
<cd:paramdoc>Access to encrypted PDFs</cd:paramdoc><br />
<cd:constant type="cd:text"></cd:constant><br />
</cd:parameter><br />
</cd:assignments><br />
</cd:arguments><br />
</cd:command><br />
</cd:variants><br />
<cd:description>There are a few more options that are missing in the interface files:<br />
<br />
* '''orientation''': rotation (in LMTX arbitrary angles, in MkIV only 90˚steps)<br />
* '''minwidth/minheight'''<br />
* '''strut''': strut=none also avoids the \noindent; otherwise we're in hmode when blank happens and we get a lineskip</cd:description><br />
<cd:examples><cd:example title=""><texcode><br />
\setupexternalfigures<br />
[order={pdf,png,jpg},<br />
location=global,<br />
directory={images}]<br />
</texcode></cd:example></cd:examples><br />
<cd:notes></cd:notes><br />
<cd:seealso><br />
<cd:commandref name="defineexternalfigure" originator="system"></cd:commandref><br />
<cd:commandref name="externalfigure"></cd:commandref><br />
<cd:commandref name="definegraphictypesynonym"></cd:commandref><br />
<cd:wikipage originator="system" page="Category:Graphics"></cd:wikipage><br />
<cd:source file="grph-inc.mkvi" originator="system">MkIV source</cd:source><br />
<cd:source file="grph-inc.mkxl">LMTX source</cd:source><br />
<cd:source file="grph-con.lua">conversions source</cd:source><br />
<cd:wikipage page="Using Graphics"></cd:wikipage><br />
<cd:wikipage page="Multimedia Inclusion">to add audio and video contents</cd:wikipage></cd:seealso><br />
</cd:commandgroup></div>Zsdhttps://wiki.contextgarden.net/index.php?title=Using_Graphics&diff=34324Using Graphics2024-02-06T00:01:38Z<p>Zsd: Fixed one typo, one small grammatical error.</p>
<hr />
<div>= Usage =<br />
<br />
The simplest way to insert an image is to use:<br />
<br />
<texcode>\externalfigure[logo.pdf]</texcode><br />
<br />
This command places the PDF image <tt>logo.pdf</tt> in a {{cmd|vbox}}; the width and height of the image are equal to the natural dimensions of the image.<br />
<br />
To set the width of the image to a specific size, say <tt>1cm</tt>, use:<br />
<br />
<texcode>\externalfigure[logo.pdf][width=1cm]</texcode><br />
<br />
Similarly, to set the height of the image to a specific size, say <tt>2cm</tt>, use:<br />
<br />
<texcode>\externalfigure[logo.pdf][height=2cm]</texcode><br />
<br />
If only the <tt>width</tt> or <tt>height</tt> of the image is specified, the other dimension is scaled appropriately to keep the aspect ratio.<br />
<br />
To include a specific page, say page 5, of a multi-page PDF file, use:<br />
<br />
<texcode>\externalfigure[logo.pdf][page=5]</texcode><br />
<br />
These four variations cover the most common use cases.<br />
<br />
== File Formats ==<br />
<br />
ConTeXt natively supports the image formats enumerated below. The image format is determined from the file extension (case insensitive).<br />
<br />
* '''PDF''': File extension <tt>.pdf</tt><br />
* '''MPS''' (MetaPost output): File extension <tt>.mps</tt> or <tt>.&lt;digits&gt;</tt><br />
* '''JPEG''': File extension <tt>.jpg</tt> or <tt>.jpeg</tt><br />
* '''PNG''': File extension <tt>.png</tt><br />
* '''JPEG 2000''': File extension <tt>.jp2</tt><br />
* '''JBIG''' or '''JBIG2''': File extension <tt>.jbig</tt>, <tt>.jbig2</tt>, or <tt>.jb2</tt><br />
<br />
An old page (2010), gives details on supported [[File Formats|file formats]]<br />
<br />
== Image Conversion ==<br />
<br />
The image file formats listed in the previous section are the ones that may be embedded directly in a PDF. ConTeXt also supports a few other formats that are first converted to PDF using an external program. Of course, for such a conversion to work, the corresponding converter must be in the <tt>PATH</tt>.<br />
<br />
<table><br />
<tr class="odd"><br />
<td align="left">Format</td><br />
<td align="left">Extension</td><br />
<td align="left">Converter</td><br />
</tr><br />
<tr class="even"><br />
<td align="left"><strong>SVG</strong></td><br />
<td align="left"><code>.svg</code>, <code>.svgz</code></td><br />
<td align="left"><code>inkscape</code></td><br />
</tr><br />
<tr class="odd"><br />
<td align="left"><strong>EPS</strong></td><br />
<td align="left"><code>.eps</code>, <code>.ai</code></td><br />
<td align="left"><code>gs</code> (or <code>gswin32c</code> on Windows) from Ghostscript</td><br />
</tr><br />
<tr class="even"><br />
<td align="left"><strong>GIF</strong></td><br />
<td align="left"><code>.gif</code></td><br />
<td align="left"><code>gm convert</code> from GraphicsMagick</td><br />
</tr><br />
<tr class="odd"><br />
<td align="left"><strong>TIFF</strong></td><br />
<td align="left"><code>.tiff</code></td><br />
<td align="left"><code>gm convert</code> from GraphicsMagick</td><br />
</tr><br />
<tr class="even"><br />
<td align="left"><strong>BMP</strong></td><br />
<td align="left"><code>.bmp</code></td><br />
<td align="left"><code>gm convert</code> from GraphicsMagick</td><br />
</tr><br />
</table><br />
<br />
The conversion generates a PDF file with prefix <tt>m_k_i_v_</tt> and a suffix <tt>.pdf</tt> added to the name of the original file. The result is cached, and the conversion is re-run if the timestamp of the original file is newer than that of the converted file.<br />
<br />
In LMTX, the file name contains a MD5 hash of the relevant source image parameters (resolution, dimensions, ...), e.g.:<br />
<br />
<pre><br />
hacker_jpg_c60ccda70ef92e32d7a6334f31c23259.gray.pdf <br />
</pre><br />
<br />
It is possible to change the converter used with the following code:<br />
<br />
<pre><br />
\startluacode<br />
local function downsampler(oldname, newname, resolution)<br />
if not resolution or resolution == "" then<br />
resolution = 50<br />
end<br />
os.execute(string.format(<br />
'gm convert -density %ix%i "%s" "%s"',<br />
resolution, resolution, oldname, newname)<br />
)<br />
end<br />
<br />
-- Set the PDF and default TIFF converters to the above function.<br />
figures.converters.tif.pdf = downsampler<br />
figures.converters.tif.default = downsampler<br />
-- Hint: This works also for jpg or png!<br />
\stopluacode<br />
<br />
\starttext<br />
% Substitute any TIFF here.<br />
\externalfigure[cow.tiff]<br />
\stoptext<br />
</pre><br />
<br />
See also {{src|grph-inc.lua}}<br />
<br />
== Interaction ==<br />
<br />
By default, the interactive elements of the included PDF file are discarded. To enable the interactive elements of the included PDF file, use<br />
<texcode>\externalfigure[filename.pdf][interaction=yes]</texcode><br />
<br />
For further reading, don't forget [[Including pages from PDF documents]].<br />
<br />
== Image Directory ==<br />
<br />
By default, ConTeXt searches an image in the current directory, the parent directory, and the grand-parent directory.<br />
<br />
To search for images in other directories, for example a <tt>./images</tt> subdirectory and <tt>/home/user/images</tt>, use:<br />
<br />
<texcode>\setupexternalfigures[directory={images, /home/user/images}]</texcode><br />
<br />
Note: always use forward slashes (`/`) in path names, regardless of operating system.<br />
<br />
The default search order is: the current directory, the parent directory, the grand-parent directory, and then the paths specified by the <tt>directory</tt> key. To restrict image search only to the paths specified by the <tt>directory</tt> key, use:<br />
<br />
<texcode>\setupexternalfigures[location=global]</texcode><br />
<br />
To restore the default search behavior, use:<br />
<br />
<texcode>\setupexternalfigures[location={local,global}]</texcode><br />
<br />
The ConTeXt distribution includes three sample images: <tt>cow.pdf</tt>, <tt>mill.png</tt>, and <tt>hacker.jpg</tt>, that are useful when creating minimum working examples to illustrate a bug on the mailing list. These images are located in the <tt>TEXMF</tt> directory. To add the <tt>TEXMF</tt> directory to the image search path, use:<br />
<br />
<texcode>\setupexternalfigures[location={local,global,default}]</texcode><br />
<br />
The above alternative adds the ''entire'' <tt>TEXMF</tt> directory to the search path, ''including the'' <tt>doc/</tt> ''directory!'' Therefore, one needs to be extremely careful when using this option. In fact, I would advise not using <tt>location=default</tt> except for illustrative minimal working examples.<br />
<br />
== Remote Images ==<br />
<br />
The {{cmd|externalfigure}} command supports reading files from web servers, for example:<br />
<br />
<texcode>\externalfigure[http://tug.org/images/logobw.jpg]</texcode><br />
When a document containing a remote file is compiled for the first time, the remote file is downloaded from the server and stored in the LuaTeX cache directory. This cached file is used during subsequent runs.<br />
<br />
Normally, the remote image is downloaded again if the image in the cache is older than 1 day. To change this threshold to, for example, 2 minutes (120 seconds), either add<br />
<br />
<texcode>\enabledirectives[schemes.threshold=120]</texcode><br />
<br />
in the ConTeXt file, or compile the ConTeXt file using the command<br />
<br />
<pre>context --directives=schemes.threshold=120 <em>filename</em></pre><br />
The variable <tt>schemes.threshold</tt> is global, so changing its value affects all other macros like <tt>\input</tt>, <tt>\usemodule</tt>, <tt>\component</tt>, etc. that load remote files.<br />
<br />
=== HTTP Proxy ===<br />
<br />
To use an http proxy for fetching images, the http variable ([http://w3.impa.br/~diego/software/luasocket/http.html LuaSocket]) has to be set up as follows:<br />
<br />
<texcode><br />
\ctxlua{http = require("socket.http"); http.PROXY = "http://proxy.example.com:3128"}<br />
</texcode><br />
<br />
Replace `http://proxy.example.com:3128` with the proxy URL.<br />
<br />
To disable the proxy again:<br />
<br />
<texcode><br />
\ctxlua{http = require("socket.http"); http.PROXY = nil}<br />
</texcode><br />
<br />
=== HTTPS ===<br />
<br />
For self-signed certificates retrieved over HTTPS, the `curl` command requires a flag to retrieve insecure files, which is not enabled by default. Open `tex/texmf-context/tex/context/base/mkiv/data-sch.lua` to find:<br />
<br />
<pre><br />
local function runcurl(name,cachename) -- we use sockets instead or the curl library when possible<br />
local command = "curl --silent --create-dirs --output " .. cachename .. " " .. name<br />
os.spawn(command)<br />
end<br />
</pre><br />
<br />
Insert the `-k` or `--insecure` option:<br />
<br />
<pre><br />
local command = "curl --insecure --silent --create-dirs --output " .. cachename .. " " .. name<br />
</pre><br />
<br />
== Inline Images ==<br />
<br />
Embedding inline images via base64 encoding using the memstream function (supports pdf and png streams):<br />
<br />
<texcode><br />
\startluacode<br />
local cow = mime.unb64("JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURlY29kZT4+CnN0cmVhbQp4nJWayY40SW6E7/UUcRaQIafvfp6bAAkY9SM0oHXmMBAgvb7sM0ZmVf86CYNB/+HpC500Ghevv13ljqvwv+e/v//16+//eV3/+l9f8y4nRlz/8xVx99XW9Y9fcf2D/v8f+v+/a9q5/vSb/vnbn/7p629a+oq79L639jpjRKzcmC1fsUe927xaO3fRLwydsu/Q0C7afmj5Pv3WMb32+6zGgP61rz77Xdu4fv/KkWjXiHH3xpp12r3ONeq+W3QG1r7G6Pc8yyvmOHev19LBbXtFb/fo1zkan6GBqS3qFTWaBnLNLLfmRuvnPocpq96jXdFHu8/0ms4mMYaEP160usSMK9bUTZnS9l32VUurjGuC9LjWVWvM+1ky1t3qVZumxGZKPVftTb/zNbclraPW+/TnNkP31NAKycwh6+58Hx3C7cYJtqqzzHvkKT3qXXTKlGBoqOqnsr6/S5RbuqzzTKTRkmOl9s/Q68x1j6U9FvpfGqiyY2kMLG6nRbtqbkiWNePeUtIOWUE214AMer2WFLKbLrjWfNasVm5J+hl6zaLtuoTZq3PBga4O32PfVsHQLq3phrsvIVRThu2m7wnCXqPrWqhtozYviXPPxSblcOOu2+SmghFLescOEn3LEMvHdB0jIDKHW7Co3Xsh/T73lmgd3Pp6Sygx2LqwtiZa2fMWDr93WTJl0f16FYAWSpIBnzWyXGGKzIEs0l6UwYwC1L+lNVpmrnlv23/dtg8brOFKGH1JK8W+AwxCuKpy5RRuAFg2lpJ9RYEooqZRE3BjCkbrY+bXtJPo0nNvb7Kk0mBC6Q/elpwnNrIU3UwGOlJ/w+540QE8cpqGkScu40VngidwK2Bx0K64oFHarAYQsrxLDnASiDueM43KHtJL+CThSgNtYryei7Z113ST8Rl4Sc0iIXtH3JMB2fDYHXIPLanS4a55Z+lS311MhxKkZZirBmv4Xo+y8bGDKk0u0lMtIePF9yZx0KzPkQsnV22Jhubgn2LekQibg5YcUt+CdtTvCaxpwtHmhtAa++oebaADMd7afxiIe9jtQi4TFcXJndlX/6kVWUSjnQHEPzZHTbfbYEVcaKaBncCvDx44iClBbqcb9/1hK9Hn3IwcCEjHbs1kDzFOQddvLUGjy/fRPaRbiTa0jaR9tW7KrWOOdAfBeLPr0MyHEbSbd9F5gH9ItRWodHkdokGkC2rqeyC8Fs2FTRkS8rpIYWr/jTfgFpDCnFuIbvBxYGUWwUbBkNSCx4xVHM4+i0ZDk2gBJ7Oyu6TqrBG1jZ+XbiMJKypW1bdESsCBmUAJTYiA1hcUcCRtm9DgS9cYY7fPHhjoe6hZCz8Gwur/HpBEY+aFdHcu/Z6j7eaYnuOg8d+wp/jIwtRBeH5NQwGB8VGrV/7tXYgkNglqho/qGdIHBKWZU2hphSAgLQgSBwhW+VC3Sb6HdAOEkfHaAlKhoAbmZIhqSwdy+tZLTgsawNrCZeLxhxrJPgHZKHZX2eh90NsCcsYbiMG8lSnEPam7K/hsJQAVMkg/A0ob5T1DMr02IYxWcS9wEREKkwirGOIwOs5J943prEVrTiL1Le3YkID0hMOtmYwrW+sADaWTjI7XdAYWBw0RWCNrKMA8A1zl0ozIZxw1JQLyF4iRgxsRcDLQH9MP2WhgkUK+spCF0OuBINmR+LCPblgE7p12/QyRXiDM4WZKhI7IXonQi3RLg1fs7ZwGkIkuuzTidIdbi5G16GhA/tTwPQ7QnUVVmwEjc9/CWMAuwsSH/qPJNmV9ZxOhOC/LeI0i8tFVouoGJJBjO7PR91Ie+dFCKKPid8y6nODIBTep1qsXud5hC1ICydoKGcr5DBinOqazqAep5Us5ggZY1ADJzwEFhtGT1zYh4j3yYrvugedk1goJ+jZrkCQKc/oug4WKSwzsK8AXp76jRYSg2ZLXhS85t4YU3ZxBTxQrUcFO4A2H4KmBIkIf6Q31sVjBmbiOPH4pt5MrNeteCcI9OYg01Qc1CdVYo4zYa5rMNRTWNBCQ2asNu5/WOAtmzcbL1veUHoqWvgAIJ/VpBl7gsrX9TKjeQ59ULmCAY2TDAKhFFDPTGwZiMlR9x7+A25EQVLLrfcgY+u7fd1ziMmVGzBgPNsh1m9xXipk2K0lQIM1noKAY3aDIuiVxO1n0Gfl4VeBmeBnZS+VbN5rpiYg5WKNAsOGjxrYcLEehZhHpSFrO6QWvMIdxo8UQtQ45CAed713kgWI5D7QHhLHwBw5X5jRccCwHNHHNU9g8oDoKFlKpFz2QOWtYQxQUjvTnkMaxC7WV4H4WVUKWUI1soF1H+NiEcfmgFN+uLanGrt+8rDChTHX+zH82JEVaW2UUlSDXFpEG8iqA6/7nUpi4d0/HkmmLfjtks1iyKdsYislHaYFYg7SWf0gWREjTjnJcRIhoMTYIAU8C/abSgZIkZ9fRB7UKOSIgOayQvOU45AkEH2dh41pk1qQDR3joIonVSGLQTNEq3XYeIfwpx+p0QUoKd0hOok3HyC4CUDbyPVDt1/tRp3yGGCajU7O1SqC+iCNOFJ8lZAcrMplsSX6USyITm23fFA0CTq/OJilvyVGVPGdkDHQ1L0pHaB4jGc7mJvwmKMh0oeXc0qmkkrrAq6UDV+STeChIwdOZxA7X166Snvo6K24RGckTdTBoIReTxIalUwqyZzHReqgNkGmO/nOyOUDuRY7kRO7TYlDOKksmH9qa1IoC3fCi5naB6tR7U4r82pf4/evfvn67/vyVnYu4/vNLyYj8SXGHwHb9Vd9UHe9v0Tj/ieZaWl/Nc2dmzVXqI9qQqFaoC1IKUm5q+vS68DzwKmbwhuQkR5ae1G/PjsRbpKtUlAP2EKD0KwVUsiNJaEBoI6te54Em5MnpTRfvl4MyWbxKYZ2ylVs3q0rIovrcqtA2SlX9rUvi4Tm9CTT6JARi9iq9ff8qZNyQE9Agt6G9EUWZwcypCCRCFsGSCiFHKMYiP+Gjo6+cWahyVJwo4rErCwSn4i+5+SZjKHm7IGUAVOIp+a8kJOdoXEJ3nQk4ltTmg8V0NXXda/46PJdqRSuXOwMCV1wG8E6rWFY6DtQb1bqmV4A1f6IC1IgmO/petCOEE2VEyxJC/nvlmWFR9sCY8oJim8b2lkEuZa/wTUkNBbOzSYJqljpKzRYru3xTmudCCnsLvRaRMvJYSGbSmAJ7vlcZtsBGk6XZWqovfMs4y5qExDmdiJso4gu+JXZ15/X6fiztSetYGoLSRMEk/04SfKs1iu1+Tl623U5/+DfBLnY2QJTzeZdo3oWG1s5oWZ+ZxUUqOypTgcabYafimCsSLPw5FDWb+ToxqguC4S0wAGmpVyHuQip+D3qETcSM9WL41Elnx79VRJpS6WTn1hBg0XrLnWHmKQ6M3Iq6tl1kt9O5lo10qMzsW8+AfHjbWUU3uv2wsggYOoAmCjOLbBFv/qDq8q/SL2pIW9R9PHPY3s4e2efc/aO1IgeqbxsyN4wodw/e+xDgrZbnc8735SSndFwsvI5BafszuVqlD0v8/gUGUdFpSSQieBuD2Mt2Z6QK3dn19rDuFvBZb6R7W5numJyswGL/1dyRBONjpzMFLyNz0rxN4cIhLRWvBVKDZzxEtTaLe7X1tJcmfV909TTfe4RkzjPwpJNoSHFoNmuBCmN0TceoX+MRIiDWeRFbLWqnz6PJvZT3AH7casoaJL30xtrzScqbfObDRSiQzTTE63u1btDojrn/bBJbiCiLU7/Q2kGwUaq3fn4aTlJ8TnenOsgFprcdyhzTVHzsYqZWWptXmko2cMXEu1zX4DppdMXmkcSu4+wtazv6VAdCQgrdqNShPkfe7/l1mY4qxLZgbmV+eSZejd5oRFhvRBclRVKjN6IlHVd/TO23Ayw+aCf49wJpDwIqv+P15zKZIPMuw9NXedavRfzcfHJYhooPABdJO3jqGS5F3Fhljf42Yq5OtEVz8rT3s3czxHdO3SXj9zA5rjLfqh5W8YbR5Pb4vxRuzg5HPH1FEnTsnoHQ8SXIl59aOqvDeH/BTL2bmTsOEy3jzeoleeRkQEo4C0zre224eYYmSsbZk0HT9AjT8eUyOvA7At00Yf8h7P3+9S9/9/98GGrFma1vW6+fI5LTXcNWXFVX2nq/DJSn3So9FDof1dDNBubTsxXmyQ4PuTqtuyllZBf00HfzEHyptNOpPW0TIjG9VFKyTk/nx0nahJZK5dnB6a1LSjI6GkPTA42cuRJFskYRPUvVTnDh95ccUg5NvkH/XgcBxLK+G34UFxKq0QdSZeVHqINNJ102us4MDKRkAPt60WcO+Zuq4tdZWW7WSlVoxfRMiWlAZMtVgHMqW7cbZC/3NWhbySh5o1bynYoEvdYsFGbWDrAAjSD4xWqgwbHbj6epKlc4z3tX+CqVXoY2/oufwNKWqsby0QtXm05tx/MKdvyPyuvEYwNa5s0N35JPa1iQhwA6bm6uE915RJnih6e4VP0PTT1dcOqjQStAgKh+z/kFieR0nPQ84lE1heE5p2uuIMh0FzzimgVBTj9fvtzFKmRotK5T4qH19B/wFks8wo+flaTZNfVwv6sWaPHpntdEmps470Jxk8Ftb/ZyXws9BM3mtyOQWDgJ95sqP9G2lEZoMAJFMgZl11LzG5zSonuD7i8Kv5VOVCXFcEu10NxBCeDMVR/kDe1WOhQd98JIJt79PGXSYKL62RDDg7OepSJFmOdws/Xk5r4hSSBtpYU9s4Qr2pB9SCB9aTQ24DgKKd4dCF90yr4XbT+camiLAEHnrulfsueglfXa7qjDuTT8spVMqNFkMeH0ScsmErfxErDzhUB6hYnXu0s5UR3S8aJBKzy6y+AAifRDF4+Qw0GBqp+20qCRYD5umFxT6GCQ2oXbkq8TFPPuDVau6vcxYeDUzxCqIhiRSfKwDRiGlRh+3HmaMEmU70bYy4krb9S0jqcR1LJYBxXxWGm5AfZplX0UHk9f+A0QmabRnkoMNVupTPeaXkC/j/HZ+EVBuxHv+6RN3jC5grNEaBEYU5tIblqcbw4MvCK7ldtvI84ZD+2NF8lkby37Xphg8/gg3B7dsSdbUeQPpd2n0UfiPZtOEy0h+TLNJ+FXIuzjuhugoPLd/AcCHJCLaBaJVA9msrykmeI8et8nWfvNyVxlO4QcOmwXj+PFaH30sCgA3nHoGVr5bPV/20iHxza6Llwxu6kJBBUwFOrZYMtWNu8S3Z7e6LNmzrSfd7/WzSA9eG31nMGZV2t0vdxIWtlVUfVZ+xtFxQ9Ygqmp69mEp4V5POBXgYtexN4P2eYfU/CYS4dMAy3DjizcDaJ38+mZ4UU7m010Q/23HLTp5JyO2H7K9MNG/KH7FHYvHbdKdp+m63n5wHJk2BgNnlVIe5rkxRyMtwEcuk05QDTJPxGZ1krlbxCe6LHo4K0fc/bDmvRVzJK7Wwt06p7u09FBEqJR/hUOoiXQU/3LPrvdFb0g/5hPD7T64c39hbB0w0GTthO9BP5IhCAv/S+3NfNKlHrkedvKfYIo2ff0ozCdh95+wjt4liFTpQ5PvFDAgkwFcGOBh474QNlQIK3GS+Q2tPDDT/DUTMUda4Jhc9+/8Pb1dPsi46PiV5IOz2B2c23jTjUVyHZu2x6+cwAnNMgh3AKXIV3b1ppPRp/vfOrJrCD/SAfW81sHhA05N79V+894CrxidNZnUW5DfDatrkjKnE4OnX5sIqn7j08aI9STH6maGU/A31ZlUJk6Q/0lbXh3Ff/89b/apSg4ZW5kc3RyZWFtCmVuZG9iago2IDAgb2JqCjQzMjEKZW5kb2JqCjQgMCBvYmoKPDwvVHlwZS9QYWdlL01lZGlhQm94IFswIDAgMjc1IDIwMF0KL1BhcmVudCAzIDAgUgovUmVzb3VyY2VzPDwvUHJvY1NldFsvUERGXQovQ29sb3JTcGFjZSAxMCAwIFIKL0V4dEdTdGF0ZSAxMSAwIFIKPj4KL0NvbnRlbnRzIDUgMCBSCj4+CmVuZG9iagozIDAgb2JqCjw8IC9UeXBlIC9QYWdlcyAvS2lkcyBbCjQgMCBSCl0gL0NvdW50IDEKPj4KZW5kb2JqCjEgMCBvYmoKPDwvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMyAwIFIKPj4KZW5kb2JqCjcgMCBvYmoKPDwvVHlwZS9FeHRHU3RhdGUKL09QTSAxPj5lbmRvYmoKOSAwIG9iagpbL1NlcGFyYXRpb24KL0JsYWNrCi9EZXZpY2VDTVlLCjggMCBSXWVuZG9iagoxMCAwIG9iago8PC9SOQo5IDAgUj4+CmVuZG9iagoxMSAwIG9iago8PC9SNwo3IDAgUj4+CmVuZG9iago4IDAgb2JqCjw8L0ZpbHRlci9GbGF0ZURlY29kZQovRnVuY3Rpb25UeXBlIDQKL0RvbWFpblswCjFdCi9SYW5nZVswCjEKMAoxCjAKMQowCjFdL0xlbmd0aCAyOT4+c3RyZWFtCnicq04pLVAwUMgtzVFIrUjOUMDPNQQzawHfFRGFCmVuZHN0cmVhbQplbmRvYmoKMiAwIG9iago8PC9Qcm9kdWNlcihBRlBMIEdob3N0c2NyaXB0IDguNTIpCi9DcmVhdGlvbkRhdGUoRDoyMDA2MDUxNTEyMjA1OSkKL01vZERhdGUoRDoyMDA2MDUxNTEyMjA1OSkKL0NyZWF0b3IoQ29yZWxEUkFXISkKL1RpdGxlKENPVy5FUFMpPj5lbmRvYmoKeHJlZgowIDEyCjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwNDYzNiAwMDAwMCBuIAowMDAwMDA0OTg2IDAwMDAwIG4gCjAwMDAwMDQ1NzcgMDAwMDAgbiAKMDAwMDAwNDQyNiAwMDAwMCBuIAowMDAwMDAwMDE1IDAwMDAwIG4gCjAwMDAwMDQ0MDYgMDAwMDAgbiAKMDAwMDAwNDY4NCAwMDAwMCBuIAowMDAwMDA0ODM4IDAwMDAwIG4gCjAwMDAwMDQ3MjUgMDAwMDAgbiAKMDAwMDAwNDc3OCAwMDAwMCBuIAowMDAwMDA0ODA4IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgMTIgL1Jvb3QgMSAwIFIgL0luZm8gMiAwIFIKL0lEIFs8ODE0NjQ5NTc3Qzg3MTE1QzRDQzBDQjg0QkU3RTQ1MEY+PDgxNDY0OTU3N0M4NzExNUM0Q0MwQ0I4NEJFN0U0NTBGPl0KPj4Kc3RhcnR4cmVmCjUxMzMKJSVFT0YK")<br />
figures.setmemstream("inline",cow)<br />
context.externalfigure({"memstream:///inline"})<br />
\stopluacode<br />
</texcode><br />
<br />
== Custom Processing ==<br />
<br />
The following example changes the width of images based on file name extensions:<br />
<br />
<texcode><br />
\setupexternalfigures[<br />
location={local,global,default},<br />
width=\textwidth<br />
]<br />
\defineexternalfigure[svg][width=1cm]<br />
\defineexternalfigure[jpg][width=2cm]<br />
\defineexternalfigure[png][width=4cm]<br />
<br />
% Won't be applied because there's no process action.<br />
% Default (\textwidth) is used, as defined above.<br />
\defineexternalfigure[pdf][width=6cm]<br />
<br />
\starttexdefinition includegraphics #1<br />
\splitfilename{#1}<br />
<br />
\processaction[\splitofftype][<br />
jpg=>{\externalfigure[#1][jpg]},<br />
png=>{\externalfigure[#1][png]},<br />
svg=>{\externalfigure[#1][svg][conversion=mp]},<br />
default=>{\externalfigure[#1]},<br />
unknown=>{\externalfigure[#1]}<br />
]<br />
\stoptexdefinition<br />
<br />
\starttext<br />
\includegraphics{kitten.jpg}<br />
\includegraphics{mill.png}<br />
\includegraphics{cow.pdf}<br />
\includegraphics{tiger.svg}<br />
\stoptext<br />
</texcode><br />
<br />
It's also possible to use {{cmd|setfigureconversion}} to instruct ConTeXt to use MetaPost when rendering SVG files. Such as:<br />
<br />
<texcode><br />
\setfigureconversion[svg][mp]<br />
<br />
\starttext<br />
\externalfigure[kitten.jpg][width=2cm]<br />
\externalfigure[mill.png] [width=4cm]<br />
\externalfigure[cow.pdf] [width=6cm]<br />
\externalfigure[tiger.svg] [width=1cm]<br />
\stoptext<br />
</texcode><br />
<br />
= Transformations =<br />
<br />
== Image Scaling ==<br />
<br />
{{ note | If either <tt>width</tt> or <tt>height</tt> is specified, then the <tt>scale</tt> key has no effect. }}<br />
<br />
<br />
To scale an image use the <tt>scale</tt> key: <tt>scale=1000</tt> corresponds to the original dimensions of the image, <tt>scale=500</tt> scales the image to 50% of the original size, <tt>scale=1500</tt> scales the images to 150% of the original size, and so on. For example:<br />
<br />
<texcode>\externalfigure[logo.pdf][scale=500]</texcode><br />
<br />
scales the image to 50% of its size.<br />
<br />
Use <tt>\setupexternalfigures</tt> to set the scale of all images. For example, to scale all images to be twice their original size, use:<br />
<br />
<texcode>\setupexternalfigures[scale=2000]</texcode><br />
<br />
In addition, the <tt>xscale</tt> and <tt>yscale</tt> keys scale the image in only one dimension. For example:<br />
<br />
<texcode>\externalfigure[logo.pdf][xscale=500]<br />
\externalfigure[logo.pdf][yscale=500]</texcode><br />
<br />
Scaling changes the visible size of a picture, but not the data or file size. If you want to reduce your file size by decreasing image resolution, see [[Downsampling]].<br />
<br />
== Image Dimension Restriction ==<br />
<br />
ConTeXt can limit included images to particular dimensions. For example, to ensure that an included image is not more than <tt>0.2\textwidth</tt>:<br />
<br />
<texcode>\externalfigure[logo.pdf][maxwidth=0.2\textwidth]</texcode><br />
<br />
If <tt>maxwidth</tt> is specified and the width of the image is less than <tt>maxwidth</tt>, then the image is not scaled; if the width of the image is greater than <tt>maxwidth</tt>, then the width is restricted to <tt>maxwidth</tt> and the height is scaled appropriately to maintain the original aspect ratio.<br />
<br />
The option <tt>maxheight</tt> is analogous to <tt>maxwidth</tt>, for checking the height of the image.<br />
<br />
For example, to ensure that figures do not overflow the text~area, one may set:<br />
<br />
<texcode>\setupexternalfigures<br />
[maxwidth=\textwidth,<br />
maxheight=0.8\textheight]</texcode><br />
<br />
== Image Rotation ==<br />
<br />
Rotate included images by 90°, 180°, or 270° using the <tt>orientation</tt> key. For example:<br />
<br />
<texcode>\externalfigure[logo.pdf][orientation=90]</texcode><br />
<br />
To rotate by an arbitrary angle, use the {{cmd|rotate}} command. For example:<br />
<br />
<texcode>\rotate[rotation=45]{\externalfigure[logo.pdf]}</texcode><br />
<br />
== Image Mirroring ==<br />
<br />
To mirror (flip) an image, use the generic {{cmd|mirror}} command. For example, to mirror horizontally:<br />
<br />
<texcode>\mirror{\externalfigure[logo.pdf]}</texcode><br />
<br />
To mirror vertically, first rotate the image by 180° and then mirror it:<br />
<br />
<texcode>\mirror{\externalfigure[logo.pdf][orientation=180]}</texcode><br />
<br />
== Image Clipping ==<br />
<br />
Clip an image using the generic {{cmd|clip}} command. For example, to clip the original image to a <tt>1cm x 2cm</tt> rectangle at an offset of <tt>(3mm,5mm)</tt> from the top left corner:<br />
<br />
<texcode>\clip[width=1cm, height=2cm, hoffset=3mm, voffset=5mm]<br />
{\externalfigure[logo.pdf]}</texcode><br />
<br />
As another example, this cuts the image into a <tt>3x3</tt> pieces and then outputs the <tt>(2,2)</tt> piece:<br />
<br />
<texcode>\clip[nx=3,ny=3,x=2,y=2]<br />
{\externalfigure[logo.pdf]}</texcode><br />
<br />
<br />
In PDF files, it is possible to specify different size information in PDF headers MediaBox, TrimBox, CropBox, and ArtBox. To clip to one of these sizes, use<br />
<br />
<texcode>\externalfigure[logo.pdf][size=art]</texcode><br />
<br />
Other options are: `none` (detault), `media` for MediaBox, `crop` for CropBox, `trim` for TrimBox, and `art` for ArtBox.<br />
<br />
= Troubleshooting =<br />
<br />
This section describes various tips for discovering problems with embedded images.<br />
<br />
== Visualize Bounding Box ==<br />
<br />
If, for instance, the image is taking more space than expected, it can be useful to visualize the bounding box of the image. To do this:<br />
<br />
<texcode>\externalfigure[logo.pdf][frame=on]</texcode><br />
<br />
ConTeXt includes a Perl script <tt>pdftrimwhite</tt> that removes extra white space at the borders of a PDF file. To run this script:<br />
<br />
<pre>mtxrun --script pdftrimwhite [flags] input output</pre><br />
<br />
The most important flag is <tt>--offset=dimen</tt>, which keeps some extra space around the trimmed image.<br />
<br />
Similar functionality is provided by another Perl script, <tt>pdfcrop</tt>, that is included in most TeX distributions.<br />
<br />
== Diagnostic Tracking ==<br />
<br />
To get diagnostic information about image inclusion, enable the tracker <tt>graphics.locating</tt> by editing the ConTeXt file and adding:<br />
<br />
<texcode>\enabletrackers[graphics.locating]</texcode><br />
<br />
Alternatively, compile the ConTeXt file using:<br />
<br />
<texcode>context --trackers=graphics.locating filename</texcode><br />
<br />
The tracker writes diagnostics to the console. Suppose we use <tt>\externalfigure[somefile.pdf]</tt> and ConTeXt finds the file in the current search path; then the following information is printed on the console:<br />
<br />
<pre>graphics &gt; inclusion &gt; locations: local,global<br />
graphics &gt; inclusion &gt; path list: . .. ../..<br />
graphics &gt; inclusion &gt; strategy: forced format pdf<br />
graphics &gt; inclusion &gt; found: somefile.pdf -&gt; somefile.pdf<br />
graphics &gt; inclusion &gt; format natively supported by backend: pdf</pre><br />
If the file <tt>somefile.pdf</tt> is not found in the current search path, then the following information is printed on the console (even if the <tt>graphics.locating</tt> tracker is not set):<br />
<br />
<pre>graphics &gt; inclusion &gt; strategy: forced format pdf<br />
graphics &gt; inclusion &gt; not found: somefile.pdf<br />
graphics &gt; inclusion &gt; not found: ./somefile.pdf<br />
graphics &gt; inclusion &gt; not found: ../somefile.pdf<br />
graphics &gt; inclusion &gt; not found: ../../somefile.pdf<br />
graphics &gt; inclusion &gt; not found: images/somefile.pdf<br />
graphics &gt; inclusion &gt; not found: /home/user/images/somefile.pdf<br />
graphics &gt; inclusion &gt; format not supported: </pre><br />
and a placeholder gray box is put in the output:<br />
<br />
<context> </context><br />
<br />
Sometimes, one would rather use a placeholder image for an image that is yet to be made. In such cases, load the MP library <tt>dum</tt> via:<br />
<br />
<texcode>\useMPlibrary[dum]</texcode><br />
<br />
Then, whenever an image file is not found in the current search path, a random MetaPost image is shown in the output.<br />
<br />
<context> </context><br />
<br />
== Leading Paragraph ==<br />
<br />
Using {{cmd|externalfigure}}<tt>[...]</tt> at the beginning of a paragraph results in a line break after the image. This is because {{cmd|externalfigure}} is a {{cmd|vbox}} and when a {{cmd|vbox}} is encountered at (what appears to be) the beginning of a paragraph, it remains in vertical mode. To prevent this, add {{cmd|dontleavehmode}} before {{cmd|externalfigure}}, like this:<br />
<br />
<texcode>\dontleavehmode<br />
\externalfigure[...] ... first line ...</texcode><br />
<br />
= Multiple Image Settings =<br />
<br />
== Image Settings ==<br />
<br />
Suppose your document contains many side-by-side images, and you want all of these images to be of the same size. In addition, you want to control the size of all images by changing only one setup. To do this, you can use the {{cmd|defineexternalfigure}} macro, which defines a named collection of image settings. For example, to define a collection where the image width is <tt>3cm</tt>, use:<br />
<br />
<texcode>\defineexternalfigure[logo-settings]<br />
[width=3cm]</texcode><br />
<br />
And then to use these settings in an image, use:<br />
<br />
<texcode>\externalfigure[group.pdf][logo-settings]</texcode><br />
<br />
or, if you want to add or override settings, use:<br />
<br />
<texcode>\externalfigure[group.pdf][logo-settings]<br />
[height=2cm]</texcode><br />
<br />
== Image Labels ==<br />
<br />
Suppose your document contains an image at multiple locations; all of these images are to be of the same size, which is not necessarily the same as the natural size of the image. Furthermore, as before, you want to set the size of all the images by changing only one setup. Here, the macro to use is {{cmd|useexternalfigure}}, which defines a symbolic label for inserting an image plus settings. For example:<br />
<br />
<texcode>\useexternalfigure[mylogo]<br />
[logo.pdf][width=2cm]</texcode><br />
<br />
defines an image label <tt>mylogo</tt> that maps to the image file <tt>logo.pdf</tt> and sets its width to <tt>2cm</tt>. This image label may be used as a normal image filename:<br />
<br />
<texcode>\externalfigure[mylogo]</texcode><br />
<br />
<br />
= Movies =<br />
<br />
Movies aren't recognized automatically yet; they must be delcared verbosely:<br />
<br />
<texcode><br />
\externalfigure[demo.mov][label=demo,width=4cm,height=4cm,preview=yes]<br />
</texcode><br />
<br />
<tt>preview=yes</tt> shows the first image as preview.<br />
You find more about interactive Elements in [http://www.pragma-ade.nl/general/manuals/mwidget-s.pdf mwidget-s.pdf]<br />
<br />
Unfortunately, people who are fond of Linux cannot embed movies because the Linux release of acroread doesn't support that. An alternative solution consists in launching your prefered player (MPlayer) from acroread:<br />
<br />
<texcode><br />
\defineprogram[dummy.mpeg][dummy.mpeg.sh]<br />
<br />
\starttext<br />
\goto{\externalfigure[dummy-preview][width=0.48\textwidth]}[program(dummy.mpeg{})]<br />
\stoptext<br />
</texcode><br />
<br />
The script dummy.mpeg.sh should contain:<br />
<pre><nowiki><br />
FILE=$(basename "$0"); mplayer -fs -zoom ${FILE/.sh/}<br />
</nowiki></pre><br />
<br />
<br />
[[Category:Graphics]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/type&diff=34323Command/type2024-02-03T15:21:12Z<p>Zsd: Add an example showing the use of 'compact=last'.</p>
<hr />
<div><cd:commandgroup name="type" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"><br />
<cd:shortdesc>The command <tt>\type</tt> typesets verbatim TeX code<br />
</cd:shortdesc><br />
<cd:variants><br />
<cd:command category="verbatim" file="buff-ver.mkiv" interfacedate="2020-07-14T09:24" interfacefile="i-verbatim.xml" level="document" name="type" variantnumber="1"><br />
<cd:arguments><br />
<cd:assignments list="yes" optional="yes" ordinal="1"><br />
<cd:assignmentsdoc></cd:assignmentsdoc><br />
<cd:inherit name="setuptype"></cd:inherit><br />
</cd:assignments><br />
<cd:content ordinal="2"></cd:content><br />
</cd:arguments><br />
</cd:command><br />
<cd:command category="verbatim" file="buff-ver.mkiv" interfacedate="2020-07-14T09:24" interfacefile="i-verbatim.xml" level="document" name="type" variant="angles" variantnumber="2"><br />
<cd:arguments><br />
<cd:assignments list="yes" optional="yes" ordinal="1"><br />
<cd:assignmentsdoc></cd:assignmentsdoc><br />
<cd:inherit name="setuptype"></cd:inherit><br />
</cd:assignments><br />
<cd:angles ordinal="2"></cd:angles><br />
</cd:arguments><br />
</cd:command><br />
</cd:variants><br />
<cd:description>Verbatim text, typeset in typewriter font.<br />
<br />
In a caption (and probably other places), {{cmd|type}} can cause errors if it<br />
contains active characters (<tt>|</tt> for example). You can use<br />
<texcode>\type{...}\type{|}\type{...}</texcode> as a workaround, since the first character is not expanded.<br />
<br />
<br />
</cd:description><br />
<cd:examples><cd:example title=""><context source="yes"><br />
Plain example: \type{\bf You can type any %ld thing you |ike, even command$.}<br />
<br />
Alternate delimiters: \type-You can choose your own delimiters-<br />
<br />
With options \type[option=TEX]{\ConTeXt\ colouring}<br />
</context></cd:example><cd:example title="Preserving some spaces needs more work"><context source="yes"><br />
In some cases spaces disappear unless you do a bit more work. For example, notice the missing space here: \type{\someCommand [option]}.<br />
<br />
The following usage preserves that space: \type[compact=last]{\someCommand [option]}.<br />
</context></cd:example></cd:examples><br />
<cd:notes></cd:notes><br />
<cd:seealso><br />
<cd:commandref name="definetype" originator="system"></cd:commandref><br />
<cd:commandref name="setuptype" originator="system"></cd:commandref><br />
<cd:source file="buff-ver.mkiv" originator="system"></cd:source><br />
<cd:wikipage originator="system" page="Category:Verbatim"></cd:wikipage><br />
<cd:commandref name="starttyping"></cd:commandref><br />
<cd:wikipage page="Verbatim text"></cd:wikipage></cd:seealso><br />
</cd:commandgroup></div>Zsdhttps://wiki.contextgarden.net/index.php?title=User:Zsd&diff=34322User:Zsd2024-02-03T15:11:08Z<p>Zsd: </p>
<hr />
<div>My real name is Jim Diamond, I live in Nova Scotia, Canada.<br />
<br />
I am a long-time (since 1984, ±ϵ) plain TeX user, and in 2023 I decided to finally learn (and start using) ConTeXt.<br />
<br />
I am mostly just another ConTeXt user, but I make additions/corrections to the wiki whenever I feel sure I know the right changes to make.</div>Zsdhttps://wiki.contextgarden.net/index.php?title=User:Zsd&diff=34321User:Zsd2024-02-03T15:09:02Z<p>Zsd: </p>
<hr />
<div>My real name is Jim Diamond, I live in Nova Scotia, Canada.<br />
<br />
I am a long-time (since 1984, ±ϵ) plain TeX user, and in 2023 I decided to finally learn (and start using) ConTeXt.</div>Zsdhttps://wiki.contextgarden.net/index.php?title=User:Zsd&diff=34320User:Zsd2024-02-03T15:06:46Z<p>Zsd: </p>
<hr />
<div>My real name is Jim Diamond, I live in Nova Scotia, Canada.<br />
<br />
I am a long-time (since 1984, ��) plain TeX user, and in 2023 I decided to finally learn (and start using) ConTeXt.</div>Zsdhttps://wiki.contextgarden.net/index.php?title=User:Zsd&diff=34319User:Zsd2024-02-03T15:05:14Z<p>Zsd: Created page with "My real name is Jim Diamond, I live in Nova Scotia, Canada. I am a long-time (since 1984, $\pm$) plain TeX user, and in 2023 I decided to finally learn (and start using) ConT..."</p>
<hr />
<div>My real name is Jim Diamond, I live in Nova Scotia, Canada.<br />
<br />
I am a long-time (since 1984, $\pm$) plain TeX user, and in 2023 I decided to finally learn (and start using) ConTeXt.</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Line_breaks_marker&diff=34318Line breaks marker2024-02-03T15:00:11Z<p>Zsd: Former example didn't work any more (2024/02). Removed part of example whose purpose I could not devine and made the rest work.</p>
<hr />
<div>== End of line marker in verbatim texts ==<br />
<br />
from the wizard himself:<br />
<br />
<context source="yes" text="looks like this:"><br />
\startreusableMPgraphic{return}<br />
drawarrow<br />
(0,0)--<br />
(1EmWidth,0)--<br />
(1EmWidth,-.5ExHeight)--<br />
(.5EmWidth,-.5ExHeight) ;<br />
\stopreusableMPgraphic<br />
<br />
\definesymbol[return][\reuseMPgraphic{return}]<br />
<br />
\setupcolors[state=start]<br />
<br />
\def\vcrlf{\symbol[return]\crlf\strut\kern1em\strut\ignorespaces}<br />
<br />
\setuptyping[TEX][escape=yes]<br />
<br />
\startTEX<br />
test test test /BTEX\vcrlf/ETEX test test<br />
\stopTEX<br />
<br />
</context><br />
<br />
[[Category:Basics]]<br />
[[Category:Tools]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/writetolist&diff=34317Command/writetolist2024-02-01T00:41:24Z<p>Zsd: Fix two typos.</p>
<hr />
<div><cd:commandgroup name="writetolist" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"><br />
<cd:shortdesc>The command <tt>\writetolist</tt> is used to write entries to a defined list.<br />
</cd:shortdesc><br />
<cd:variants><br />
<cd:command category="structure" file="strc-lst.mkvi" interfacedate="2020-07-14T09:24" interfacefile="i-list.xml" level="document" name="writetolist" variantnumber="1"><br />
<cd:arguments><br />
<cd:keywords ordinal="1"><br />
<cd:keywordsdoc></cd:keywordsdoc><br />
<cd:constant type="cd:list">The name of a list defined with {{cmd|definelist}}</cd:constant><br />
</cd:keywords><br />
<cd:assignments list="yes" optional="yes" ordinal="2"><br />
<cd:assignmentsdoc></cd:assignmentsdoc><br />
<cd:inherit name="setuplist"></cd:inherit><br />
</cd:assignments><br />
<cd:keywords delimiters="braces" ordinal="3"><br />
<cd:keywordsdoc></cd:keywordsdoc><br />
<cd:constant type="cd:number">The "item number"</cd:constant><br />
</cd:keywords><br />
<cd:keywords delimiters="braces" ordinal="4"><br />
<cd:keywordsdoc></cd:keywordsdoc><br />
<cd:constant type="cd:text">Actual text</cd:constant><br />
</cd:keywords><br />
</cd:arguments><br />
</cd:command><br />
</cd:variants><br />
<cd:description>If you use this command after an unnumbered section command beware that it will become a candidate for a page break. A workaround is:<br />
<br />
<texcode><br />
\subject{\bf My title!}<br />
\dontleavehmode<br />
\writetolist[myrandompart]{}{It's a test}<br />
</texcode><br />
<br />
However, according to mailing list messages (from 2010), keep in mind that it introduces 'something' in the text stream, so when whitespace is setup, in some cases you can get some extra. Also, this box can end up on the current page or the next one, depending on the circumstances. In practice it's no real problem as one will do explicit writes inside boxes or so. I.e., just bind the write to some text.<br />
<br />
In addition you might get spurious spaces after this command. So it is best to add a % sign after it.<br />
<br />
The default table of contents is a combined list. To write to it one has to choose the level to which it should be inserted: <tt>\writetolist[chapter]{1.}{Chapter list entry A}</tt>, <tt>\writetolist[section]{1.1}{Section list entry A}</tt>, etc.<br />
</cd:description><br />
<cd:examples><cd:example title=""><texcode><br />
\definelist[Reprints][criterium=all]<br />
<br />
\starttext<br />
\section{Sec 1}<br />
\writetolist[Reprints]{1.}{List entry A}%<br />
\writetolist[Reprints]{}{With no number}%<br />
\subsection{Subsec 1}<br />
\writetolist[Reprints]{2.}{List entry B}%<br />
\completelist[Reprints]<br />
\stoptext<br />
</texcode></cd:example></cd:examples><br />
<cd:notes></cd:notes><br />
<cd:seealso><br />
<cd:commandref name="definelist" originator="system"></cd:commandref><br />
<cd:commandref name="setuplist" originator="system"></cd:commandref><br />
<cd:source file="strc-lst.mkvi" originator="system"></cd:source><br />
<cd:wikipage originator="system" page="Category:Structure"></cd:wikipage><br />
<cd:commandref name="writebetweenlist"></cd:commandref></cd:seealso><br />
</cd:commandgroup></div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/starttable&diff=34316Command/starttable2024-01-26T15:54:14Z<p>Zsd: Minor spelling corrections.</p>
<hr />
<div><cd:commandgroup name="table" type="environment" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"><br />
<cd:shortdesc><!-- a short command summary goes here --><br />
The environment <tt>\starttable ... \stoptable</tt> is an old and nearly obsolete way to handle tabular material<br />
</cd:shortdesc><br />
<cd:variants><br />
<cd:command category="tables" file="tabl-tab.mkiv" interfacedate="2020-06-19T13:41" interfacefile="i-table.xml" level="document" name="table" type="environment" variantnumber="1"><br />
<cd:arguments><br />
<cd:template ordinal="1"></cd:template><br />
<cd:assignments list="yes" optional="yes" ordinal="2"><br />
<cd:assignmentsdoc></cd:assignmentsdoc><br />
<cd:inherit name="setuptables"></cd:inherit><br />
</cd:assignments><br />
</cd:arguments><br />
</cd:command><br />
<cd:command category="tables" file="tabl-tab.mkiv" interfacedate="2020-06-19T13:41" interfacefile="i-table.xml" level="document" name="table" type="environment" variant="name" variantnumber="2"><br />
<cd:arguments><br />
<cd:keywords ordinal="1"><br />
<cd:keywordsdoc></cd:keywordsdoc><br />
<cd:constant type="cd:name"></cd:constant><br />
</cd:keywords><br />
<cd:assignments list="yes" optional="yes" ordinal="2"><br />
<cd:assignmentsdoc></cd:assignmentsdoc><br />
<cd:inherit name="setuptables"></cd:inherit><br />
</cd:assignments><br />
</cd:arguments><br />
</cd:command><br />
</cd:variants><br />
<cd:description>The table entries are placed between the <code>\starttable</code> ... <code>\stoptable</code> pair. Between the bracket pair your can specify the table format template using column separators <code>|</code> and format keys, or using the name of a defined table template (see {{cmd|definetabletemplate}}).<br />
<br />
There is a long wiki page about [[Table]] macros, and the macros have been superseded by different macros sets, so this page is intentionally kept short. The [[Tables Overview]] page contains a quick overview of all the tabular macro environments and their pros and cons.</cd:description><br />
<cd:examples><cd:example title="">The command {{cmd|placetable}} on the first line has the same function as {{cmd|placefigure}}. It takes care of spacing before and after the table and numbering. Furthermore the floating mechanism is initialised so the table will be placed at the most optimal location on the page.<br />
<br />
<br />
<context source="yes" text="yields"><br />
\placetable[here][tab:ships]{Ships that moored at Hasselt.}<br />
\starttable[|c|c|]<br />
\HL<br />
\NC \bf Year \NC \bf Number of ships \NC\SR<br />
\HL<br />
\NC 1645 \NC 450 \NC\FR<br />
\NC 1671 \NC 480 \NC\MR<br />
\NC 1676 \NC 500 \NC\MR<br />
\NC 1695 \NC 930 \NC\LR<br />
\HL<br />
\stoptable<br />
<br />
...<br />
<br />
See \in{Table}[tab:ships].<br />
</context></cd:example></cd:examples><br />
<cd:notes></cd:notes><br />
<cd:seealso><br />
<cd:commandref name="setuptables" originator="system"></cd:commandref><br />
<cd:source file="tabl-tab.mkiv" originator="system"></cd:source><br />
<cd:wikipage originator="system" page="Category:Tables"></cd:wikipage><br />
<cd:wikipage page="Table">wiki manual page for tables using this macro set</cd:wikipage><br />
<cd:wikipage page="Tables_Overview">for a global intro to the various table macro sets in ConTeXt</cd:wikipage><br />
<cd:commandref name="definetabletemplate"></cd:commandref></cd:seealso><br />
</cd:commandgroup></div>Zsdhttps://wiki.contextgarden.net/index.php?title=Table&diff=34315Table2024-01-26T15:48:15Z<p>Zsd: Minor grammatical corrections.</p>
<hr />
<div>< [[Tables Overview]] | [[Tabulate]] | [[Tables]] ><br />
<br />
This is ConTeXt's oldest table module. It uses the same formatting as [[Tabulate]] (see [[Tables Overview]]).<br />
<br />
This mode is based on Michael Wichura's TaBlE package for Plain TeX. The official manual for it is commercial (18 USD), see [http://www.pctex.com/books.html PCTeX] -- but note that the TaBlE manual only talks about the original syntax, which does not use {{cmd|NC}}, {{cmd|HL}}, cum suis.<br />
<br />
The only ConTeXt docs are in [[manual:ms-cb-en.pdf|ConTeXt - an excursion]]. There are also two introductory articles in TUGboat [http://tug.org/TUGboat/Articles/tb28-3/tb90mahajan.pdf ConTeXt basics for users: Table macros] [http://www.tug.org/TUGboat/Articles/tb29-1/tb91mahajan.pdf Table macros II] by Aditya Mahajan (2007 and 2008).<br />
<br />
== Basic Commands ==<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
* You get vertical lines (rules), if you use {{cmd|VL}} instead of {{cmd|NC}}.<br />
* Better use {{cmd|SR}}, {{cmd|FR}}, {{cmd|MR}}, {{cmd|LR}} instead of {{cmd|NR}}.<br />
* You can also use {{cmd|AR}} instead of {{cmd|SR}}, {{cmd|FR}}, {{cmd|MR}} and {{cmd|LR}} (AR for automatic row).<br />
* You can leave out the {{cmd|NC}} before the "row" command, but not if you use {{cmd|AR}} in a last or single row (see example).<br />
* You can influence the table with {{cmd|setuptables}}.<br />
<br />
==Column Definition==<br />
<br />
The table is defined by the template enclosed in square brackets after {{cmd|starttable}}. The template has the form<br />
<br><br />
<tt>|keys for the first column|keys for the second column|...|keys for the last column|</tt>.<br />
<br><br />
Please note that each column is surrounded by <tt>|</tt> signs. These are necessary. The formatting keys for each column can be a choice of<br />
<br />
{| class="wikitable"<br />
! Key<br />
! Meaning<br />
|-<br />
! colspan="2" | Primitive Keys<br />
|-<br />
| <code>a{<em>tokens</em>}</code><br />
| Adds <code><em>tokens</em></code> <em>after</em> the column content<br />
|-<br />
|-<br />
| <code>b{<em>tokens</em>}</code><br />
| Adds <code><em>tokens</em></code> <em>before</em> the column content<br />
|-<br />
| <code>\{</code><br />
| Enclose the column in braces (grouping)<br />
|-<br />
| <code>*{<em>n</em>}{<em>keys</em>}</code><br />
| Equivalent to repeating the formatting keys <code><i>keys</i></code> <code><i>n</i></code> times<br />
|-<br />
! colspan="2" | Positioning Keys<br />
|-<br />
| <code>\LeftGlue</code><br />
| Specifies the left glue to be used before the column<br />
|-<br />
| <code>\RightGlue</code><br />
| Specifies the right glue to be used after the column<br />
|-<br />
| <code>l</code><br />
| left-aligned column<br />
|-<br />
| <code>c</code><br />
| centered column<br />
|-<br />
| <code>r</code><br />
| right-aligned column<br />
|-<br />
| <code>p(<em>width</em>)</code><br />
| Set each cell as a paragraph<br />
|-<br />
| <code>s(<em>width</em>)</code><br />
| Specify the inter-column width<br />
|-<br />
| <code>w</code><br />
| Set minimum column width<br />
|-<br />
| <code>k</code><br />
| Insert a kern both left and right of the column<br />
|-<br />
| <code>i</code><br />
| Add a kern to the left of the column<br />
|-<br />
| <code>j</code><br />
| Add a kern to the right of the column<br />
|-<br />
! colspan="2" | Numeric and Math Item Keys<br />
|-<br />
| <code>n</code><br />
| Numeric item not in math mode<br />
|-<br />
| <code>N</code><br />
| Numeric item in math mode<br />
|-<br />
| <code>m</code><br />
| Each cell is in (inline) math mode. Equivalent to <code>b$ a$</code><br />
|-<br />
| <code>M</code><br />
| Each cell is in display math mode. Equivalent to <code>\{b{$\displaystyle}a$}</code><br />
|-<br />
| <code>\m</code><br />
| Equivalent to 1 <code>l b{{}}m</code><br />
|-<br />
| <code>\M</code><br />
| Equivalent to 1 <code>l b{{}}M</code><br />
|-<br />
! colspan="2" | Style Keys<br />
|-<br />
| <code>f\<em>command</em></code><br />
| Set font according to following <code><em>command</em></code><br />
|-<br />
| <code>B</code><br />
| Bold. Equivalent to <code>f\bf</code><br />
|-<br />
| <code>I</code><br />
| Italic. Equivalent to <code>f\it</code><br />
|-<br />
| <code>S</code><br />
| Slanted. Equivalent to <code>f\sl</code><br />
|-<br />
| <code>R</code><br />
| Roman. Equivalent to <code>f\rm</code><br />
|-<br />
| <code>T</code><br />
| Teletype. Equivalent to <code>f\tt</code><br />
|-<br />
| <code>C</code><br />
| Color. Use it in combination with <code>\{</code> (e.g. <code>\{C{<em>red</em>}</code>)<br />
|-<br />
! colspan="2" | Tabskip Keys<br />
|-<br />
| <code>s</code><br />
| Set the tabskip to the right of this column and of all following columns up to the next <code>s</code> or <code>o</code> key<br />
|-<br />
| <code>o</code><br />
| Set the tabskip to the right of this column only<br />
|-<br />
|}<br />
<br />
=== Column definition examples===<br />
; <code>|l|</code> : a left aligned column, as wide as necessary<br />
; <code>|lw(2cm)|</code> : a left aligned column of at least 2 cm width<br />
; <code>|p(2cm)|</code> : a centered(!) paragraph of 2 cm width<br />
; <code>|lp(.5\textwidth)|</code> : a left aligned paragraph of specified width<br />
; <code>|rp(.5\textwidth)|</code> : a right aligned paragraph of specified width<br />
; <code>|cp(.5\textwidth)|</code> : a center aligned paragraph of specified width<br />
; <code>|xp(.5\textwidth)|</code> : a justified paragraph of specified width<br />
<br />
{{todo|add more examples of column definitions}}<br />
<br />
==Column Spans==<br />
<br />
It's possible to create columnspans (i.e., cells that span more than one column) with the command {{cmd|use|{<i>N</i>}}} where ''N'' is the number of columns spanned by the cell. It's often necessary to use {{cmd|ReFormat|[<i>new keys</i>]{}}} to reformat this specific cell according to the ''new keys''.<br />
<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR % slightly shorted<br />
\HL<br />
\NC left text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR<br />
\HL<br />
\NC left text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
<br />
({{cmd|ReFormat}} can be abbreviated {{cmd|REF}} for brevity.)<br />
<br />
== Row Spans==<br />
<br />
It's also possible to create rowspans (i.e. cells that span more than one row) with the command {{cmd|Raise|(<i>dimen</i>){<i>content</i>}}} or {{cmd|Lower|(<i>dimen</i>){</i>content</i>}}} that raise or lower ''content'' by ''dimen''.<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
({{cmd|Lower|(.5\lineheight){a}}} can be abbreviated {{cmd|LOW|{a}}} for brevity.)<br />
<br />
An alternative means of spanning rows by a tall object makes use of a bit of TeX magic:<br />
{{cmd|smash|{tall object}}}:<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
==Table as Floating Object==<br />
<br />
<texcode><br />
\placetable[here][tab:sample]{sample table}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
* See [[Floating Objects]] in general.<br />
* If you need information about {{cmd|placetable}} look after {{cmd|placefloat}} in the manual or texshow!<br />
* If you do not want a caption for your table, to get rid of it altogether you have to add "none" to settings and then leave the braces empty; if you only leave the braces empty, your table will still be numbered ("Table 1" etc.).<br />
<br />
<texcode><br />
\placetable[here,none][tab:sample]{}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
==Background Colors==<br />
<br />
Note: Adding color to tables using the `\CL` and `\BL` commands appears to be deprecated in MKIV; see: http://wiki.contextgarden.net/Tabulate<br />
<br />
A very nice application in table are background colors for rows/cells (a feature that doesn't work in [[Tabulate]]):<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><br />
</tr></table><br />
The commands work something like this: first, you say what background colour you want for the next row<br />
and then you typeset the row. Observe: the line with the colour-command and the row it is supposed<br />
to colour should end in the same command (i.e. both \SR, \LR, \FR, ...). If they don't, the background<br />
won't cover the whole cell.<br />
<br />
* {{cmd|BL}} makes a gray background: the optional argument tells BL how many cells it should color<br />
* {{cmd|CL}} makes a colored row<br />
<br />
==Fit Table Width==<br />
<br />
Hans posted a solution to the list for fitting a wide table (with paragraphs and vertical lines) to the page width. The key to his solution is the <code>.45\textwidth</code> settings when setting each cell as a paragraph.<br />
<br />
<texcode><br />
\SetTableToWidth{\textwidth}<br />
<br />
\starttable[|p(.45\textwidth)|p(.45\textwidth)|]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<!-- It makes no sense to typeset this here. --><br />
<br />
Since the table module has been under [http://www.ntg.nl/pipermail/ntg-context/2010/055004.html reconstruction] this approach works only for MKII. In MKIV one can use <br />
<br />
<texcode><br />
\starttable[|l|l|][textwidth=max]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<br />
to change the width of the current table only.<br />
<br />
<code>\setuptables[textwidth=...]</code> will affect the behavior of every table.<br />
<br />
== Booktabs ==<br />
<br />
Latex has an excellent package called booktabs for typesetting tables. The main features of that package is that you can have top, mid, and bottom rules of different thickness. It is possible to achieve similar effects using table. For example, to match the default settings of booktabs (well almost, this gives a top and bottom rules of 0.09em while booktabs sets it to 0.08em).<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
[[Category:Tables]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Framed&diff=34314Framed2024-01-24T22:12:48Z<p>Zsd: Fix typesetting of \, in its explanation.</p>
<hr />
<div>= How to achieve specific results =<br />
<br />
== Preventing hyphenation ==<br />
<br />
One can prevent hyphenation inside a frame by passing {{code|1=nothypenated}} option to {{code|1=align}}. It is also a good idea to add {{code|1=verytolerant}} and {{code|1=stretch}} options.<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\startcombination[2*2]<br />
{\framed<br />
[width=5cm,<br />
align={flushleft}]<br />
{\input ward \endgraf}}<br />
{flushleft}<br />
{\framed<br />
[width=5cm,<br />
align={flushleft,nothyphenated,verytolerant}] % maybe also stretch<br />
{\input ward \endgraf}}<br />
{flushleft,\crlf nothyphenated, \crlf verytolerant}<br />
{\framed<br />
[width=5cm,<br />
align={flushright,nothyphenated,verytolerant}] % maybe also stretch<br />
{\input ward \endgraf}}<br />
{flushright,\crlf nothyphenated, \crlf verytolerant}<br />
{\framed<br />
[width=5cm,<br />
align={width,nothyphenated,verytolerant}] % maybe also stretch<br />
{\input ward \endgraf}}<br />
{width,\crlf nothyphenated, \crlf verytolerant}<br />
\stopcombination<br />
</context><br />
<br />
== Specify the width no longer than needed ==<br />
<br />
I want to specify the maximum width of a frame. If the size of the box is smaller than the maximum width, I want a tight box. This can be done using the {{code|1=autowidth=force}} option to framed.<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\defineframed<br />
[tightframed][width=5cm,autowidth=force,align=middle]<br />
<br />
\tightframed{Small}<br />
<br />
\tightframed{A really really long line that is split at 5cm}<br />
<br />
</context><br />
<br />
== Ruled Frames ==<br />
<br />
{{cmd|framed}} allows you to specify specific edges to be ruled.<br />
As an alternative to {{code|1=frame=on}} (the default), one can specify<br />
{{code|1=topframe=on}}, etc.<br />
Note that, as the default is to draw a complete frame,<br />
it is necessary to either specify the state (on/off) for all four edges<br />
or include the keyword {{code|1=frame=off}}.<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\framed[frame=off,topframe=on,leftframe=on]{A fancy title}<br />
</context><br />
<br />
The thickness of the frame rule can be specified using {{code|1=rulethickness=}}<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\framed[frame=off,leftframe=on,rulethickness=2pt]{\tfa\bf A fancy title}<br />
</context><br />
<br />
== Rounded Corners ==<br />
<br />
{{cmd|framed}} allows you to have round corners with {{code|1=corner=round}}. There are also other possibilities if you want round corners but not at all places by giving an appropriate number to {{code|1=corner=...}}. This example is taken from [[source:core-rul.tex | core-rul.tex]] and each frame is typeset using<br />
<br />
<texcode><br />
\framed[corner=....,frame=on]{...}<br />
</texcode><br />
<br />
<context><br />
\setuppapersize[A5]<br />
\dontleavehmode\framed<br />
[corner=0,frame=on,<br />
]{\tttf corner=\twodigits\recurselevel}%<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse {1} {4}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse {5} {8}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse {9}{12}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse{13}{16}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse{17}{20}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse{21}{24}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
\vskip1em<br />
\dontleavehmode\dostepwiserecurse{25}{28}{1}{\framed<br />
[corner=\recurselevel,frame=on]<br />
{\tttf corner=\twodigits\recurselevel}%<br />
\quad}<br />
</context><br />
<br />
* You can only fill the frame with a background color if the corner shape is closed. Otherwise, the backgroundcolor option will be silently ignored.<br />
<br />
<br />
== Coloring frame background and framed text ==<br />
<br />
First you have to turn on colors with {{cmd|setupcolors|2=[state=start]}}. Then you can define the background and foreground (=text) colors:<br />
<br />
<texcode>\framed[background=color,backgroundcolor=....,foreground=color,foregroundcolor=...]{...}</texcode><br />
<br />
If you want to make the frame itself disappear, add a {{code|1=frame=off}} to the setups.<br />
<br />
{|<br />
|<context><br />
\setupcolors[state=start]<br />
\framed<br />
[background=color,backgroundcolor=darkblue,<br />
foreground=color,foregroundcolor=white]<br />
{\ssx \bf Bold white on dark blue}<br />
</context><br />
|<texcode><br />
\setupcolors[state=start]<br />
\framed<br />
[background=color,backgroundcolor=darkblue,<br />
foreground=color,foregroundcolor=white]<br />
{\ssx \bf Bold white on dark blue}<br />
</texcode><br />
|-<br />
|<context><br />
\setupcolors[state=start]<br />
\framed<br />
[background=color,backgroundcolor=yellow,<br />
frame=off]<br />
{\tfx Who needs highlighter pens, anyway?}<br />
</context><br />
|<texcode><br />
\framed<br />
[background=color,backgroundcolor=yellow,<br />
frame=off]<br />
{\tfx Who needs highlighter pens, anyway?}<br />
</texcode><br />
|-<br />
|<context><br />
\setupcolors[state=start]<br />
\framed<br />
[frame=on, corner=0, frameoffset=10pt,<br />
framecolor=black,background=color,<br />
backgroundcolor=darkgreen, backgroundoffset=10pt,<br />
foreground=color,foregroundcolor=white]<br />
{\tfxx \bf Rounded corners with offset}<br />
</context><br />
|For filling frames with offset you have to add options {{code|1=frameoffset=..., backgroundoffset=...}}<br />
<texcode><br />
\framed<br />
[frame=on, corner=0, frameoffset=10pt,<br />
framecolor=black,background=color,<br />
backgroundcolor=darkgreen, backgroundoffset=10pt, <br />
foreground=color,foregroundcolor=white]<br />
{\tfxx \bf Rounded corners with offset}<br />
</texcode><br />
|}<br />
<br />
See the [[Color]] article for more information on available colors and color usage.<br />
<br />
== Shaded background for part of a displayed equation ==<br />
<br />
To highlight part of a formula, you can give it a gray background using {{cmd|mframed}}:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\setupcolors[state=start]<br />
\def\graymath{\mframed[frame=off,<br />
background=color,<br />
backgroundcolor=gray,<br />
backgroundoffset=3pt]}<br />
<br />
\startformula<br />
\ln (1+x) =\, \graymath{x - {x^2\over2}} \,+ {x^3\over3}-\cdots.<br />
\stopformula<br />
</context><br />
<br />
The {{code|\,}} adds a tiny bit of space to prevent the gray background from crowding the equals and plus sign.<br />
<br />
== Inline Frames ==<br />
<br />
The command {{cmd|inframed}}, similar to {{cmd|framed}},<br />
differs in the definition of the baseline:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\framed[frame=off,width=10em,align=flushleft]{%<br />
Notice the difference between<br />
\framed{framed} and \inframed{inframed},<br />
especially considering its effect on linespacing...<br />
}<br />
</context><br />
<br />
== Dotted Frames ==<br />
<br />
Using MetaPost:<br />
<br />
<texcode><br />
\startuniqueMPgraphic{Label}<br />
path p; p := (0,0) -- (OverlayWidth,0) -- (OverlayWidth, OverlayHeight) -- (0, OverlayHeight) -- (0,0);<br />
draw p withpen pencircle scaled 1pt dashed withdots;<br />
setbounds currentpicture to boundingbox OverlayBox;<br />
\stopuniqueMPgraphic<br />
\defineoverlay[Label][\useMPgraphic{Label}]<br />
\def\DotPicture#1#2#3%<br />
{%<br />
\placefigure[][#3]{#2}%<br />
{%<br />
\framed[align={flushleft, low},%<br />
frame=off,%<br />
height=3in,%<br />
width=broad]%<br />
{%<br />
\externalfigure[#1]%<br />
[width=3in,%<br />
background=Label,%<br />
backgroundoffset=1ex]%<br />
}%<br />
}%<br />
}%<br />
\def\DotText#1%<br />
{%<br />
\framed[frame=off,%<br />
background=Label,%<br />
location=low]%<br />
{%<br />
#1<br />
}%<br />
}%<br />
\starttext<br />
<br />
\DotPicture{sample/cow.pdf}{All your base are belong to us}{SampleRef}%<br />
<br />
AAA \DotText{BBB} CCC \DotText{DDD}<br />
\stoptext<br />
</texcode><br />
[[File:dotted_frame_mpost.png|650px]]<br />
<br />
Using TikZ:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\usemodule[tikz]%<br />
\tikzstyle{block}=[rectangle,draw=black,text centered,style=dotted,inner sep=0pt]<br />
\def\Picture#1#2#3%<br />
{<br />
\placefigure[left][#3]{#2}%<br />
{%<br />
\tikzpicture%<br />
\node[block](init){\externalfigure[#1][width=3in]};%<br />
\endtikzpicture%<br />
}%<br />
}%<br />
\starttext<br />
\Picture{sample/cow.pdf}{All your base are belong to us}{SampleRef}<br />
\stoptext<br />
</context><br />
<br />
<br />
== Colorored horizontal stripe of full paper width ==<br />
<br />
<context mode="mkiv" source="yes"><br />
\definepapersize[sheet][width=120mm,height=60mm]<br />
\setuppapersize[sheet]<br />
\setuppagenumbering[location=]<br />
\setuplayout<br />
[width=110mm,<br />
backspace=5mm,<br />
topspace=5mm,<br />
header=5mm,<br />
headerdistance=5mm,<br />
footer=5mm,<br />
footerdistance=5mm]<br />
<br />
\showframe<br />
<br />
\setupbackgrounds[page] [background=color, backgroundcolor=lightgray]<br />
<br />
\startuniqueMPgraphic{whatever}<br />
fill OverlayBox <br />
leftenlarged BackSpace rightenlarged CutSpace<br />
withcolor OverlayColor;<br />
setbounds currentpicture to OverlayBox enlarged max(BackSpace,CutSpace);<br />
\stopuniqueMPgraphic<br />
<br />
\defineoverlay[whatever][\uniqueMPgraphic{whatever}]<br />
\starttext<br />
<br />
Here some text first.<br />
<br />
\framed[background=whatever,backgroundcolor=green,frame=off,width=\textwidth]{test}<br />
<br />
After, again some text.<br />
<br />
\stoptext<br />
<br />
</context><br />
<br />
= Width broad and local =<br />
Sometimes {{code|1=width}} must be adapted to a "local" {{code|1=\hsize }}<br />
(the actual text area used by TeX to determine line breaks).<br />
For example:<br />
<context source='yes'><br />
\setuppapersize[A5]<br />
\setuppapersize[A7,landscape][A7,landscape]<br />
\setupbodyfont[8pt,ss]<br />
\starttext<br />
\framed[width=broad]{}<br />
\startnarrower[left]<br />
\framed[width=broad]{}<br />
\dontleavehmode\framed[width=broad]{}<br />
\dontleavehmode\framed[width=local]{}<br />
\stopnarrower<br />
\blank<br />
\hsize.5\hsize<br />
\framed[width=broad]{}<br />
\startnarrower[left]<br />
\framed[width=broad]{}<br />
\dontleavehmode\framed[width=broad]{}<br />
\dontleavehmode\framed[width=local]{}<br />
\stopnarrower<br />
\stoptext<br />
</context><br />
<br />
Here we use {{code|1=\setlocalhsize}} after {{code|1=\startitemize}} to setup the localhsize:<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\setuppapersize[A7,landscape][A7,landscape]<br />
\setupbodyfont[8pt,ss]<br />
\setupcolors[state=start]<br />
\setupframed[framecolor=blue]<br />
\showframe<br />
\starttext<br />
\framed[width=\hsize,align=middle]{width=hsize}<br />
\startitemize<br />
\setlocalhsize<br />
\item \framed[width=\hsize,align=middle] {width=hsize}<br />
\item \framed[width=broad,align=middle] {width=broad}<br />
\item \framed[width=local,align=middle] {width=local}<br />
\stopitemize<br />
\stoptext<br />
</context><br />
<br />
=Spacing between frame and text=<br />
<br />
{{cmd|framed}} comes with two different types of offsets:<br />
one for the frame itself and another for the its content.<br />
The parameters {{code|1=frameoffset}} and {{code|1=backgroundoffset}}<br />
were already explained above in the section [[#Coloring frame background and framed text]].<br />
<br />
In addition, the parameter [strut=no] allows removal of the initial strut when framing text that is [[Verbatim with line breaks]].<br />
<br />
==Content offsets==<br />
Beyond those there is another four dimensions that enable you to control <br />
the safety distance of a {{cmd|framed}}’s content by orientation.<br />
Horizontally, {{code|1=loffset}} governs the left, {{code|1=roffset}} the right<br />
offset;<br />
the same goes for {{code|1=boffset}} for the bottom and {{code|1=toffset}} for <br />
the top distance.<br />
Their effects are explored in the following example (MkIV only).<br />
<br />
==Example==<br />
<texcode><br />
\def\offsetframe[#1]{%<br />
{\framed[<br />
#1=1em,<br />
align=normal,<br />
width=5.3cm,<br />
height=5.3cm,<br />
]{\tfx\input ward }<br />
}{\it#1}<br />
}<br />
<br />
\starttext<br />
\startcombination[2*2]<br />
\offsetframe[loffset]<br />
\offsetframe[roffset]<br />
\offsetframe[toffset]<br />
\offsetframe[boffset]<br />
\stopcombination<br />
\stoptext<br />
</texcode><br />
<br />
==More offset parameters==<br />
Also, you can set up <nowiki>offset</nowiki>, which sets up all the <nowiki>[lrtb]offset</nowiki> parameters.<br />
<br />
Here's a method to define a new parameter, call it <nowiki>hoffset</nowiki>, which sets up <nowiki>[lr]offset</nowiki> at the same time:<br />
<texcode><br />
\setupframed<br />
[loffset=\framedparameter{hoffset},<br />
roffset=\framedparameter{hoffset},<br />
hoffset=\zeropoint]<br />
</texcode><br />
<br />
= Location parameter =<br />
<br />
<context source="yes"><br />
\ruledhbox<br />
{A<br />
\framed[width=2cm,align=middle,location=hanging]{location\\equals\\hanging}<br />
\framed[width=2cm,align=middle,location=depth] {location\\equals\\depth}<br />
\framed[width=2cm,align=middle,location=height] {location\\equals\\height}<br />
B}<br />
\vskip2cm<br />
\ruledhbox<br />
{A<br />
\framed[width=2cm,align=middle,location=low] {location\\equals\\low}<br />
\framed[width=2cm,align=middle,location=line] {location\\equals\\line}<br />
\framed[width=2cm,align=middle,location=high] {location\\equals\\high}<br />
B}<br />
\vskip2cm<br />
\ruledhbox<br />
{A<br />
\framed[width=2cm,align=middle,location=top] {location\\equals\\top}<br />
\framed[width=2cm,align=middle,location=bottom] {location\\equals\\bottom}<br />
\framed[width=2cm,align=middle,location=lohi] {location\\equals\\lohi}<br />
\framed[width=2cm,align=middle,location=middle] {location\\equals\\middle}<br />
B}<br />
</context><br />
<br />
and to compare with basic height and depth of the line, and looking at the end on the effect of the struct parameter:<br />
<br />
<context source="yes"><br />
\defineframed[MonCadre][width=1.75cm,align=middle]<br />
\define[1]\DemoLoc{\ruledhbox{%<br />
{\getbuffer \MonCadre[location=#1]<br />
{location\\ \color[darkmagenta]{\bf #1}\\location}}}}<br />
\setupbodyfont[10pt]<br />
%\showboxes<br />
\startbuffer<br />
\blackrule[height=max,depth=0pt,width=3mm]%<br />
\blackrule[height=0pt,depth=max,width=3mm]<br />
\stopbuffer<br />
<br />
\strut<br />
\DemoLoc{empty} \dontleavehmode<br />
\DemoLoc{keep} \dontleavehmode <br />
\DemoLoc{depth} \dontleavehmode<br />
\DemoLoc{bottom} \dontleavehmode<br />
\DemoLoc{low} <br />
\blank[big]<br />
\strut<br />
\DemoLoc{middle} \dontleavehmode<br />
\DemoLoc{lohi} \dontleavehmode <br />
\DemoLoc{line}<br />
\blank[big]<br />
\strut<br />
\DemoLoc{top} \dontleavehmode<br />
\DemoLoc{height} \dontleavehmode <br />
\DemoLoc{high} \dontleavehmode<br />
\DemoLoc{formula} \dontleavehmode <br />
\DemoLoc{hanging}<br />
<br />
\setupframed[MonCadre][strut=yes]<br />
\strut<br />
{\tt strut=yes}<br />
\DemoLoc{bottom} \dontleavehmode \DemoLoc{top}<br />
<br />
{\tt strut=no}<br />
\setupframed[MonCadre][strut=no]<br />
\DemoLoc{bottom} \dontleavehmode \DemoLoc{top}<br />
</context><br />
<br />
= Similar topics =<br />
* [[Vertically Centered Boxes]]<br />
* [[Overlays]]<br />
* [[Tables Overview]]<br />
<br />
= See also =<br />
* [[:Category:Command/Frames]]<br />
<br />
[[Category:Basics]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Detailed_Example&diff=34311Detailed Example2024-01-18T20:23:27Z<p>Zsd: Remove spurious 's's, add in missing "in".</p>
<hr />
<div>< [[First Document]] | [[Detailed Example]] | [[Basics]] ><br />
<br />
== Purpose ==<br />
<br />
Here is a skeleton document that illustrates several features of ConTeXt: <br />
* [[Layout|layouts]]<br />
* [[Enumerations|lists]]<br />
* [[Math|mathematics]]<br />
* [[References|automatic cross-references]]<br />
* [[Presentations|interaction]] (hyperlinks)<br />
* shaded boxes<br />
* [[Using Graphics|figure-text integration]]<br />
<br />
[[Image:Hello-world.pdf]] is the PDF file the 2006.12.27 version of ConTeXt produced.<br />
<br />
== Source ==<br />
<br />
[[Image:Hello-world.tex]] is the source (to save copying and pasting from the source below).<br />
<br />
<texcode><br />
% "Hello world!" document for the ConTeXt typesetting system<br />
%<br />
% === History ===<br />
% 2006-12-29 Sanjoy Mahajan &lt;sanjoy@mit.edu&gt;<br />
% * Created<br />
% <br />
% This document is in the public domain (no copyright).<br />
<br />
\setupcolors[state=start] % otherwise you get greyscale<br />
\definecolor[headingcolor][r=1,b=0.4]<br />
<br />
% for the document info/catalog (reported by 'pdfinfo', for example)<br />
\setupinteraction[state=start, % make hyperlinks active, etc.<br />
title={Hello world!},<br />
subtitle={A ConTeXt template},<br />
author={Sanjoy Mahajan},<br />
keyword={template}]<br />
<br />
% useful urls<br />
\useURL[author-email][mailto:a.u.thor@somewhere.edu][][a.u.thor@somewhere.edu]<br />
\useURL[wiki][http://wiki.contextgarden.net][][\ConTeXt\ wiki]<br />
\useURL[sanjoy][mailto:sanjoy@mit.edu][][sanjoy@mit.edu]<br />
<br />
% for US paper; the sensible default is [A4][A4] (A4 typesetting,<br />
% printed on A4 paper)<br />
\setuppapersize[letter][letter]<br />
\setuplayout[topspace=0.5in, backspace=1in, header=24pt, footer=36pt,<br />
height=middle, width=middle]<br />
% uncomment the next line to see the layout<br />
% \showframe<br />
<br />
% headers and footers<br />
\setupfooter[style=\it]<br />
\setupfootertexts[\date\hfill \ConTeXt\ template]<br />
\setuppagenumbering[location={header,right}, style=bold]<br />
<br />
\setupbodyfont[11pt] % default is 12pt<br />
<br />
\setuphead[section,chapter,subject][color=headingcolor]<br />
\setuphead[section,subject][style={\ss\bfa},<br />
before={\bigskip\bigskip}, after={}]<br />
\setuphead[chapter][style={\ss\bfd}]<br />
\setuphead[title][style={\ss\bfd},<br />
before={\begingroup\setupbodyfont[14.4pt]},<br />
after={\leftline{\ss\tfa A. U. Thor $\langle$\from[author-email]$\rangle$}<br />
\bigskip\bigskip\endgroup}]<br />
<br />
\setupitemize[inbetween={}, style=bold]<br />
<br />
% set inter-paragraph spacing<br />
\setupwhitespace[medium]<br />
% comment the next line to not indent paragraphs<br />
\setupindenting[medium, yes]<br />
<br />
\starttext<br />
<br />
\title{Hello, world!}<br />
<br />
Here is a hello-world template document to illustrate a few \ConTeXt\<br />
features. Have fun. You can find a lot more information at<br />
\from[wiki]; the preceding text should be colored and clickable, and<br />
clicking it should take you to the wiki.<br />
<br />
\subject{A list}<br />
<br />
Here is an example of a list.<br />
<br />
\startitemize[a] % tags are lowercase letters<br />
\item first<br />
\item second<br />
\item third<br />
\stopitemize<br />
<br />
\subject{Math}<br />
<br />
An equation can be typeset inline like $e^{\pi i}+1=0$, or as a<br />
displayed formula:<br />
\startformula<br />
\int_0^\infty t^4 e^{-t}\,dt = 24.<br />
\stopformula<br />
% don't use $$...$$ (the plain TeX equivalent)<br />
You can also have numbered equations:<br />
\placeformula[eq:factorial-example]\startformula<br />
\int_0^\infty t^5 e^{-t}\,dt = 120.<br />
\stopformula<br />
And you can refer to them by name. I called the previous equation {\tt<br />
factorial-example}, and it is equation \in[eq:factorial-example].<br />
\ConTeXt\ figures out the number for you. And with interaction turned<br />
on, you can click on the equation number to get to the equation.<br />
<br />
\subject{Text with figures}<br />
<br />
Now text with a few figures. The first figure goes on the right, with<br />
the paragraph flowing around it.<br />
<br />
\placefigure[right,none]{}{\externalfigure[dummy]}<br />
<br />
\input tufte<br />
<br />
The next figure will go inline, like a displayed formula:<br />
\placefigure[here,none]{}{\externalfigure[dummy]}<br />
\input tufte<br />
<br />
Here's another reference to the numbered equation -- equation<br />
\in[eq:factorial-example] on \at{page}[eq:factorial-example], so that<br />
you can test clicking on it or on the page reference.<br />
<br />
% most plain TeX commands work<br />
\vfill<br />
<br />
\noindent <br />
\framed[corner=round, width=\textwidth,height=1in,<br />
backgroundcolor=gray,background=color]<br />
{This document is in the public domain, so that you can improve it, share<br />
it, and otherwise do what you want with it. <br />
Suggestions are welcome. You can send them to me<br />
at \from[sanjoy] (Sanjoy Mahajan).}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Output ==<br />
This document looks like this:<br />
<br />
<context><br />
\setuplayout[scale=0.7]<br />
% "Hello world!" document for the ConTeXt typesetting system<br />
%<br />
% === History ===<br />
% 2006-12-29 Sanjoy Mahajan &lt;sanjoy@mit.edu&gt;<br />
% * Created<br />
% <br />
% This document is in the public domain (no copyright).<br />
<br />
\setupcolors[state=start] % otherwise you get greyscale<br />
\definecolor[headingcolor][r=1,b=0.4]<br />
<br />
% for the document info/catalog (reported by 'pdfinfo', for example)<br />
\setupinteraction[state=start, % make hyperlinks active, etc.<br />
title={Hello world!},<br />
subtitle={A ConTeXt template},<br />
author={Sanjoy Mahajan},<br />
keyword={template}]<br />
<br />
% useful urls<br />
\useURL[author-email][mailto:a.u.thor@somewhere.edu][][a.u.thor@somewhere.edu]<br />
\useURL[wiki][http://wiki.contextgarden.net][][\ConTeXt\ wiki]<br />
\useURL[sanjoy][mailto:sanjoy@mit.edu][][sanjoy@mit.edu]<br />
<br />
% for US paper; the sensible default is [A4][A4] (A4 typesetting,<br />
% printed on A4 paper)<br />
\setuppapersize[letter][letter]<br />
\setuplayout[topspace=0.5in, backspace=1in, header=24pt, footer=36pt,<br />
height=middle, width=middle]<br />
% uncomment the next line to see the layout<br />
% \showframe<br />
<br />
% headers and footers<br />
\setupfooter[style=\it]<br />
\setupfootertexts[\date\hfill \ConTeXt\ template]<br />
\setuppagenumbering[location={header,right}, style=bold]<br />
<br />
\setupbodyfont[11pt] % default is 12pt<br />
<br />
\setuphead[section,chapter,subject][color=headingcolor]<br />
\setuphead[section,subject][style={\ss\bfa},<br />
before={\bigskip\bigskip}, after={}]<br />
\setuphead[chapter][style={\ss\bfd}]<br />
\setuphead[title][style={\ss\bfd},<br />
before={\begingroup\setupbodyfont[14.4pt]},<br />
after={\leftline{\ss\tfa A. U. Thor $\langle$\from[author-email]$\rangle$}<br />
\bigskip\bigskip\endgroup}]<br />
<br />
\setupitemize[inbetween={}, style=bold]<br />
<br />
% set inter-paragraph spacing<br />
\setupwhitespace[medium]<br />
% comment the next line to not indent paragraphs<br />
\setupindenting[medium, yes]<br />
<br />
\starttext<br />
<br />
\title{Hello, world!}<br />
<br />
Here is a hello-world template document to illustrate a few \ConTeXt\<br />
features. Have fun. You can find a lot more information at<br />
\from[wiki]; the preceding text should be colored and clickable, and<br />
clicking it should take you to the wiki.<br />
<br />
\subject{A list}<br />
<br />
Here is an example of a list.<br />
<br />
\startitemize[a] % tags are lowercase letters<br />
\item first<br />
\item second<br />
\item third<br />
\stopitemize<br />
<br />
\subject{Math}<br />
<br />
An equation can be typeset inline like $e^{\pi i}+1=0$, or as a<br />
displayed formula:<br />
\startformula<br />
\int_0^\infty t^4 e^{-t}\,dt = 24.<br />
\stopformula<br />
% don't use $$...$$ (the plain TeX equivalent)<br />
You can also have numbered equations:<br />
\placeformula[eq:factorial-example]\startformula<br />
\int_0^\infty t^5 e^{-t}\,dt = 120.<br />
\stopformula<br />
And you can refer to them by name. I called the previous equation {\tt<br />
factorial-example}, and it is equation \in[eq:factorial-example].<br />
\ConTeXt\ figures out the number for you. And with interaction turned<br />
on, you can click on the equation number to get to the equation.<br />
<br />
\subject{Text with figures}<br />
<br />
Now text with a few figures. The first figure goes on the right, with<br />
the paragraph flowing around it.<br />
<br />
\placefigure[right,none]{}{\externalfigure[dummy]}<br />
<br />
\input tufte<br />
\stoptext<br />
</context><br />
<br />
<br />
<br />
<br />
<context><br />
\setuplayout[scale=0.7]<br />
% "Hello world!" document for the ConTeXt typesetting system<br />
%<br />
% === History ===<br />
% 2006-12-29 Sanjoy Mahajan &lt;sanjoy@mit.edu&gt;<br />
% * Created<br />
% <br />
% This document is in the public domain (no copyright).<br />
<br />
%%%% TO GET CORRECT Page number<br />
\setnumber[page]{2}<br />
<br />
\setupcolors[state=start] % otherwise you get greyscale<br />
\definecolor[headingcolor][r=1,b=0.4]<br />
<br />
% for the document info/catalog (reported by 'pdfinfo', for example)<br />
\setupinteraction[state=start, % make hyperlinks active, etc.<br />
title={Hello world!},<br />
subtitle={A ConTeXt template},<br />
author={Sanjoy Mahajan},<br />
keyword={template}]<br />
<br />
% useful urls<br />
\useURL[author-email][mailto:a.u.thor@somewhere.edu][][a.u.thor@somewhere.edu]<br />
\useURL[wiki][http://wiki.contextgarden.net][][\ConTeXt\ wiki]<br />
\useURL[sanjoy][mailto:sanjoy@mit.edu][][sanjoy@mit.edu]<br />
<br />
% for US paper; the sensible default is [A4][A4] (A4 typesetting,<br />
% printed on A4 paper)<br />
\setuppapersize[letter][letter]<br />
\setuplayout[topspace=0.5in, backspace=1in, header=24pt, footer=36pt,<br />
height=middle, width=middle]<br />
% uncomment the next line to see the layout<br />
% \showframe<br />
<br />
% headers and footers<br />
\setupfooter[style=\it]<br />
\setupfootertexts[\date\hfill \ConTeXt\ template]<br />
\setuppagenumbering[location={header,right}, style=bold]<br />
<br />
\setupbodyfont[11pt] % default is 12pt<br />
<br />
\setuphead[section,chapter,subject][color=headingcolor]<br />
\setuphead[section,subject][style={\ss\bfa},<br />
before={\bigskip\bigskip}, after={}]<br />
\setuphead[chapter][style={\ss\bfd}]<br />
\setuphead[title][style={\ss\bfd},<br />
before={\begingroup\setupbodyfont[14.4pt]},<br />
after={\leftline{\ss\tfa A. U. Thor $\langle$\from[author-email]$\rangle$}<br />
\bigskip\bigskip\endgroup}]<br />
<br />
\setupitemize[inbetween={}, style=bold]<br />
<br />
% set inter-paragraph spacing<br />
\setupwhitespace[medium]<br />
% comment the next line to not indent paragraphs<br />
\setupindenting[medium, yes]<br />
<br />
\starttext<br />
<br />
<br />
The next figure will go inline, like a displayed formula:<br />
\placefigure[here,none]{}{\externalfigure[dummy]}<br />
\input tufte<br />
<br />
Here's another reference to the numbered equation -- equation<br />
\in[eq:factorial-example] on \at{page}[eq:factorial-example], so that<br />
you can test clicking on it or on the page reference.<br />
<br />
% most plain TeX commands work<br />
\vfill<br />
<br />
\noindent <br />
\framed[corner=round, width=\textwidth,height=1in,<br />
backgroundcolor=gray,background=color]<br />
{This document is in the public domain, so that you can improve it, share<br />
it, and otherwise do what you want with it. <br />
Suggestions are welcome. You can send them to me<br />
at \from[sanjoy] (Sanjoy Mahajan).}<br />
<br />
\stoptext<br />
</context><br />
<br />
[[Category:Sample documents]]<br />
[[Category:Basics]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Detailed_Example&diff=34310Detailed Example2024-01-18T20:17:19Z<p>Zsd: Delete spurious 's'.</p>
<hr />
<div>< [[First Document]] | [[Detailed Example]] | [[Basics]] ><br />
<br />
== Purpose ==<br />
<br />
Here is a skeleton document that illustrates several features of ConTeXt: <br />
* [[Layout|layouts]]<br />
* [[Enumerations|lists]]<br />
* [[Math|mathematics]]<br />
* [[References|automatic cross-references]]<br />
* [[Presentations|interaction]] (hyperlinks)<br />
* shaded boxes<br />
* [[Using Graphics|figure-text integration]]<br />
<br />
[[Image:Hello-world.pdf]] is the PDF file the 2006.12.27 version of ConTeXt produced.<br />
<br />
== Source ==<br />
<br />
[[Image:Hello-world.tex]] is the source (to save copying and pasting from the source below).<br />
<br />
<texcode><br />
% "Hello world!" document for the ConTeXt typesetting system<br />
%<br />
% === History ===<br />
% 2006-12-29 Sanjoy Mahajan &lt;sanjoy@mit.edu&gt;<br />
% * Created<br />
% <br />
% This document is the public domain (no copyright).<br />
<br />
\setupcolors[state=start] % otherwise you get greyscale<br />
\definecolor[headingcolor][r=1,b=0.4]<br />
<br />
% for the document info/catalog (reported by 'pdfinfo', for example)<br />
\setupinteraction[state=start, % make hyperlinks active, etc.<br />
title={Hello world!},<br />
subtitle={A ConTeXt template},<br />
author={Sanjoy Mahajan},<br />
keyword={template}]<br />
<br />
% useful urls<br />
\useURL[author-email][mailto:a.u.thor@somewhere.edu][][a.u.thor@somewhere.edu]<br />
\useURL[wiki][http://wiki.contextgarden.net][][\ConTeXt\ wiki]<br />
\useURL[sanjoy][mailto:sanjoy@mit.edu][][sanjoy@mit.edu]<br />
<br />
% for US paper; the sensible default is [A4][A4] (A4 typesetting,<br />
% printed on A4 paper)<br />
\setuppapersize[letter][letter]<br />
\setuplayout[topspace=0.5in, backspace=1in, header=24pt, footer=36pt,<br />
height=middle, width=middle]<br />
% uncomment the next line to see the layout<br />
% \showframe<br />
<br />
% headers and footers<br />
\setupfooter[style=\it]<br />
\setupfootertexts[\date\hfill \ConTeXt\ template]<br />
\setuppagenumbering[location={header,right}, style=bold]<br />
<br />
\setupbodyfont[11pt] % default is 12pt<br />
<br />
\setuphead[section,chapter,subject][color=headingcolor]<br />
\setuphead[section,subject][style={\ss\bfa},<br />
before={\bigskip\bigskip}, after={}]<br />
\setuphead[chapter][style={\ss\bfd}]<br />
\setuphead[title][style={\ss\bfd},<br />
before={\begingroup\setupbodyfont[14.4pt]},<br />
after={\leftline{\ss\tfa A. U. Thor $\langle$\from[author-email]$\rangle$}<br />
\bigskip\bigskip\endgroup}]<br />
<br />
\setupitemize[inbetween={}, style=bold]<br />
<br />
% set inter-paragraph spacing<br />
\setupwhitespace[medium]<br />
% comment the next line to not indent paragraphs<br />
\setupindenting[medium, yes]<br />
<br />
\starttext<br />
<br />
\title{Hello, world!}<br />
<br />
Here is a hello-world template document to illustrates a few \ConTeXt\<br />
features. Have fun. You can find a lot more information at<br />
\from[wiki]; the preceding text should be colored and clickable, and<br />
clicking it should take you to the wiki.<br />
<br />
\subject{A list}<br />
<br />
Here is an example of a list.<br />
<br />
\startitemize[a] % tags are lowercase letters<br />
\item first<br />
\item second<br />
\item third<br />
\stopitemize<br />
<br />
\subject{Math}<br />
<br />
An equation can be typeset inline like $e^{\pi i}+1=0$, or as a<br />
displayed formula:<br />
\startformula<br />
\int_0^\infty t^4 e^{-t}\,dt = 24.<br />
\stopformula<br />
% don't use $$...$$ (the plain TeX equivalent)<br />
You can also have numbered equations:<br />
\placeformula[eq:factorial-example]\startformula<br />
\int_0^\infty t^5 e^{-t}\,dt = 120.<br />
\stopformula<br />
And you can refer to them by name. I called the previous equation {\tt<br />
factorial-example}, and it is equation \in[eq:factorial-example].<br />
\ConTeXt\ figures out the number for you. And with interaction turned<br />
on, you can click on the equation number to get to the equation.<br />
<br />
\subject{Text with figures}<br />
<br />
Now text with a few figures. The first figure goes on the right, with<br />
the paragraph flowing around it.<br />
<br />
\placefigure[right,none]{}{\externalfigure[dummy]}<br />
<br />
\input tufte<br />
<br />
The next figure will go inline, like a displayed formula:<br />
\placefigure[here,none]{}{\externalfigure[dummy]}<br />
\input tufte<br />
<br />
Here's another reference to the numbered equation -- equation<br />
\in[eq:factorial-example] on \at{page}[eq:factorial-example], so that<br />
you can test clicking on it or on the page reference.<br />
<br />
% most plain TeX commands work<br />
\vfill<br />
<br />
\noindent <br />
\framed[corner=round, width=\textwidth,height=1in,<br />
backgroundcolor=gray,background=color]<br />
{This document is in the public domain, so that you can improve it, share<br />
it, and otherwise do what you want with it. <br />
Suggestions are welcome. You can send them to me<br />
at \from[sanjoy] (Sanjoy Mahajan).}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Output ==<br />
This document looks like this:<br />
<br />
<context><br />
\setuplayout[scale=0.7]<br />
% "Hello world!" document for the ConTeXt typesetting system<br />
%<br />
% === History ===<br />
% 2006-12-29 Sanjoy Mahajan &lt;sanjoy@mit.edu&gt;<br />
% * Created<br />
% <br />
% This document is the public domain (no copyright).<br />
<br />
\setupcolors[state=start] % otherwise you get greyscale<br />
\definecolor[headingcolor][r=1,b=0.4]<br />
<br />
% for the document info/catalog (reported by 'pdfinfo', for example)<br />
\setupinteraction[state=start, % make hyperlinks active, etc.<br />
title={Hello world!},<br />
subtitle={A ConTeXt template},<br />
author={Sanjoy Mahajan},<br />
keyword={template}]<br />
<br />
% useful urls<br />
\useURL[author-email][mailto:a.u.thor@somewhere.edu][][a.u.thor@somewhere.edu]<br />
\useURL[wiki][http://wiki.contextgarden.net][][\ConTeXt\ wiki]<br />
\useURL[sanjoy][mailto:sanjoy@mit.edu][][sanjoy@mit.edu]<br />
<br />
% for US paper; the sensible default is [A4][A4] (A4 typesetting,<br />
% printed on A4 paper)<br />
\setuppapersize[letter][letter]<br />
\setuplayout[topspace=0.5in, backspace=1in, header=24pt, footer=36pt,<br />
height=middle, width=middle]<br />
% uncomment the next line to see the layout<br />
% \showframe<br />
<br />
% headers and footers<br />
\setupfooter[style=\it]<br />
\setupfootertexts[\date\hfill \ConTeXt\ template]<br />
\setuppagenumbering[location={header,right}, style=bold]<br />
<br />
\setupbodyfont[11pt] % default is 12pt<br />
<br />
\setuphead[section,chapter,subject][color=headingcolor]<br />
\setuphead[section,subject][style={\ss\bfa},<br />
before={\bigskip\bigskip}, after={}]<br />
\setuphead[chapter][style={\ss\bfd}]<br />
\setuphead[title][style={\ss\bfd},<br />
before={\begingroup\setupbodyfont[14.4pt]},<br />
after={\leftline{\ss\tfa A. U. Thor $\langle$\from[author-email]$\rangle$}<br />
\bigskip\bigskip\endgroup}]<br />
<br />
\setupitemize[inbetween={}, style=bold]<br />
<br />
% set inter-paragraph spacing<br />
\setupwhitespace[medium]<br />
% comment the next line to not indent paragraphs<br />
\setupindenting[medium, yes]<br />
<br />
\starttext<br />
<br />
\title{Hello, world!}<br />
<br />
Here is a hello-world template document to illustrates a few \ConTeXt\<br />
features. Have fun. You can find a lot more information at<br />
\from[wiki]; the preceding text should be colored and clickable, and<br />
clicking it should take you to the wiki.<br />
<br />
\subject{A list}<br />
<br />
Here is an example of a list.<br />
<br />
\startitemize[a] % tags are lowercase letters<br />
\item first<br />
\item second<br />
\item third<br />
\stopitemize<br />
<br />
\subject{Math}<br />
<br />
An equation can be typeset inline like $e^{\pi i}+1=0$, or as a<br />
displayed formula:<br />
\startformula<br />
\int_0^\infty t^4 e^{-t}\,dt = 24.<br />
\stopformula<br />
% don't use $$...$$ (the plain TeX equivalent)<br />
You can also have numbered equations:<br />
\placeformula[eq:factorial-example]\startformula<br />
\int_0^\infty t^5 e^{-t}\,dt = 120.<br />
\stopformula<br />
And you can refer to them by name. I called the previous equation {\tt<br />
factorial-example}, and it is equation \in[eq:factorial-example].<br />
\ConTeXt\ figures out the number for you. And with interaction turned<br />
on, you can click on the equation number to get to the equation.<br />
<br />
\subject{Text with figures}<br />
<br />
Now text with a few figures. The first figure goes on the right, with<br />
the paragraph flowing around it.<br />
<br />
\placefigure[right,none]{}{\externalfigure[dummy]}<br />
<br />
\input tufte<br />
\stoptext<br />
</context><br />
<br />
<br />
<br />
<br />
<context><br />
\setuplayout[scale=0.7]<br />
% "Hello world!" document for the ConTeXt typesetting system<br />
%<br />
% === History ===<br />
% 2006-12-29 Sanjoy Mahajan &lt;sanjoy@mit.edu&gt;<br />
% * Created<br />
% <br />
% This document is the public domain (no copyright).<br />
<br />
%%%% TO GET CORRECT Page number<br />
\setnumber[page]{2}<br />
<br />
\setupcolors[state=start] % otherwise you get greyscale<br />
\definecolor[headingcolor][r=1,b=0.4]<br />
<br />
% for the document info/catalog (reported by 'pdfinfo', for example)<br />
\setupinteraction[state=start, % make hyperlinks active, etc.<br />
title={Hello world!},<br />
subtitle={A ConTeXt template},<br />
author={Sanjoy Mahajan},<br />
keyword={template}]<br />
<br />
% useful urls<br />
\useURL[author-email][mailto:a.u.thor@somewhere.edu][][a.u.thor@somewhere.edu]<br />
\useURL[wiki][http://wiki.contextgarden.net][][\ConTeXt\ wiki]<br />
\useURL[sanjoy][mailto:sanjoy@mit.edu][][sanjoy@mit.edu]<br />
<br />
% for US paper; the sensible default is [A4][A4] (A4 typesetting,<br />
% printed on A4 paper)<br />
\setuppapersize[letter][letter]<br />
\setuplayout[topspace=0.5in, backspace=1in, header=24pt, footer=36pt,<br />
height=middle, width=middle]<br />
% uncomment the next line to see the layout<br />
% \showframe<br />
<br />
% headers and footers<br />
\setupfooter[style=\it]<br />
\setupfootertexts[\date\hfill \ConTeXt\ template]<br />
\setuppagenumbering[location={header,right}, style=bold]<br />
<br />
\setupbodyfont[11pt] % default is 12pt<br />
<br />
\setuphead[section,chapter,subject][color=headingcolor]<br />
\setuphead[section,subject][style={\ss\bfa},<br />
before={\bigskip\bigskip}, after={}]<br />
\setuphead[chapter][style={\ss\bfd}]<br />
\setuphead[title][style={\ss\bfd},<br />
before={\begingroup\setupbodyfont[14.4pt]},<br />
after={\leftline{\ss\tfa A. U. Thor $\langle$\from[author-email]$\rangle$}<br />
\bigskip\bigskip\endgroup}]<br />
<br />
\setupitemize[inbetween={}, style=bold]<br />
<br />
% set inter-paragraph spacing<br />
\setupwhitespace[medium]<br />
% comment the next line to not indent paragraphs<br />
\setupindenting[medium, yes]<br />
<br />
\starttext<br />
<br />
<br />
The next figure will go inline, like a displayed formula:<br />
\placefigure[here,none]{}{\externalfigure[dummy]}<br />
\input tufte<br />
<br />
Here's another reference to the numbered equation -- equation<br />
\in[eq:factorial-example] on \at{page}[eq:factorial-example], so that<br />
you can test clicking on it or on the page reference.<br />
<br />
% most plain TeX commands work<br />
\vfill<br />
<br />
\noindent <br />
\framed[corner=round, width=\textwidth,height=1in,<br />
backgroundcolor=gray,background=color]<br />
{This document is in the public domain, so that you can improve it, share<br />
it, and otherwise do what you want with it. <br />
Suggestions are welcome. You can send them to me<br />
at \from[sanjoy] (Sanjoy Mahajan).}<br />
<br />
\stoptext<br />
</context><br />
<br />
[[Category:Sample documents]]<br />
[[Category:Basics]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=SyncTeX&diff=34282SyncTeX2023-11-17T01:24:24Z<p>Zsd: /* Editors & Viewers Jim Diamond added the emacs+auctex section, including the synctex replacement shell script and related comments. */</p>
<hr />
<div>'''SyncTeX''' is a program that puts a lot of anchors in the output file that link to the corresponding position in the source file. This allows you to quickly jump from PDF to source. <br />
<br />
== Usage ==<br />
<br />
You can use the <code>--synctex</code> switch to enable SyncTeX.<br />
<br />
So in MkIV you can run<br />
context --synctex <i>jobname</i><br />
and in MkII you can use<br />
texexec --synctex <i>jobname</i><br />
<br />
Alternatively you can add one of the following commands to your MkIV document:<br />
<texcode><br />
\setupsynctex[state=start,method=min] % clickable words<br />
\setupsynctex[state=start,method=max] % more efficient clickable ranges<br />
</texcode><br />
<br />
This will create a file <code><i>jobname</i>.synctex</code>. The command<br />
context --purge<br />
or next run without <code>--synctex</code> will remove the file again.<br />
<br />
To see what became clickable, use one of<br />
<texcode><br />
\enabletrackers[system.synctex.visualize]<br />
\enabletrackers[system.synctex.visualize=real]<br />
</texcode><br />
<br />
This file can be used by your editor and PDF viewer to jump back and forth between the source and the PDF.<br />
<br />
== Editors & Viewers ==<br />
<br />
=== TeXshop ===<br />
<br />
Works quite well, but needs “magic lines” like:<br />
<br />
% !TEX TS-program = ConTeXt2021<br />
% !TEX useAlternatePath<br />
% !TEX useConTeXtSyncParser<br />
<br />
Setup see [[TeXShop|extra page on TeXshop]].<br />
<br />
=== TeXWorks ===<br />
<br />
You may need to modify the command for executing ConTeXt first (you need to add <code>--synctex</code> switch in preferences).<br />
<br />
=== Emacs + auctex ===<br />
<br />
To implement forward search with auctex (i.e., open the viewer at the right page from emacs)<br />
creating a shell script called '''synctex''' in some directory which precedes one containing<br />
the "usual" synctex (if any) in your $PATH with the following contents has been demonstrated<br />
to work on at least Slackware64 15.0:<br />
<br />
#! /bin/zsh<br />
<br />
# synctex replacement to allow forward search from emacs+auctex to (at least) evince<br />
<br />
# Emacs + auctex calls synctex up to three times.<br />
# For example, attempting to view the PDF of <FILE>.tex would cause<br />
# emacs to run the following commands ($PWD is the path to the<br />
# current directory):<br />
# synctex view -i <LINE>:<COL>:$PWD/./<FILE>.tex -o <FILE>.pdf<br />
# synctex view -i <LINE>:<COL>:<FILE>.tex -o <FILE>.pdf<br />
# synctex view -i <LINE>:<COL>:$PWD/<FILE>.tex -o <FILE>.pdf<br />
<br />
line_number=${3%%:*}<br />
tex_file=${3##*:}<br />
synctex_file=${tex_file%.tex}.synctex<br />
<br />
# Transmogrify the output format of mtxrun into something that emacs+auctex<br />
# (and maybe other editors?) recognizes:<br />
mtxrun --script synctex --find \<br />
--file=$tex_file --line=$line_number $synctex_file \<br />
| sed 's/.*page=/Page:/'<br />
<br />
(Note: this has only been tested with simple document structures.)<br />
<br />
=== Evince, Okular & Kile ===<br />
Okular (the KDE PDF viewer) and Evince (the GNOME one) support SyncTeX. (The latter since version 2.32.0)<br />
<br />
To forward something from a text editor to Okular, do<br />
okular --unique '${pdffile}#src:${linenumber} ${texfile}'<br />
<br />
Kile’s (the KDE TeX IDE) ForwardPDF function should support SyncTeX, but it doesn’t seem to work with ConTeXt at the time of writing<br />
<br />
=== Skim.app & TextMate (Mac OS X) ===<br />
<br />
In Skim/Preferences/Sync choose TextMate. The key combination<br />
Shift + Apple + MouseClick<br />
will bring you to the corresponding line in text editor.<br />
<br />
In [[TextMate]] I have created my own command inside the ConTeXt bundle:<br />
<br />
* '''Save''': Nothing<br />
* '''Command(s)'''<br />
#!/bin/bash<br />
pdf=${TM_FILEPATH%tex}pdf<br />
/Applications/Skim.app/Contents/SharedSupport/displayline -r "$TM_LINE_NUMBER" "${pdf}"<br />
* '''Input''': None<br />
* '''Output''': Discard<br />
* '''Activation''': Key Equivalent (choose one; I used Ctrl+Alt+Apple+O)<br />
* '''Scope Selector''': text.tex.context<br />
<br />
If you use <code>Apple+R</code> for typesetting that needs to be modified as well (to account for --synctex switch).<br />
<br />
Hopefully this functionality will become part of the official ConTeXt bundle one day. (The recipe given above is too specific. The code needs to be written to handle more different viewers and different locations, not only a single viewer at a specified location.)<br />
<br />
=== Bugs ===<br />
<br />
(In 2021-10 I didn’t manage to get ConTeXt-SyncTeX working with Skim and different editors, while it worked with LaTeX-SyncTeX; there’s also no error message. I guess the parser fails on ConTeXt’s synctex files. [[User:Hraban|Hraban]] ([[User talk:Hraban|talk]]))<br />
<br />
<br />
<br />
[[Category:Text Editors]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/externalfigure&diff=34245Command/externalfigure2023-10-14T13:26:44Z<p>Zsd: /* See also */</p>
<hr />
<div><noinclude><br />
<br />
{{Reference<br />
|name=externalfigure<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>externalfigure</syntax><br />
<br />
</noinclude><br />
<br />
== Description == <br />
<br />
The <code>\externalfigure</code> command is used to include an external figure/movie inside ConTeXt. Includes both local files or remote files hosted on HTTP servers. <br />
<br />
The simplest way to insert an image is to use:<br />
<br />
<context source="yes" mode="mkiv"><br />
\externalfigure[cow.pdf]<br />
</context><br />
<br />
This command places the PDF image <code>cow.pdf</code> in a<br />
<code>\vbox</code>; the width and height of the image are equal to the natural dimensions of the image.<br />
<br />
To set the width of the image to a specific size, say <code>1cm</code>, use:<br />
<context source="yes" mode="mkiv" text="which gives"><br />
\externalfigure[cow.pdf][width=1cm]<br />
</context><br />
<br />
Similarly, to set the height of the image to a specific size, say <code>2cm</code>, use:<br />
<context source="yes" mode="mkiv" text="which gives"><br />
\externalfigure[cow.pdf][height=2cm]<br />
</context><br />
<br />
If only the <code>width</code> or <code>height</code> of the image is specified, the other dimension is scaled appropriately to keep the aspect ratio.<br />
<br />
To include a specific page, say page 5, of a multi-page PDF file, use:<br />
<texcode><br />
\externalfigure[filename.pdf][page=5]<br />
</texcode><br />
<br />
These four variations cover 90% of the use cases.<br />
<br />
<br />
=== How the filetype is determined ===<br />
<br />
* '''File extension''': Normally, the type of file is determined by the extension of the file (in a case-insensitive manner).<br />
* '''<code>method=type</code>''' If the file uses a non-standard extension, specify the file type using <code>method=type</code> where type is any of the file extensions that is recognized by {{cmd|externalfigure}}.<br />
* '''auto''': When the file extension is <code>.auto</code> or <code>method=auto</code> is used, ConTeXt reads the first few bytes of the file to determine the filetype. Such an auto-discovery is useful for remote images that do not have a file extension.<br />
<br />
If the extension of the file is not specified, ConTeXt searches for all possible extensions in the order given below.<br />
<br />
Historically, when postscript output was used, the order in which the file extensions were searched depended on the output format (PDF or PS). With recent releases of ConTeXt, PDF is the default output format, so for all practical purposes, the order in which the file extensions are searched is fixed.<br />
<br />
=== Natively supported image formats ===<br />
<br />
The following image formats are supported natively in MkIV:<br />
<br />
* '''[http://en.wikipedia.org/wiki/Portable_Document_Format PDF]''': File extension <code>.pdf</code>. By default, ''mediabox'' is used to determine size. Use <code>size=artbox</code> to use ''artbox''.<br />
* '''MPS (MetaPost Output)''': File extension <code>.mp</code>, <code>.mps</code> or <code>.[digits]</code>.<br />
<!-- Converted to PDF on the fly using MPtoPDF. --><br />
* '''[http://en.wikipedia.org/wiki/JPEG JPEG]''': File extension <code>.jpg</code> and <code>.jpeg</code><br />
* '''[http://en.wikipedia.org/wiki/Portable_Network_Graphics PNG]''': File extesion <code>.png</code><br />
* '''[http://en.wikipedia.org/wiki/JPEG_2000 JPEG 2000]''': File extesion <code>.jp2</code><br />
* '''[http://en.wikipedia.org/wiki/JBIG JBIG]''' and '''[http://en.wikipedia.org/wiki/JBIG2 JBIG2]''': File extension <code>.jbig</code>, <code>.jbib2</code>, and <code>.jb2</code><br />
<br />
Additionally supported natively in LMTX:<br />
<br />
* '''[http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG]''': File extension <code>.svg</code> and <code>.svgz</code> via an internal Metapost conversion; use <code>conversion=mp</code><br />
<br />
=== Image formats supported through external converters ===<br />
<br />
The following formats are converted to PDF by external programs before being included. The conversion generates a new file with a prefix <code>m_k_i_v_</code> and a suffix <code>.pdf</code> added to the name of the original file (the original extension is not removed). The result is cached, and the conversion is rerun only if the timestamp of the original file is newer than the converted file.<br />
<br />
<br />
* '''[http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG]''': File extension <code>.svg</code> and <code>.svgz</code>. Converted to PDF using [http://en.wikipedia.org/wiki/Inkscape Inkscape]. <br />
<br />
: For the conversion to work, <code>inkscape</code> should be in the <code>PATH</code>. The following command is used for conversion:<br />
<br />
inkscape [inputfile] --export-dpi=600 -A [outputfile] <br />
<br />
: (Note: Conversion to PNG is also possible, but I don’t know the details on how to active that -- 03:32, 29 November 2012 (CET)).<br />
<br />
* '''[http://en.wikipedia.org/wiki/PostScript PS]''' and '''[http://en.wikipedia.org/wiki/Encapsulated_PostScript EPS]''': File extension <code>.eps</code> and <code>.ai</code>. Converted to PDF using [http://en.wikipedia.org/wiki/Ghostscript Ghostscript]. <br />
<br />
<br />
: For the conversion to work, on Windows <code>gswin32c</code> must be in the <code>PATH</code>; on other platforms <code>gs</code> must be in the <code>PATH</code>. The following command line options are passed to Ghostscript<br />
<br />
gs -q -sDEVICE=pdfwrite -dNOPAUSE -dNOCACHE -dBATCH [resolution] -sOutputFile=[outputfile] [inputfile] -c quit<br />
<br />
: By default, the <code>[resolution]</code> is ''prepress''. Use <code>resolution=low</code> to change the <code>[resolution]</code> to ''screen'' and <code>resolution=meidum</code> to change the <code>[resolution]</code> to ''ebook''.<br />
<br />
* '''[http://en.wikipedia.org/wiki/GIF GIF]''': File extension <code>.gif</code>. Converted to PDF using [http://en.wikipedia.org/wiki/GraphicsMagick GraphicsMagick].<br />
<br />
: For the conversion to work, <code>gm</code> should be in the <code>PATH</code>. The following command is used for the conversion:<br />
<br />
gm convert [inputfile] [outputfile]<br />
<br />
* '''[http://en.wikipedia.org/wiki/Tagged_Image_File_Format TIFF]''': File extensions <code>.tiff</code> and <code>.tif</code>. Converted to PDF using [http://en.wikipedia.org/wiki/GraphicsMagick GraphicsMagick].<br />
<br />
: For the conversion to work, <code>gm</code> should be in the <code>PATH</code>. The following command is used for the conversion:<br />
<br />
gm convert [inputfile] [outputfile]<br />
<br />
=== Supported movie formats ===<br />
<br />
The following movie formats are supported.<br />
<br />
* '''[http://en.wikipedia.org/wiki/QuickTime QuickTime]''': File extension <code>.mov</code>. <br />
* '''[https://en.wikipedia.org/wiki/Flash_Video Flash Video]''': File extension <code>.flv</code><br />
* '''[https://en.wikipedia.org/wiki/MPEG-4 MPEG 4]''': File extension <code>.mp4</code><br />
<br />
{{ note| Movie inclusion only works in a few PDF viewers }}<br />
<br />
=== Support for special TeX formats ===<br />
<br />
The following special formats are supported:<br />
<br />
* '''buffer''': Typeset the buffer with the given name and include the result as a PDF file.<br />
<br />
* '''tex''': Typeset the TeX file using <code>context</code> and include the result as a PDF file<br />
<br />
* '''cld''': Typeset the [[CLD|ConTeXt Lua document]] using <code>context</code> and include the result as a PDF file.<br />
<br />
== Command options ==<br />
<br />
=== <code>interaction</code> ===<br />
<br />
By default, the interactive elements of the included PDF file are discarded. To enable the interactive elements of the included PDF file, use<br />
<br />
<texcode>\externalfigure[filename.pdf][interaction=yes]</texcode><br />
<br />
== Example ==<br />
<br />
=== Including a local image ===<br />
<br />
In the example below, no file name extension is used. ConTeXt searches for an image file in the following order: <code>cow.pdf</code>, <code>cow.mps</code>, <code>cow.1</code>, <code>cow.2</code>, etc., <code>cow.jpg</code>, <code>cow.png</code>, <code>cow.jp2</code>, <code>cow.jbig</code>, <code>cow.jbig2</code>, <code>cow.jb2</code>. The file <code>cow.pdf</code>, which is distributed as part of the ConTeXt distribution, is found and displayed.<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[cow][width=4cm]<br />
</context><br />
<br />
ConTeXt distribution also includes a sample image <code>hacker.jpg</code>. To include it use:<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[hacker][height=3cm]<br />
</context><br />
<br />
=== Include a remote image ===<br />
<br />
<context source="yes" mode="mkiv"><br />
\externalfigure[http://placekitten.com/g/200/300][method=jpg]<br />
</context><br />
<br />
=== Rotate an image ===<br />
<br />
* '''Rotate by 90, 180, or 270 degrees''': Use <code>orientation=90|180|270</code> to rotate an image in multiples of 90. For example:<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[mill][orientation=180]<br />
</context><br />
<br />
<br />
* '''Rotate by an arbitrary angle''': Use {{cmd|rotate}} command.<br />
<br />
<context source="yes" mode=mkiv><br />
\rotate[rotation=45]{\externalfigure[mill]}<br />
</context><br />
<br />
=== Flip an image ===<br />
<br />
Use {{cmd|mirror}} to horizontally flip an image<br />
<br />
<context source=yes mode=mkiv><br />
\mirror{\externalfigure[cow][width=3cm]}<br />
</context><br />
<br />
== Error Messages ==<br />
<br />
When a file is specified by its full name, and is not found, no error message is displayed in the log; rather a gray box is shown in the generated PDF which indicates that the figure was not found. For example (note that <code>cat.pdf</code> should '''not''' exist in the current directory)<br />
<br />
<context source=yes><br />
\externalfigure[cat.pdf]<br />
</context><br />
<br />
== Tracking ==<br />
<br />
The following trackers are available for {{cmd|externalfigure}} (MkIV only) <br />
<br />
* '''graphics.locating''': Gives details about where the image files are searched, what strategy was used to infer the file format, and what was the inferred file format.<br />
<br />
* '''graphics.conversion''': Gives details about the conversion from one file format to another<br />
<br />
* '''graphics.inclusions''': Gives details of including a movie<br />
<br />
The trackers are enabled using<br />
<br />
\enabletrackers[...tracker...]<br />
<br />
or <br />
<br />
context --trackers=list [filename]<br />
<br />
When the '''graphics.locating''' tracker is enabled, including a known file displays the following information on the terminal:<br />
<br />
graphics > inclusion > locations: local,global<br />
graphics > inclusion > path list: . .. ../..<br />
graphics > inclusion > strategy: unknown format, prefer quality<br />
graphics > inclusion > found: ./cow.pdf -> /opt/context-minimals/texmf-context/tex/context/sample/cow.pdf<br />
graphics > inclusion > format natively supported by backend: pdf<br />
<br />
If the requested file does not exist, the following information is displayed:<br />
<br />
graphics > inclusion > locations: local,global<br />
graphics > inclusion > path list: . .. ../..<br />
graphics > inclusion > strategy: forced format pdf<br />
graphics > inclusion > not found: cat.pdf<br />
graphics > inclusion > not found: ./cat.pdf<br />
graphics > inclusion > not found: ../cat.pdf<br />
graphics > inclusion > not found: ../../cat.pdf<br />
graphics > inclusion > format not supported: %s<br />
<br />
When the '''graphics.conversion''' tracker is enabled and a file type that requires conversion (e.g., PS) is included, the following message is displayed on the terminal:<br />
<br />
graphics > inclusion > checking conversion of './tiger.ps' (./tiger.ps): old format 'ps', new format 'pdf', conversion 'default', resolution 'default'<br />
graphics > inclusion > no need to convert './tiger.ps' (tiger.ps) from 'ps' to 'pdf'<br />
graphics > inclusion > new graphic, hash: m_k_i_v_tiger.ps.pdf->1->crop->unknown->unknown->unknown-><br />
<br />
When the '''graphics.inclusion''' tracker is enabled and a movie is included, the following message is displayed on the terminal:<br />
<br />
graphics > inclusion > including movie 'clip.mov': width 5594039.4330709, height 5594039.4330709<br />
<br />
<br />
<noinclude><br />
<br />
== See also ==<br />
* {{cmd|defineexternalfigure}} to define a collection of settings<br />
* {{cmd|setupexternalfigure}} to define a different collection of settings<br />
* {{cmd|useexternalfigure}} to define an image+settings combination<br />
* [[Using Graphics]]<br />
* [[Multimedia Inclusion]] to add audio and video contents.<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
</noinclude><br />
<br />
[[Category:Command/FiguresImages|externalfigure]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/externalfigure&diff=34244Command/externalfigure2023-10-14T13:26:11Z<p>Zsd: /* Tracking */</p>
<hr />
<div><noinclude><br />
<br />
{{Reference<br />
|name=externalfigure<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>externalfigure</syntax><br />
<br />
</noinclude><br />
<br />
== Description == <br />
<br />
The <code>\externalfigure</code> command is used to include an external figure/movie inside ConTeXt. Includes both local files or remote files hosted on HTTP servers. <br />
<br />
The simplest way to insert an image is to use:<br />
<br />
<context source="yes" mode="mkiv"><br />
\externalfigure[cow.pdf]<br />
</context><br />
<br />
This command places the PDF image <code>cow.pdf</code> in a<br />
<code>\vbox</code>; the width and height of the image are equal to the natural dimensions of the image.<br />
<br />
To set the width of the image to a specific size, say <code>1cm</code>, use:<br />
<context source="yes" mode="mkiv" text="which gives"><br />
\externalfigure[cow.pdf][width=1cm]<br />
</context><br />
<br />
Similarly, to set the height of the image to a specific size, say <code>2cm</code>, use:<br />
<context source="yes" mode="mkiv" text="which gives"><br />
\externalfigure[cow.pdf][height=2cm]<br />
</context><br />
<br />
If only the <code>width</code> or <code>height</code> of the image is specified, the other dimension is scaled appropriately to keep the aspect ratio.<br />
<br />
To include a specific page, say page 5, of a multi-page PDF file, use:<br />
<texcode><br />
\externalfigure[filename.pdf][page=5]<br />
</texcode><br />
<br />
These four variations cover 90% of the use cases.<br />
<br />
<br />
=== How the filetype is determined ===<br />
<br />
* '''File extension''': Normally, the type of file is determined by the extension of the file (in a case-insensitive manner).<br />
* '''<code>method=type</code>''' If the file uses a non-standard extension, specify the file type using <code>method=type</code> where type is any of the file extensions that is recognized by {{cmd|externalfigure}}.<br />
* '''auto''': When the file extension is <code>.auto</code> or <code>method=auto</code> is used, ConTeXt reads the first few bytes of the file to determine the filetype. Such an auto-discovery is useful for remote images that do not have a file extension.<br />
<br />
If the extension of the file is not specified, ConTeXt searches for all possible extensions in the order given below.<br />
<br />
Historically, when postscript output was used, the order in which the file extensions were searched depended on the output format (PDF or PS). With recent releases of ConTeXt, PDF is the default output format, so for all practical purposes, the order in which the file extensions are searched is fixed.<br />
<br />
=== Natively supported image formats ===<br />
<br />
The following image formats are supported natively in MkIV:<br />
<br />
* '''[http://en.wikipedia.org/wiki/Portable_Document_Format PDF]''': File extension <code>.pdf</code>. By default, ''mediabox'' is used to determine size. Use <code>size=artbox</code> to use ''artbox''.<br />
* '''MPS (MetaPost Output)''': File extension <code>.mp</code>, <code>.mps</code> or <code>.[digits]</code>.<br />
<!-- Converted to PDF on the fly using MPtoPDF. --><br />
* '''[http://en.wikipedia.org/wiki/JPEG JPEG]''': File extension <code>.jpg</code> and <code>.jpeg</code><br />
* '''[http://en.wikipedia.org/wiki/Portable_Network_Graphics PNG]''': File extesion <code>.png</code><br />
* '''[http://en.wikipedia.org/wiki/JPEG_2000 JPEG 2000]''': File extesion <code>.jp2</code><br />
* '''[http://en.wikipedia.org/wiki/JBIG JBIG]''' and '''[http://en.wikipedia.org/wiki/JBIG2 JBIG2]''': File extension <code>.jbig</code>, <code>.jbib2</code>, and <code>.jb2</code><br />
<br />
Additionally supported natively in LMTX:<br />
<br />
* '''[http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG]''': File extension <code>.svg</code> and <code>.svgz</code> via an internal Metapost conversion; use <code>conversion=mp</code><br />
<br />
=== Image formats supported through external converters ===<br />
<br />
The following formats are converted to PDF by external programs before being included. The conversion generates a new file with a prefix <code>m_k_i_v_</code> and a suffix <code>.pdf</code> added to the name of the original file (the original extension is not removed). The result is cached, and the conversion is rerun only if the timestamp of the original file is newer than the converted file.<br />
<br />
<br />
* '''[http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG]''': File extension <code>.svg</code> and <code>.svgz</code>. Converted to PDF using [http://en.wikipedia.org/wiki/Inkscape Inkscape]. <br />
<br />
: For the conversion to work, <code>inkscape</code> should be in the <code>PATH</code>. The following command is used for conversion:<br />
<br />
inkscape [inputfile] --export-dpi=600 -A [outputfile] <br />
<br />
: (Note: Conversion to PNG is also possible, but I don’t know the details on how to active that -- 03:32, 29 November 2012 (CET)).<br />
<br />
* '''[http://en.wikipedia.org/wiki/PostScript PS]''' and '''[http://en.wikipedia.org/wiki/Encapsulated_PostScript EPS]''': File extension <code>.eps</code> and <code>.ai</code>. Converted to PDF using [http://en.wikipedia.org/wiki/Ghostscript Ghostscript]. <br />
<br />
<br />
: For the conversion to work, on Windows <code>gswin32c</code> must be in the <code>PATH</code>; on other platforms <code>gs</code> must be in the <code>PATH</code>. The following command line options are passed to Ghostscript<br />
<br />
gs -q -sDEVICE=pdfwrite -dNOPAUSE -dNOCACHE -dBATCH [resolution] -sOutputFile=[outputfile] [inputfile] -c quit<br />
<br />
: By default, the <code>[resolution]</code> is ''prepress''. Use <code>resolution=low</code> to change the <code>[resolution]</code> to ''screen'' and <code>resolution=meidum</code> to change the <code>[resolution]</code> to ''ebook''.<br />
<br />
* '''[http://en.wikipedia.org/wiki/GIF GIF]''': File extension <code>.gif</code>. Converted to PDF using [http://en.wikipedia.org/wiki/GraphicsMagick GraphicsMagick].<br />
<br />
: For the conversion to work, <code>gm</code> should be in the <code>PATH</code>. The following command is used for the conversion:<br />
<br />
gm convert [inputfile] [outputfile]<br />
<br />
* '''[http://en.wikipedia.org/wiki/Tagged_Image_File_Format TIFF]''': File extensions <code>.tiff</code> and <code>.tif</code>. Converted to PDF using [http://en.wikipedia.org/wiki/GraphicsMagick GraphicsMagick].<br />
<br />
: For the conversion to work, <code>gm</code> should be in the <code>PATH</code>. The following command is used for the conversion:<br />
<br />
gm convert [inputfile] [outputfile]<br />
<br />
=== Supported movie formats ===<br />
<br />
The following movie formats are supported.<br />
<br />
* '''[http://en.wikipedia.org/wiki/QuickTime QuickTime]''': File extension <code>.mov</code>. <br />
* '''[https://en.wikipedia.org/wiki/Flash_Video Flash Video]''': File extension <code>.flv</code><br />
* '''[https://en.wikipedia.org/wiki/MPEG-4 MPEG 4]''': File extension <code>.mp4</code><br />
<br />
{{ note| Movie inclusion only works in a few PDF viewers }}<br />
<br />
=== Support for special TeX formats ===<br />
<br />
The following special formats are supported:<br />
<br />
* '''buffer''': Typeset the buffer with the given name and include the result as a PDF file.<br />
<br />
* '''tex''': Typeset the TeX file using <code>context</code> and include the result as a PDF file<br />
<br />
* '''cld''': Typeset the [[CLD|ConTeXt Lua document]] using <code>context</code> and include the result as a PDF file.<br />
<br />
== Command options ==<br />
<br />
=== <code>interaction</code> ===<br />
<br />
By default, the interactive elements of the included PDF file are discarded. To enable the interactive elements of the included PDF file, use<br />
<br />
<texcode>\externalfigure[filename.pdf][interaction=yes]</texcode><br />
<br />
== Example ==<br />
<br />
=== Including a local image ===<br />
<br />
In the example below, no file name extension is used. ConTeXt searches for an image file in the following order: <code>cow.pdf</code>, <code>cow.mps</code>, <code>cow.1</code>, <code>cow.2</code>, etc., <code>cow.jpg</code>, <code>cow.png</code>, <code>cow.jp2</code>, <code>cow.jbig</code>, <code>cow.jbig2</code>, <code>cow.jb2</code>. The file <code>cow.pdf</code>, which is distributed as part of the ConTeXt distribution, is found and displayed.<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[cow][width=4cm]<br />
</context><br />
<br />
ConTeXt distribution also includes a sample image <code>hacker.jpg</code>. To include it use:<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[hacker][height=3cm]<br />
</context><br />
<br />
=== Include a remote image ===<br />
<br />
<context source="yes" mode="mkiv"><br />
\externalfigure[http://placekitten.com/g/200/300][method=jpg]<br />
</context><br />
<br />
=== Rotate an image ===<br />
<br />
* '''Rotate by 90, 180, or 270 degrees''': Use <code>orientation=90|180|270</code> to rotate an image in multiples of 90. For example:<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[mill][orientation=180]<br />
</context><br />
<br />
<br />
* '''Rotate by an arbitrary angle''': Use {{cmd|rotate}} command.<br />
<br />
<context source="yes" mode=mkiv><br />
\rotate[rotation=45]{\externalfigure[mill]}<br />
</context><br />
<br />
=== Flip an image ===<br />
<br />
Use {{cmd|mirror}} to horizontally flip an image<br />
<br />
<context source=yes mode=mkiv><br />
\mirror{\externalfigure[cow][width=3cm]}<br />
</context><br />
<br />
== Error Messages ==<br />
<br />
When a file is specified by its full name, and is not found, no error message is displayed in the log; rather a gray box is shown in the generated PDF which indicates that the figure was not found. For example (note that <code>cat.pdf</code> should '''not''' exist in the current directory)<br />
<br />
<context source=yes><br />
\externalfigure[cat.pdf]<br />
</context><br />
<br />
== Tracking ==<br />
<br />
The following trackers are available for {{cmd|externalfigure}} (MkIV only) <br />
<br />
* '''graphics.locating''': Gives details about where the image files are searched, what strategy was used to infer the file format, and what was the inferred file format.<br />
<br />
* '''graphics.conversion''': Gives details about the conversion from one file format to another<br />
<br />
* '''graphics.inclusions''': Gives details of including a movie<br />
<br />
The trackers are enabled using<br />
<br />
\enabletrackers[...tracker...]<br />
<br />
or <br />
<br />
context --trackers=list [filename]<br />
<br />
When the '''graphics.locating''' tracker is enabled, including a known file displays the following information on the terminal:<br />
<br />
graphics > inclusion > locations: local,global<br />
graphics > inclusion > path list: . .. ../..<br />
graphics > inclusion > strategy: unknown format, prefer quality<br />
graphics > inclusion > found: ./cow.pdf -> /opt/context-minimals/texmf-context/tex/context/sample/cow.pdf<br />
graphics > inclusion > format natively supported by backend: pdf<br />
<br />
If the requested file does not exist, the following information is displayed:<br />
<br />
graphics > inclusion > locations: local,global<br />
graphics > inclusion > path list: . .. ../..<br />
graphics > inclusion > strategy: forced format pdf<br />
graphics > inclusion > not found: cat.pdf<br />
graphics > inclusion > not found: ./cat.pdf<br />
graphics > inclusion > not found: ../cat.pdf<br />
graphics > inclusion > not found: ../../cat.pdf<br />
graphics > inclusion > format not supported: %s<br />
<br />
When the '''graphics.conversion''' tracker is enabled and a file type that requires conversion (e.g., PS) is included, the following message is displayed on the terminal:<br />
<br />
graphics > inclusion > checking conversion of './tiger.ps' (./tiger.ps): old format 'ps', new format 'pdf', conversion 'default', resolution 'default'<br />
graphics > inclusion > no need to convert './tiger.ps' (tiger.ps) from 'ps' to 'pdf'<br />
graphics > inclusion > new graphic, hash: m_k_i_v_tiger.ps.pdf->1->crop->unknown->unknown->unknown-><br />
<br />
When the '''graphics.inclusion''' tracker is enabled and a movie is included, the following message is displayed on the terminal:<br />
<br />
graphics > inclusion > including movie 'clip.mov': width 5594039.4330709, height 5594039.4330709<br />
<br />
<br />
<noinclude><br />
<br />
== See also ==<br />
* {{cmd|defineexternalfigure}} to define a collection of settings<br />
* {{cmd|setupexternalfigures}} to define a different collection of settings<br />
* {{cmd|useexternalfigure}} to define an image+settings combination<br />
* [[Using Graphics]]<br />
* [[Multimedia Inclusion]] to add audio and video contents.<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
</noinclude><br />
<br />
[[Category:Command/FiguresImages|externalfigure]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/externalfigure&diff=34243Command/externalfigure2023-10-14T13:25:26Z<p>Zsd: /* Tracking */</p>
<hr />
<div><noinclude><br />
<br />
{{Reference<br />
|name=externalfigure<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>externalfigure</syntax><br />
<br />
</noinclude><br />
<br />
== Description == <br />
<br />
The <code>\externalfigure</code> command is used to include an external figure/movie inside ConTeXt. Includes both local files or remote files hosted on HTTP servers. <br />
<br />
The simplest way to insert an image is to use:<br />
<br />
<context source="yes" mode="mkiv"><br />
\externalfigure[cow.pdf]<br />
</context><br />
<br />
This command places the PDF image <code>cow.pdf</code> in a<br />
<code>\vbox</code>; the width and height of the image are equal to the natural dimensions of the image.<br />
<br />
To set the width of the image to a specific size, say <code>1cm</code>, use:<br />
<context source="yes" mode="mkiv" text="which gives"><br />
\externalfigure[cow.pdf][width=1cm]<br />
</context><br />
<br />
Similarly, to set the height of the image to a specific size, say <code>2cm</code>, use:<br />
<context source="yes" mode="mkiv" text="which gives"><br />
\externalfigure[cow.pdf][height=2cm]<br />
</context><br />
<br />
If only the <code>width</code> or <code>height</code> of the image is specified, the other dimension is scaled appropriately to keep the aspect ratio.<br />
<br />
To include a specific page, say page 5, of a multi-page PDF file, use:<br />
<texcode><br />
\externalfigure[filename.pdf][page=5]<br />
</texcode><br />
<br />
These four variations cover 90% of the use cases.<br />
<br />
<br />
=== How the filetype is determined ===<br />
<br />
* '''File extension''': Normally, the type of file is determined by the extension of the file (in a case-insensitive manner).<br />
* '''<code>method=type</code>''' If the file uses a non-standard extension, specify the file type using <code>method=type</code> where type is any of the file extensions that is recognized by {{cmd|externalfigure}}.<br />
* '''auto''': When the file extension is <code>.auto</code> or <code>method=auto</code> is used, ConTeXt reads the first few bytes of the file to determine the filetype. Such an auto-discovery is useful for remote images that do not have a file extension.<br />
<br />
If the extension of the file is not specified, ConTeXt searches for all possible extensions in the order given below.<br />
<br />
Historically, when postscript output was used, the order in which the file extensions were searched depended on the output format (PDF or PS). With recent releases of ConTeXt, PDF is the default output format, so for all practical purposes, the order in which the file extensions are searched is fixed.<br />
<br />
=== Natively supported image formats ===<br />
<br />
The following image formats are supported natively in MkIV:<br />
<br />
* '''[http://en.wikipedia.org/wiki/Portable_Document_Format PDF]''': File extension <code>.pdf</code>. By default, ''mediabox'' is used to determine size. Use <code>size=artbox</code> to use ''artbox''.<br />
* '''MPS (MetaPost Output)''': File extension <code>.mp</code>, <code>.mps</code> or <code>.[digits]</code>.<br />
<!-- Converted to PDF on the fly using MPtoPDF. --><br />
* '''[http://en.wikipedia.org/wiki/JPEG JPEG]''': File extension <code>.jpg</code> and <code>.jpeg</code><br />
* '''[http://en.wikipedia.org/wiki/Portable_Network_Graphics PNG]''': File extesion <code>.png</code><br />
* '''[http://en.wikipedia.org/wiki/JPEG_2000 JPEG 2000]''': File extesion <code>.jp2</code><br />
* '''[http://en.wikipedia.org/wiki/JBIG JBIG]''' and '''[http://en.wikipedia.org/wiki/JBIG2 JBIG2]''': File extension <code>.jbig</code>, <code>.jbib2</code>, and <code>.jb2</code><br />
<br />
Additionally supported natively in LMTX:<br />
<br />
* '''[http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG]''': File extension <code>.svg</code> and <code>.svgz</code> via an internal Metapost conversion; use <code>conversion=mp</code><br />
<br />
=== Image formats supported through external converters ===<br />
<br />
The following formats are converted to PDF by external programs before being included. The conversion generates a new file with a prefix <code>m_k_i_v_</code> and a suffix <code>.pdf</code> added to the name of the original file (the original extension is not removed). The result is cached, and the conversion is rerun only if the timestamp of the original file is newer than the converted file.<br />
<br />
<br />
* '''[http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG]''': File extension <code>.svg</code> and <code>.svgz</code>. Converted to PDF using [http://en.wikipedia.org/wiki/Inkscape Inkscape]. <br />
<br />
: For the conversion to work, <code>inkscape</code> should be in the <code>PATH</code>. The following command is used for conversion:<br />
<br />
inkscape [inputfile] --export-dpi=600 -A [outputfile] <br />
<br />
: (Note: Conversion to PNG is also possible, but I don’t know the details on how to active that -- 03:32, 29 November 2012 (CET)).<br />
<br />
* '''[http://en.wikipedia.org/wiki/PostScript PS]''' and '''[http://en.wikipedia.org/wiki/Encapsulated_PostScript EPS]''': File extension <code>.eps</code> and <code>.ai</code>. Converted to PDF using [http://en.wikipedia.org/wiki/Ghostscript Ghostscript]. <br />
<br />
<br />
: For the conversion to work, on Windows <code>gswin32c</code> must be in the <code>PATH</code>; on other platforms <code>gs</code> must be in the <code>PATH</code>. The following command line options are passed to Ghostscript<br />
<br />
gs -q -sDEVICE=pdfwrite -dNOPAUSE -dNOCACHE -dBATCH [resolution] -sOutputFile=[outputfile] [inputfile] -c quit<br />
<br />
: By default, the <code>[resolution]</code> is ''prepress''. Use <code>resolution=low</code> to change the <code>[resolution]</code> to ''screen'' and <code>resolution=meidum</code> to change the <code>[resolution]</code> to ''ebook''.<br />
<br />
* '''[http://en.wikipedia.org/wiki/GIF GIF]''': File extension <code>.gif</code>. Converted to PDF using [http://en.wikipedia.org/wiki/GraphicsMagick GraphicsMagick].<br />
<br />
: For the conversion to work, <code>gm</code> should be in the <code>PATH</code>. The following command is used for the conversion:<br />
<br />
gm convert [inputfile] [outputfile]<br />
<br />
* '''[http://en.wikipedia.org/wiki/Tagged_Image_File_Format TIFF]''': File extensions <code>.tiff</code> and <code>.tif</code>. Converted to PDF using [http://en.wikipedia.org/wiki/GraphicsMagick GraphicsMagick].<br />
<br />
: For the conversion to work, <code>gm</code> should be in the <code>PATH</code>. The following command is used for the conversion:<br />
<br />
gm convert [inputfile] [outputfile]<br />
<br />
=== Supported movie formats ===<br />
<br />
The following movie formats are supported.<br />
<br />
* '''[http://en.wikipedia.org/wiki/QuickTime QuickTime]''': File extension <code>.mov</code>. <br />
* '''[https://en.wikipedia.org/wiki/Flash_Video Flash Video]''': File extension <code>.flv</code><br />
* '''[https://en.wikipedia.org/wiki/MPEG-4 MPEG 4]''': File extension <code>.mp4</code><br />
<br />
{{ note| Movie inclusion only works in a few PDF viewers }}<br />
<br />
=== Support for special TeX formats ===<br />
<br />
The following special formats are supported:<br />
<br />
* '''buffer''': Typeset the buffer with the given name and include the result as a PDF file.<br />
<br />
* '''tex''': Typeset the TeX file using <code>context</code> and include the result as a PDF file<br />
<br />
* '''cld''': Typeset the [[CLD|ConTeXt Lua document]] using <code>context</code> and include the result as a PDF file.<br />
<br />
== Command options ==<br />
<br />
=== <code>interaction</code> ===<br />
<br />
By default, the interactive elements of the included PDF file are discarded. To enable the interactive elements of the included PDF file, use<br />
<br />
<texcode>\externalfigure[filename.pdf][interaction=yes]</texcode><br />
<br />
== Example ==<br />
<br />
=== Including a local image ===<br />
<br />
In the example below, no file name extension is used. ConTeXt searches for an image file in the following order: <code>cow.pdf</code>, <code>cow.mps</code>, <code>cow.1</code>, <code>cow.2</code>, etc., <code>cow.jpg</code>, <code>cow.png</code>, <code>cow.jp2</code>, <code>cow.jbig</code>, <code>cow.jbig2</code>, <code>cow.jb2</code>. The file <code>cow.pdf</code>, which is distributed as part of the ConTeXt distribution, is found and displayed.<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[cow][width=4cm]<br />
</context><br />
<br />
ConTeXt distribution also includes a sample image <code>hacker.jpg</code>. To include it use:<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[hacker][height=3cm]<br />
</context><br />
<br />
=== Include a remote image ===<br />
<br />
<context source="yes" mode="mkiv"><br />
\externalfigure[http://placekitten.com/g/200/300][method=jpg]<br />
</context><br />
<br />
=== Rotate an image ===<br />
<br />
* '''Rotate by 90, 180, or 270 degrees''': Use <code>orientation=90|180|270</code> to rotate an image in multiples of 90. For example:<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[mill][orientation=180]<br />
</context><br />
<br />
<br />
* '''Rotate by an arbitrary angle''': Use {{cmd|rotate}} command.<br />
<br />
<context source="yes" mode=mkiv><br />
\rotate[rotation=45]{\externalfigure[mill]}<br />
</context><br />
<br />
=== Flip an image ===<br />
<br />
Use {{cmd|mirror}} to horizontally flip an image<br />
<br />
<context source=yes mode=mkiv><br />
\mirror{\externalfigure[cow][width=3cm]}<br />
</context><br />
<br />
== Error Messages ==<br />
<br />
When a file is specified by its full name, and is not found, no error message is displayed in the log; rather a gray box is shown in the generated PDF which indicates that the figure was not found. For example (note that <code>cat.pdf</code> should '''not''' exist in the current directory)<br />
<br />
<context source=yes><br />
\externalfigure[cat.pdf]<br />
</context><br />
<br />
== Tracking ==<br />
<br />
The following trackers are available for {{cmd|externalfigures}} (MkIV only) <br />
<br />
* '''graphics.locating''': Gives details about where the image files are searched, what strategy was used to infer the file format, and what was the inferred file format.<br />
<br />
* '''graphics.conversion''': Gives details about the conversion from one file format to another<br />
<br />
* '''graphics.inclusions''': Gives details of including a movie<br />
<br />
The trackers are enabled using<br />
<br />
\enabletrackers[...tracker...]<br />
<br />
or <br />
<br />
context --trackers=list [filename]<br />
<br />
When the '''graphics.locating''' tracker is enabled, including a known file displays the following information on the terminal:<br />
<br />
graphics > inclusion > locations: local,global<br />
graphics > inclusion > path list: . .. ../..<br />
graphics > inclusion > strategy: unknown format, prefer quality<br />
graphics > inclusion > found: ./cow.pdf -> /opt/context-minimals/texmf-context/tex/context/sample/cow.pdf<br />
graphics > inclusion > format natively supported by backend: pdf<br />
<br />
If the requested file does not exist, the following information is displayed:<br />
<br />
graphics > inclusion > locations: local,global<br />
graphics > inclusion > path list: . .. ../..<br />
graphics > inclusion > strategy: forced format pdf<br />
graphics > inclusion > not found: cat.pdf<br />
graphics > inclusion > not found: ./cat.pdf<br />
graphics > inclusion > not found: ../cat.pdf<br />
graphics > inclusion > not found: ../../cat.pdf<br />
graphics > inclusion > format not supported: %s<br />
<br />
When the '''graphics.conversion''' tracker is enabled and a file type that requires conversion (e.g., PS) is included, the following message is displayed on the terminal:<br />
<br />
graphics > inclusion > checking conversion of './tiger.ps' (./tiger.ps): old format 'ps', new format 'pdf', conversion 'default', resolution 'default'<br />
graphics > inclusion > no need to convert './tiger.ps' (tiger.ps) from 'ps' to 'pdf'<br />
graphics > inclusion > new graphic, hash: m_k_i_v_tiger.ps.pdf->1->crop->unknown->unknown->unknown-><br />
<br />
When the '''graphics.inclusion''' tracker is enabled and a movie is included, the following message is displayed on the terminal:<br />
<br />
graphics > inclusion > including movie 'clip.mov': width 5594039.4330709, height 5594039.4330709<br />
<br />
<br />
<noinclude><br />
<br />
== See also ==<br />
* {{cmd|defineexternalfigure}} to define a collection of settings<br />
* {{cmd|setupexternalfigures}} to define a different collection of settings<br />
* {{cmd|useexternalfigure}} to define an image+settings combination<br />
* [[Using Graphics]]<br />
* [[Multimedia Inclusion]] to add audio and video contents.<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
</noinclude><br />
<br />
[[Category:Command/FiguresImages|externalfigure]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/externalfigure&diff=34242Command/externalfigure2023-10-14T13:20:46Z<p>Zsd: /* Tracking */ Minor grammatical change.</p>
<hr />
<div><noinclude><br />
<br />
{{Reference<br />
|name=externalfigure<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>externalfigure</syntax><br />
<br />
</noinclude><br />
<br />
== Description == <br />
<br />
The <code>\externalfigure</code> command is used to include an external figure/movie inside ConTeXt. Includes both local files or remote files hosted on HTTP servers. <br />
<br />
The simplest way to insert an image is to use:<br />
<br />
<context source="yes" mode="mkiv"><br />
\externalfigure[cow.pdf]<br />
</context><br />
<br />
This command places the PDF image <code>cow.pdf</code> in a<br />
<code>\vbox</code>; the width and height of the image are equal to the natural dimensions of the image.<br />
<br />
To set the width of the image to a specific size, say <code>1cm</code>, use:<br />
<context source="yes" mode="mkiv" text="which gives"><br />
\externalfigure[cow.pdf][width=1cm]<br />
</context><br />
<br />
Similarly, to set the height of the image to a specific size, say <code>2cm</code>, use:<br />
<context source="yes" mode="mkiv" text="which gives"><br />
\externalfigure[cow.pdf][height=2cm]<br />
</context><br />
<br />
If only the <code>width</code> or <code>height</code> of the image is specified, the other dimension is scaled appropriately to keep the aspect ratio.<br />
<br />
To include a specific page, say page 5, of a multi-page PDF file, use:<br />
<texcode><br />
\externalfigure[filename.pdf][page=5]<br />
</texcode><br />
<br />
These four variations cover 90% of the use cases.<br />
<br />
<br />
=== How the filetype is determined ===<br />
<br />
* '''File extension''': Normally, the type of file is determined by the extension of the file (in a case-insensitive manner).<br />
* '''<code>method=type</code>''' If the file uses a non-standard extension, specify the file type using <code>method=type</code> where type is any of the file extensions that is recognized by {{cmd|externalfigure}}.<br />
* '''auto''': When the file extension is <code>.auto</code> or <code>method=auto</code> is used, ConTeXt reads the first few bytes of the file to determine the filetype. Such an auto-discovery is useful for remote images that do not have a file extension.<br />
<br />
If the extension of the file is not specified, ConTeXt searches for all possible extensions in the order given below.<br />
<br />
Historically, when postscript output was used, the order in which the file extensions were searched depended on the output format (PDF or PS). With recent releases of ConTeXt, PDF is the default output format, so for all practical purposes, the order in which the file extensions are searched is fixed.<br />
<br />
=== Natively supported image formats ===<br />
<br />
The following image formats are supported natively in MkIV:<br />
<br />
* '''[http://en.wikipedia.org/wiki/Portable_Document_Format PDF]''': File extension <code>.pdf</code>. By default, ''mediabox'' is used to determine size. Use <code>size=artbox</code> to use ''artbox''.<br />
* '''MPS (MetaPost Output)''': File extension <code>.mp</code>, <code>.mps</code> or <code>.[digits]</code>.<br />
<!-- Converted to PDF on the fly using MPtoPDF. --><br />
* '''[http://en.wikipedia.org/wiki/JPEG JPEG]''': File extension <code>.jpg</code> and <code>.jpeg</code><br />
* '''[http://en.wikipedia.org/wiki/Portable_Network_Graphics PNG]''': File extesion <code>.png</code><br />
* '''[http://en.wikipedia.org/wiki/JPEG_2000 JPEG 2000]''': File extesion <code>.jp2</code><br />
* '''[http://en.wikipedia.org/wiki/JBIG JBIG]''' and '''[http://en.wikipedia.org/wiki/JBIG2 JBIG2]''': File extension <code>.jbig</code>, <code>.jbib2</code>, and <code>.jb2</code><br />
<br />
Additionally supported natively in LMTX:<br />
<br />
* '''[http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG]''': File extension <code>.svg</code> and <code>.svgz</code> via an internal Metapost conversion; use <code>conversion=mp</code><br />
<br />
=== Image formats supported through external converters ===<br />
<br />
The following formats are converted to PDF by external programs before being included. The conversion generates a new file with a prefix <code>m_k_i_v_</code> and a suffix <code>.pdf</code> added to the name of the original file (the original extension is not removed). The result is cached, and the conversion is rerun only if the timestamp of the original file is newer than the converted file.<br />
<br />
<br />
* '''[http://en.wikipedia.org/wiki/Scalable_Vector_Graphics SVG]''': File extension <code>.svg</code> and <code>.svgz</code>. Converted to PDF using [http://en.wikipedia.org/wiki/Inkscape Inkscape]. <br />
<br />
: For the conversion to work, <code>inkscape</code> should be in the <code>PATH</code>. The following command is used for conversion:<br />
<br />
inkscape [inputfile] --export-dpi=600 -A [outputfile] <br />
<br />
: (Note: Conversion to PNG is also possible, but I don’t know the details on how to active that -- 03:32, 29 November 2012 (CET)).<br />
<br />
* '''[http://en.wikipedia.org/wiki/PostScript PS]''' and '''[http://en.wikipedia.org/wiki/Encapsulated_PostScript EPS]''': File extension <code>.eps</code> and <code>.ai</code>. Converted to PDF using [http://en.wikipedia.org/wiki/Ghostscript Ghostscript]. <br />
<br />
<br />
: For the conversion to work, on Windows <code>gswin32c</code> must be in the <code>PATH</code>; on other platforms <code>gs</code> must be in the <code>PATH</code>. The following command line options are passed to Ghostscript<br />
<br />
gs -q -sDEVICE=pdfwrite -dNOPAUSE -dNOCACHE -dBATCH [resolution] -sOutputFile=[outputfile] [inputfile] -c quit<br />
<br />
: By default, the <code>[resolution]</code> is ''prepress''. Use <code>resolution=low</code> to change the <code>[resolution]</code> to ''screen'' and <code>resolution=meidum</code> to change the <code>[resolution]</code> to ''ebook''.<br />
<br />
* '''[http://en.wikipedia.org/wiki/GIF GIF]''': File extension <code>.gif</code>. Converted to PDF using [http://en.wikipedia.org/wiki/GraphicsMagick GraphicsMagick].<br />
<br />
: For the conversion to work, <code>gm</code> should be in the <code>PATH</code>. The following command is used for the conversion:<br />
<br />
gm convert [inputfile] [outputfile]<br />
<br />
* '''[http://en.wikipedia.org/wiki/Tagged_Image_File_Format TIFF]''': File extensions <code>.tiff</code> and <code>.tif</code>. Converted to PDF using [http://en.wikipedia.org/wiki/GraphicsMagick GraphicsMagick].<br />
<br />
: For the conversion to work, <code>gm</code> should be in the <code>PATH</code>. The following command is used for the conversion:<br />
<br />
gm convert [inputfile] [outputfile]<br />
<br />
=== Supported movie formats ===<br />
<br />
The following movie formats are supported.<br />
<br />
* '''[http://en.wikipedia.org/wiki/QuickTime QuickTime]''': File extension <code>.mov</code>. <br />
* '''[https://en.wikipedia.org/wiki/Flash_Video Flash Video]''': File extension <code>.flv</code><br />
* '''[https://en.wikipedia.org/wiki/MPEG-4 MPEG 4]''': File extension <code>.mp4</code><br />
<br />
{{ note| Movie inclusion only works in a few PDF viewers }}<br />
<br />
=== Support for special TeX formats ===<br />
<br />
The following special formats are supported:<br />
<br />
* '''buffer''': Typeset the buffer with the given name and include the result as a PDF file.<br />
<br />
* '''tex''': Typeset the TeX file using <code>context</code> and include the result as a PDF file<br />
<br />
* '''cld''': Typeset the [[CLD|ConTeXt Lua document]] using <code>context</code> and include the result as a PDF file.<br />
<br />
== Command options ==<br />
<br />
=== <code>interaction</code> ===<br />
<br />
By default, the interactive elements of the included PDF file are discarded. To enable the interactive elements of the included PDF file, use<br />
<br />
<texcode>\externalfigure[filename.pdf][interaction=yes]</texcode><br />
<br />
== Example ==<br />
<br />
=== Including a local image ===<br />
<br />
In the example below, no file name extension is used. ConTeXt searches for an image file in the following order: <code>cow.pdf</code>, <code>cow.mps</code>, <code>cow.1</code>, <code>cow.2</code>, etc., <code>cow.jpg</code>, <code>cow.png</code>, <code>cow.jp2</code>, <code>cow.jbig</code>, <code>cow.jbig2</code>, <code>cow.jb2</code>. The file <code>cow.pdf</code>, which is distributed as part of the ConTeXt distribution, is found and displayed.<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[cow][width=4cm]<br />
</context><br />
<br />
ConTeXt distribution also includes a sample image <code>hacker.jpg</code>. To include it use:<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[hacker][height=3cm]<br />
</context><br />
<br />
=== Include a remote image ===<br />
<br />
<context source="yes" mode="mkiv"><br />
\externalfigure[http://placekitten.com/g/200/300][method=jpg]<br />
</context><br />
<br />
=== Rotate an image ===<br />
<br />
* '''Rotate by 90, 180, or 270 degrees''': Use <code>orientation=90|180|270</code> to rotate an image in multiples of 90. For example:<br />
<br />
<context source="yes" mode=mkiv><br />
\externalfigure[mill][orientation=180]<br />
</context><br />
<br />
<br />
* '''Rotate by an arbitrary angle''': Use {{cmd|rotate}} command.<br />
<br />
<context source="yes" mode=mkiv><br />
\rotate[rotation=45]{\externalfigure[mill]}<br />
</context><br />
<br />
=== Flip an image ===<br />
<br />
Use {{cmd|mirror}} to horizontally flip an image<br />
<br />
<context source=yes mode=mkiv><br />
\mirror{\externalfigure[cow][width=3cm]}<br />
</context><br />
<br />
== Error Messages ==<br />
<br />
When a file is specified by its full name, and is not found, no error message is displayed in the log; rather a gray box is shown in the generated PDF which indicates that the figure was not found. For example (note that <code>cat.pdf</code> should '''not''' exist in the current directory)<br />
<br />
<context source=yes><br />
\externalfigure[cat.pdf]<br />
</context><br />
<br />
== Tracking ==<br />
<br />
The following trackers are available for {{cmd|externalfigures}} (MkIV only) <br />
<br />
* '''graphics.locating''': Gives details about where the image files are searched, what strategy was used to infer the file format, and what was the inferred file format.<br />
<br />
* '''graphics.conversion''': Gives details about the conversion from one file format to another<br />
<br />
* '''graphics.inclusions''': Gives details of including a movie<br />
<br />
The trackers are enabled using<br />
<br />
\enabletrackers[...tracker...]<br />
<br />
or <br />
<br />
context --trackers=list [filename]<br />
<br />
When '''graphics.locating''' tracker is enabled, including a known file gives the following information on the terminal<br />
<br />
graphics > inclusion > locations: local,global<br />
graphics > inclusion > path list: . .. ../..<br />
graphics > inclusion > strategy: unknown format, prefer quality<br />
graphics > inclusion > found: ./cow.pdf -> /opt/context-minimals/texmf-context/tex/context/sample/cow.pdf<br />
graphics > inclusion > format natively supported by backend: pdf<br />
<br />
If the requested file does not exist, the following information is displayed.<br />
<br />
<br />
graphics > inclusion > locations: local,global<br />
graphics > inclusion > path list: . .. ../..<br />
graphics > inclusion > strategy: forced format pdf<br />
graphics > inclusion > not found: cat.pdf<br />
graphics > inclusion > not found: ./cat.pdf<br />
graphics > inclusion > not found: ../cat.pdf<br />
graphics > inclusion > not found: ../../cat.pdf<br />
graphics > inclusion > format not supported: %s<br />
<br />
When '''graphics.conversion''' tracker is enabled, and, including a file type that requires conversion, say PS, displays the following message on the terminal<br />
<br />
graphics > inclusion > checking conversion of './tiger.ps' (./tiger.ps): old format 'ps', new format 'pdf', conversion 'default', resolution 'default'<br />
graphics > inclusion > no need to convert './tiger.ps' (tiger.ps) from 'ps' to 'pdf'<br />
graphics > inclusion > new graphic, hash: m_k_i_v_tiger.ps.pdf->1->crop->unknown->unknown->unknown-><br />
<br />
When '''graphics.inclusion''' tracker is enabled, including a movie displays the following message on the terminal <br />
<br />
graphics > inclusion > including movie 'clip.mov': width 5594039.4330709, height 5594039.4330709<br />
<br />
<br />
<noinclude><br />
<br />
== See also ==<br />
* {{cmd|defineexternalfigure}} to define a collection of settings<br />
* {{cmd|setupexternalfigures}} to define a different collection of settings<br />
* {{cmd|useexternalfigure}} to define an image+settings combination<br />
* [[Using Graphics]]<br />
* [[Multimedia Inclusion]] to add audio and video contents.<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
</noinclude><br />
<br />
[[Category:Command/FiguresImages|externalfigure]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Tabulate&diff=34025Tabulate2023-09-11T13:46:10Z<p>Zsd: /* Basic commands */</p>
<hr />
<div>< [[Tables Overview]] | [[Table]] ><br />
<br />
<br />
=Summary=<br />
<br />
{{cmd|starttabulate}} is a versatile table environment.<br />
It supports ''paragraphs'' in cells, ''vertical rules'' (for<br />
those typographically less demanding jobs&nbsp;…), and<br />
''colorization'' of those rules, the background of fields as well<br />
as the text itself.<br />
<br />
'''Warning''': When you want to use tables with macros use {{cmd|starttable}} and \stoptable. {{cmd|starttabulate}} and \stoptabulate does not work correctly with macros.<br />
<br />
=Basic commands=<br />
<br />
The control sequence {{cmd|starttabulate|[#1]}} takes a layout<br />
string as optional argument.<br />
As is common with tables in TeX-based typesetting, this string<br />
(in its basic variant) consists primarily of the ''bar''<br />
character (“<tt>|</tt>”) as delimiter for columns,<br />
and of the letters <tt>c</tt>, <tt>l</tt>, as well as <tt>r</tt>,<br />
denoting the ''alignment'' within cells of this row.<br />
<br />
For instance consider a two-column table: if text in the<br />
first column should be right aligned (''real''<br />
[[Right and left|<tt>flushright</tt>]]) and the second column<br />
left aligned, the corresponding format string would be<br />
<tt>|l|r|</tt>.<br />
''NB'': those bars, as stated above, denote cell limits only<br />
&ndash; ''not'' vertical lines.<br />
<br />
<!--<br />
- wtf this listing was full of <tab> chars‽ Was this supposed<br />
- to be a bad pun on *tabulate*?<br />
- - No, I formatted it readably in my text editor. --HR<br />
--><br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|l|lB|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning} \NC Mk \NC\NR<br />
\HL<br />
\NC c \NC centered \NC \NC\NR<br />
\NC l \NC left aligned \NC \NC\NR<br />
\NC r \NC right aligned \NC \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC \NC\NR<br />
\NC cg(.) \NC align on a character \NC IV: cg{.} \NC\NR<br />
\NC m \NC math mode \NC IV only \NC\NR<br />
\NC b \NC before e.g. b{\star} \NC IV only \NC\NR<br />
\NC a \NC after, e.g. a{\percent} \NC IV only \NC\NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
|<br />
|<context><br />
\setuppapersize[A5]<br />
\starttabulate[|r|l|lB|]<br />
\HL<br />
\NC {\bf format} \NC {\bf meaning}\NC Mk \NC\NR<br />
\HL<br />
\NC c \NC centered \NC\NR<br />
\NC l \NC left aligned \NC\NR<br />
\NC r \NC right aligned \NC\NR<br />
\NC w(1cm) \NC one line, fixed width \NC\NR<br />
\NC p(2cm) \NC paragraph, lines broken to fixed width \NC\NR<br />
\NC cg(.) \NC align on a character \NC\NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
* {{cmd|HL}} draws a horizontal rule,<br />
* {{cmd|NC}} marks a new column (or new cell),<br />
* {{cmd|NS}} marka a new cell that spans more than one column (LMTX only),<br />
* {{cmd|NN}} marks a new math column/cell (see below),<br />
* {{cmd|NR}} starts a new row,<br />
* {{cmd|NB}} starts a new row as a block (avoids page breaking inside of a block, to keep some lines together),<br />
* {{cmd|TB}} (= "Table Blank") adds some vertical space between rows -- see an example below,<br />
* {{cmd|VL}} (instead of {{cmd|NC}}) draws a vertical rule -- for more info see below.<br />
<br />
When using fixed width, you can use values relative to the<br />
current page-width. For example: if you want the previous table<br />
to take up all the width and having the second column taking three<br />
quarters of the space, change the {{cmd|starttabulate}} to:<br />
<texcode><br />
\starttabulate[|rw(.25\textwidth)|lw(.75\textwidth)|]<br />
</texcode><br />
(Mistake: This doesn’t account for the width of the column distance!)<br />
<br />
=Horizontal centering table on the page=<br />
<br />
<context source=yes><br />
This is a very long text, longer than the width of the table.<br />
It must be long enough to flow to the next line to see the effect.<br />
<br />
\placetable[force,none]{}{%<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC I want this table \NC aligned in the center.\NC\NR<br />
\HL<br />
\stoptabulate<br />
}</context><br />
<br />
This can also be done with the start/stop syntax:<br />
<br />
<context source=yes><br />
This is a very long text, longer than the width of the table.<br />
It must be long enough to flow to the next line to see the effect.<br />
<br />
\startplacetable[location=force,number=no]<br />
\starttabulate[|r|l|]<br />
\HL<br />
\NC I want this table \NC aligned in the center.\NC\NR<br />
\HL<br />
\stoptabulate<br />
\stopplacetable<br />
</context><br />
<br />
=Spanning columns=<br />
<br />
Only LMTX since September 2021 supports wide cells:<br />
<br />
<context source=yes><br />
\starttabulate[|r|l|c|]<br />
\HL<br />
\NC 123 \NC foo \NC bar \NC\NR<br />
\NS[2][c] LMTX \NC\NR<br />
\NC 123 \NC baz \NC bla \NC\NR<br />
\HL<br />
\stoptabulate<br />
</context><br />
<br />
The two parameters of {{cmd|NS}} are the number of additional columns (i.e. 1 of you want to span 2 columns), and the formatting for it.<br />
<br />
This works only with single-line cells, i.e. not with “p” columns.<br />
<br />
=Spanning Multiple Pages=<br />
<br />
Tabulate may extend to adjacient pages if needed.<br />
To achieve this the argument <tt>split</tt> must be set to<br />
''true''.<br />
<br />
''NB'': the difference between setting and unsetting this<br />
argument may not be visible on the first few pages. Rather, it<br />
seems to affect the ''end'' of the environment.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red] Fenchurch St. Paul},<br />
frame=on]<br />
<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
</context><br />
<br />
<br />
==Titles==<br />
<br />
A tabulating environment can have an optional name which will be<br />
repeated above at every page break that occurs inside the table.<br />
This name needs to be specified as the argument of the<br />
<tt>title</tt> key of {{cmd|setuptabulate}}.<br />
The <tt>header</tt> key has to be set to <em>text</em> for this<br />
to work.<br />
<br />
<context source=yes><br />
\setuppapersize[A10, landscape][A8, landscape]<br />
\setuppaper[nx=2,ny=2]<br />
\setuparranging[XY]<br />
<br />
\switchtobodyfont[5pt]<br />
\setuppagenumbering[location={header,inright}]<br />
\showframe[edge]<br />
<br />
\setuptabulate<br />
[split=yes,<br />
header=text,<br />
title={\color[red]{Fenchurch St. Paul}\strut},<br />
frame=on]<br />
<br />
\starttext<br />
\starttabulate[|p(1.2cm)|p(1.2cm)|]<br />
\dorecurse{6}{<br />
\NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR<br />
\HL<br />
\NC Name: \NC Tailor Paul \NC \NR <br />
\HL<br />
}<br />
\stoptabulate<br />
\stoptext<br />
</context><br />
<br />
<!--<br />
- ==Headers and Footers==<br />
- As I couldn’t get footers running I just comment this and<br />
- leave it to whoever discovers the trick to activate them.<br />
- (The <tt>footer=</tt> key seems to be implemented for<br />
- “\setuptabulate” but I couldn’t notice any effect.<br />
--><br />
<br />
==Headers==<br />
Tabulate supports header rows that can be repeated over new table<br />
pages instead of the title.<br />
There is a separate environment {{cmd|starttabulatehead}} where<br />
this header row has to be specified in advance of its use in a<br />
tabulation.<br />
<br />
In ConTeXt MkIV the command requires an additional [], thus you need<br />
to write {{cmd|starttabulatehead}}[] instead.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\FL<br />
\NC {\bf format char} \NC {\bf meaning} \NC \AR<br />
\LL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \NC \AR<br />
\NC l \NC left aligned \NC \AR<br />
\NC r \NC right aligned \NC \AR<br />
\stoptabulate<br />
</texcode><br />
|<br />
| <context><br />
\setuppapersize[A5]<br />
<br />
\setuptabulate[split=yes,header=repeat]<br />
<br />
\starttabulatehead<br />
\FL<br />
\NC {\bf format char} \NC {\bf meaning} \AR<br />
\LL<br />
\stoptabulatehead<br />
<br />
\starttabulate[|r|l|]<br />
\NC c \NC centered \AR<br />
\NC l \NC left aligned \AR<br />
\NC r \NC right aligned \AR<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
Note the use of <tt>\FL</tt> and <tt>\LL</tt> in the tabulate header rather than <tt>\HL</tt> which is a standard rule command (see below) that tries to guess automatically its position.<br />
<br />
=Individualizing the Tabulate Look=<br />
<br />
Hans initially announced support for vertical lines and colors on<br />
the mailing list. [http://archive.contextgarden.net/message/20101117.123950.739657a7.en.html]<br />
<br />
==Rules==<br />
<br />
===Horizontal Rules===<br />
<br />
As already demonstrated above, the <tt>\HL</tt> statement inserts<br />
a hairline after the current line.<br />
This particularly useful when demarking header and footer rows or<br />
separated parts of a table that should not be as closely<br />
associated as the rows between the rules.<br />
<br />
{|<br />
! width="55%"|<br />
! width="10%"|<br />
! width="35%"|<br />
|-<br />
| <texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</texcode><br />
| <context><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\NC test \NC test \NC test \NC\NR <br />
\HL<br />
\stoptabulate<br />
</context><br />
|}<br />
<br />
Context supports different categories of rules that can be<br />
configured individually in order to discern various applications.<br />
Their behaviour accounts for the designated use, e.g.<br />
<tt>\ML</tt> (mid rules) are intended to be deployed between<br />
ordinary rows of the table body and will prevent page breaks<br />
&ndash; no way you’d end up with a rogue hairline desecrating<br />
the bottom of your page’s text area.<br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Type !! Description<br />
|-<br />
|<tt>\HL</tt> || standard horizontal rule;<br />
|-<br />
|<tt>\FL</tt> || first rule;<br />
|-<br />
|<tt>\ML</tt> || mid rule;<br />
|-<br />
|<tt>\LL</tt> || bottom rule;<br />
|-<br />
|<tt>\LL</tt> and <tt>\TL</tt> || bottom rule;<br />
|-<br />
|<tt>\BL</tt> || last rule.<br />
|}<br />
<br />
Additionally, there is an option <tt>rulecolor</tt> for<br />
{{cmd|setuptabulate}} that allows for those rules to be tinted.<br />
<br />
<texcode><br />
\setuptabulate[rulecolor=red]<br />
<br />
\starttabulate[|r|c|l|] <br />
\FL<br />
\NC first row \NC test \NC test \NC\NR <br />
\ML<br />
\NC rows in \NC test \NC test \NC\NR <br />
\NC between \NC test \NC test \NC\NR <br />
\LL <br />
\NC last row \NC test \NC test \NC\NR <br />
\BL<br />
\stoptabulate<br />
</texcode><br />
<br />
Other types can be discovered in the source<br />
([[source:tabl-tbl.mkiv|tabl-tbl.mkiv]]).<br />
<br />
===Vertical Rules===<br />
<br />
The {{cmd|VL}} command serves as a replacement for {{cmd|NC}}<br />
to mark a cell border wherever a vertical rule may be desired (if<br />
they are to be desired at all from a typographical point of<br />
view).<br />
<br />
<texcode><br />
\starttabulate[||||] <br />
\NC test \VL test \VL test \VL\NR <br />
\VL test \NC test \VL test \VL\NR <br />
\VL test \VL test \NC test \VL\NR <br />
\VL test \VL test \VL test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
==Coloring==<br />
<br />
The following elements can be colorized: rules, cell backgrounds,<br />
and, obviously, common text.<br />
<br />
===Colorizing Rules===<br />
<br />
For ''horizontal rules'' see above.<br />
<br />
For ''vertical rules'', {{cmd|VL}} takes a defined color as an<br />
optional argument.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\VL test \VL[red] red rule \VL test \VL \NR <br />
\VL test \VL[green] green rule \VL test \VL \NR <br />
\VL test \VL[blue] blue rule \VL test \VL \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
===Colorizing Backgrounds & Text===<br />
Backgrounds and text can be colorized either on column basis or<br />
individually by cell.<br />
<br />
There are five color-specific control sequences:<br />
{|<br />
|{{cmd|CR}} || color is applied to the background of the text and the remaining space on the right.<br />
|-<br />
|{{cmd|CC}} || color is applied to the background of the text only.<br />
|-<br />
|{{cmd|CM}} || color is applied to the background of the text and the remaining space on both sides.<br />
|-<br />
|{{cmd|CL}} || color is applied to the background of the text and the remaining space on the left.<br />
|-<br />
|{{cmd|CT}} || color is applied to the text itself - in other words, the "foreground color."<br />
|}<br />
These are to complement the normal table layout expression (the<br />
first argument to {{cmd|starttabulate}.<br />
Thus, in order to colorize a four column table with the initial<br />
layout <tt>|c|c|c|c|</tt> it will have to be modified as follows:<br />
<texcode><br />
\starttabulate[|CR{red}c|CC{yellow}c|CM{green}c|CL{blue}c|] <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\NC test \NC test \NC test \NC test \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
Those control sequences, if applied within the table body, can<br />
replace the ordinary {{cmd|NC}}, allowing individual cells to<br />
be colorized.<br />
<texcode><br />
\starttabulate[|c|c|c|c|c|c|]<br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \CM[blue] d \NC e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \CM[blue] i \CM[blue] d \CM[blue] e \NC r \NC \NR <br />
\NC g \NC l \NC i \NC d \NC e \NC r \NC \NR <br />
\stoptabulate<br />
</texcode><br />
<br />
'''caveat emptor'''! The background coloring does apply only to<br />
the ''first'' row of a paragraph cell. Any other cell will come<br />
out colorless. If you need to color an entire multi-line cell,<br />
you will need to switch to another<br />
[[Tables Overview|tabulation variant]].<br />
<br />
===Colorizing Cell Text===<br />
''Normal text'' inside cells gets its color via the<br />
[[Color|standard coloring commands]], or by the <br />
shorter variant described above.<br />
<br />
<texcode><br />
\starttabulate[|r|c|l|] <br />
\NC test \NC {\colored[red] test} \NC test \NC\NR <br />
\NC test \NC {\colored[green] test} \NC test \NC\NR <br />
\NC test \NC {\colored[blue] test} \NC test \NC\NR <br />
\NC test \NC {\colored[cyan] test} \NC test \NC\NR <br />
\stoptabulate<br />
</texcode><br />
<br />
== Vertical Distance Between Rows ==<br />
<br />
<!--<br />
There does not seem to be an official interface for<br />
vertical skips.<br />
Manually placed <code>\blank</code>s are<br />
<code>\unskipped</code> on purpose.<br />
However, as expected there is a token list<br />
<code>\t_tabl_tabulate_every_after_row</code> that is<br />
placed after a line is finished.<br />
So, in order to get a vertical spacing of half a baseline<br />
distance you can use this code:<br />
<br />
<texcode><br />
\unprotect<br />
\appendtoks<br />
\blank[halfline]<br />
\to \t_tabl_tabulate_every_after_row<br />
\protect<br />
</texcode><br />
<br />
--><br />
<br />
<context mode=mkiv source=yes><br />
\starttabulate<br />
\NC one \NC two \NC\NR <br />
\NC two \NC three \NC\NR <br />
\TB[halfline]<br />
\NC four \NC five \NC\NR <br />
\TB[line]<br />
\NC four \NC five \NC\NR <br />
\TB[1cm]<br />
\NC eight \NC nine \NC\NR <br />
\stoptabulate<br />
</context><br />
<br />
=Using math mode=<br />
<br />
If you want to display numerics, you can simply use {{cmd|NN}} for a new column instead of {{cmd|NC}}. This command works similar to the [http://www.pragma-ade.nl/general/magazines/mag-0003.pdf digit-module]. Therefore you can also abbreviate:<br />
<br />
<texcode>\starttabulate[|l|l|]<br />
\HL<br />
\NN 10e-3 \NN 10e+3 \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
instead of<br />
<br />
<texcode><br />
\starttabulate[|l|l|]<br />
\HL<br />
\NC $10\cdot 10^{-3}$ \NC $10 \cdot 10^3$ \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
although both variants do work.<br />
<br />
If you always need math in one column, consider math mode columns:<br />
<br />
<texcode><br />
\starttabulate[|m|m|]<br />
\HL<br />
\NC 10e-3 \NC 10e+3 \NR<br />
\HL<br />
\stoptabulate<br />
</texcode><br />
<br />
<br />
=Itemization or framed objects inside a tabulation=<br />
<br />
The following issue is related to MkIV:<br />
<br />
When using an itemization inside a tabulation where one uses also the <br />
{{cmd|head}} command, there occurs a snapping problem. This is related to penalties which force a twoline split whereas the snapping mechanism prevents this. As a result two lines are typeset on top of each other. The solution is to add the following statement to the preamble:<br />
<texcode>\tabulatesplitlinemode \plustwo</texcode><br />
<br />
The following code provided by Wolfgang Schuster demonstrates the problem: Compile with and without the line <tt>\tabulatesplitlinemode\plustwo</tt><br />
<br />
<texcode><br />
\tabulatesplitlinemode \plustwo<br />
\starttabulate[|p|]<br />
\NC<br />
one \par<br />
\blank[penalty:10000]<br />
two \par<br />
\blank[penalty:10000]<br />
three<br />
\NC\NR<br />
\stoptabulate<br />
</texcode><br />
<br />
The same is true if you use {{cmd|framed}} or something that uses it internally, like [[Widgets]], within Tabulate.<br />
<br />
=Combining enumerations and tabulations=<br />
<br />
{{cmd|NI}} (new item) exists since 2017-09-25. {{cmd|itemtag}} is old, but undocumented. Source: http://source.contextgarden.net/tex/context/base/mkiv/strc-itm.mkvi?search=itemtag<br />
<br />
<context mode=mkiv source=yes><br />
\startitemize[n]<br />
\starttabulate[|||||]<br />
\NC p \NC \itemtag \NC q \NC r \NC \NR<br />
\NC p \NC \itemtag \NC q \NC r \NC \NR<br />
\NC p \NC \itemtag \NC q \NC r \NC \NR<br />
\NC p \NC \itemtag \NC q \NC r \NC \NR<br />
\stoptabulate<br />
\stopitemize<br />
</context><br />
<br />
<texcode><br />
\startitemize[n]<br />
\starttabulate[|||||]<br />
\NI x \NC y \NC z \NC \NR<br />
\NI x \NC y \NC z \NC \NR<br />
\NI x \NC y \NC z \NC \NR<br />
\NI x \NC y \NC z \NC \NR<br />
\stoptabulate<br />
\stopitemize<br />
<br />
\startitemize[n]<br />
\starttabulate[|||||]<br />
\NI b \NC c \NC d \NC \NR<br />
\NC a \NI c \NC d \NC \NR<br />
\NC a \NC b \NI d \NC \NR<br />
\NC a \NC b \NC c \NI \NR<br />
\stoptabulate<br />
\stopitemize<br />
</texcode><br />
<br />
=EQ option within table=<br />
<br />
EQ option defines text which will be placed by \EQ column separator.<br />
Source: https://www.mail-archive.com/ntg-context@ntg.nl/msg95207.html<br />
<br />
<context mode=mkiv source=yes><br />
\starttabulate[|l|r|r|][EQ={=}]<br />
\NC DC \EQ 3.20 bbl \EQ 420 ft \NC\NR<br />
\NC HWDP \EQ 3.90 bbl \EQ 450 ft \NC\NR<br />
\NC DP \EQ 34.63 bbl \EQ 2.037 ft \NC\NR<br />
\NC DC \EQ 41.73 bbl \EQ 2.907 ft \NC\NR<br />
\stoptabulate<br />
</context><br />
<br />
=See also=<br />
<br />
* More features are constantly added and documented in the {{src|tabl-tbl.mkiv|source}}.<br />
* {{cmd|starttabulate}}, {{cmd|setuptabulate}}, {{cmd|definetabulate}}<br />
* [[TABLE|Natural Tables]]<br />
* {{cmd|starttable}}, <s>{{cmd|setuptable}}</s><br />
<br />
[[Category:Tables]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Talk:Modules&diff=33914Talk:Modules2023-04-30T22:25:15Z<p>Zsd: </p>
<hr />
<div>== R module is unmantained ==<br />
<br />
It seems that R module is not maintained anymore because \usemodule[r] gives me <br />
<br />
modules > 'r' is not found<br />
<br />
[[User:Xan|Xan]] ([[User talk:Xan|talk]]) 21:04, 4 July 2021 (CEST)<br />
<br />
<br />
== Link to tlcontrib modules gives an Apache default page. ==</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Using_Graphics&diff=33907Using Graphics2023-04-15T23:10:16Z<p>Zsd: Spurious (for this markup) ~ (non-breakable space) removed. Two usages of subscripts which I assume were there in error removed.</p>
<hr />
<div>= Usage =<br />
<br />
The simplest way to insert an image is to use:<br />
<br />
<texcode>\externalfigure[logo.pdf]</texcode><br />
<br />
This command places the PDF image <tt>logo.pdf</tt> in a {{cmd|vbox}}; the width and height of the image are equal to the natural dimensions of the image.<br />
<br />
To set the width of the image to a specific size, say <tt>1cm</tt>, use:<br />
<br />
<texcode>\externalfigure[logo.pdf][width=1cm]</texcode><br />
<br />
Similarly, to set the height of the image to a specific size, say <tt>2cm</tt>, use:<br />
<br />
<texcode>\externalfigure[logo.pdf][height=2cm]</texcode><br />
<br />
If only the <tt>width</tt> or <tt>height</tt> of the image is specified, the other dimension is scaled appropriately to keep the aspect ratio.<br />
<br />
To include a specific page, say page 5, of a multi-page PDF file, use:<br />
<br />
<texcode>\externalfigure[logo.pdf][page=5]</texcode><br />
<br />
These four variations cover the most common use cases.<br />
<br />
== File Formats ==<br />
<br />
ConTeXt natively supports the image formats enumerated below. The image format is determined from the file extension (case insensitive).<br />
<br />
* '''PDF''': File extension <tt>.pdf</tt><br />
* '''MPS''' (MetaPost output): File extension <tt>.mps</tt> or <tt>.&lt;digits&gt;</tt><br />
* '''JPEG''': File extension <tt>.jpg</tt> or <tt>.jpeg</tt><br />
* '''PNG''': File extension <tt>.png</tt><br />
* '''JPEG 2000''': File extension <tt>.jp2</tt><br />
* '''JBIG''' or '''JBIG2''': File extension <tt>.jbig</tt>, <tt>.jbig2</tt>, or <tt>.jb2</tt><br />
<br />
An old page (2010), gives details on supported [[File Formats|file formats]]<br />
<br />
== Image Conversion ==<br />
<br />
The image file formats listed in the previous section are the ones that may be embedded directly in a PDF. ConTeXt also supports a few other formats that are first converted to PDF using an external program. Of course, for such a conversion to work, the corresponding converter must be in the <tt>PATH</tt>.<br />
<br />
<table><br />
<tr class="odd"><br />
<td align="left">Format</td><br />
<td align="left">Extension</td><br />
<td align="left">Converter</td><br />
</tr><br />
<tr class="even"><br />
<td align="left"><strong>SVG</strong></td><br />
<td align="left"><code>.svg</code>, <code>.svgz</code></td><br />
<td align="left"><code>inkscape</code></td><br />
</tr><br />
<tr class="odd"><br />
<td align="left"><strong>EPS</strong></td><br />
<td align="left"><code>.eps</code>, <code>.ai</code></td><br />
<td align="left"><code>gs</code> (or <code>gswin32c</code> on Windows) from Ghostscript</td><br />
</tr><br />
<tr class="even"><br />
<td align="left"><strong>GIF</strong></td><br />
<td align="left"><code>.gif</code></td><br />
<td align="left"><code>gm convert</code> from GraphicsMagick</td><br />
</tr><br />
<tr class="odd"><br />
<td align="left"><strong>TIFF</strong></td><br />
<td align="left"><code>.tiff</code></td><br />
<td align="left"><code>gm convert</code> from GraphicsMagick</td><br />
</tr><br />
<tr class="even"><br />
<td align="left"><strong>BMP</strong></td><br />
<td align="left"><code>.bmp</code></td><br />
<td align="left"><code>gm convert</code> from GraphicsMagick</td><br />
</tr><br />
</table><br />
<br />
The conversion generates a PDF file with prefix <tt>m_k_i_v_</tt> and a suffix <tt>.pdf</tt> added to the name of the original file. The result is cached, and the conversion is re-run if the timestamp of the original file is newer than that of the converted file.<br />
<br />
In LMTX, the file name contains a MD5 hash of the relevant source image parameters (resolution, dimensions, ...), e.g.:<br />
<br />
<pre><br />
hacker_jpg_c60ccda70ef92e32d7a6334f31c23259.gray.pdf <br />
</pre><br />
<br />
It is possible to change the converter used with the following code:<br />
<br />
<pre><br />
\startluacode<br />
local function downsampler(oldname, newname, resolution)<br />
if not resolution or resolution == "" then<br />
resolution = 50<br />
end<br />
os.execute(string.format(<br />
'gm convert -density %ix%i "%s" "%s"',<br />
resolution, resolution, oldname, newname)<br />
)<br />
end<br />
<br />
-- Set the PDF and default TIFF converters to the above function.<br />
figures.converters.tif.pdf = downsampler<br />
figures.converters.tif.default = downsampler<br />
-- Hint: This works also for jpg or png!<br />
\stopluacode<br />
<br />
\starttext<br />
% Substitute any TIFF here.<br />
\externalfigure[cow.tiff]<br />
\stoptext<br />
</pre><br />
<br />
See also {{src|grph-inc.lua}}<br />
<br />
== Interaction ==<br />
<br />
By default, the interactive elements of the included PDF file are discarded. To enable the interactive elements of the included PDF file, use<br />
<texcode>\externalfigure[filename.pdf][interaction=yes]</texcode><br />
<br />
For further reading, don't forget [[Including pages from PDF documents]].<br />
<br />
== Image Directory ==<br />
<br />
By default, ConTeXt searches an image in the current directory, the parent directory, and the grand-parent directory.<br />
<br />
To search for images in other directories, for example a <tt>./images</tt> subdirectory and <tt>/home/user/images</tt>, use:<br />
<br />
<texcode>\setupexternalfigures[directory={images, /home/user/images}]</texcode><br />
<br />
Note: always use forward slashes (`/`) in path names, regardless of operating system.<br />
<br />
The default search order is: the current directory, the parent directory, the grand-parent directory, and then the paths specified by the <tt>directory</tt> key. To restrict image search only to the paths specified by the <tt>directory</tt> key, use:<br />
<br />
<texcode>\setupexternalfigures[location=global]</texcode><br />
<br />
To restore the default search behavior, use:<br />
<br />
<texcode>\setupexternalfigures[location={local,global}]</texcode><br />
<br />
The ConTeXt distribution includes three sample images: <tt>cow.pdf</tt>, <tt>mill.png</tt>, and <tt>hacker.jpg</tt>, that are useful when creating minimum working examples to illustrate a bug on the mailing list. These images are locating in the <tt>TEXMF</tt> directory. To add the <tt>TEXMF</tt> directory to the image search path, use:<br />
<br />
<texcode>\setupexternalfigures[location={local,global,default}]</texcode><br />
<br />
The above alternative adds the ''entire'' <tt>TEXMF</tt> directory to the search path, ''including the'' <tt>doc/</tt> ''directory!'' Therefore, one needs to be extremely careful when using this option. In fact, I would advise not using <tt>location=default</tt> except for illustrative minimal working examples.<br />
<br />
== Remote Images ==<br />
<br />
The {{cmd|externalfigure}} command supports reading files from web servers, for example:<br />
<br />
<texcode>\externalfigure[http://tug.org/images/logobw.jpg]</texcode><br />
When a document containing a remote file is compiled for the first time, the remote file is downloaded from the server and stored in the LuaTeX cache directory. This cached file is used during subsequent runs.<br />
<br />
Normally, the remote image is downloaded again if the image in the cache is older than 1 day. To change this threshold to, for example, 2 minutes (120 seconds), either add<br />
<br />
<texcode>\enabledirectives[schemes.threshold=120]</texcode><br />
<br />
in the ConTeXt file, or compile the ConTeXt file using the command<br />
<br />
<pre>context --directives=schemes.threshold=120 <em>filename</em></pre><br />
The variable <tt>schemes.threshold</tt> is global, so changing its value affects all other macros like <tt>\input</tt>, <tt>\usemodule</tt>, <tt>\component</tt>, etc. that load remote files.<br />
<br />
=== HTTP Proxy ===<br />
<br />
To use an http proxy for fetching images, the http variable ([http://w3.impa.br/~diego/software/luasocket/http.html LuaSocket]) has to be set up as follows:<br />
<br />
<texcode><br />
\ctxlua{http = require("socket.http"); http.PROXY = "http://proxy.example.com:3128"}<br />
</texcode><br />
<br />
Replace `http://proxy.example.com:3128` with the proxy URL.<br />
<br />
To disable the proxy again:<br />
<br />
<texcode><br />
\ctxlua{http = require("socket.http"); http.PROXY = nil}<br />
</texcode><br />
<br />
=== HTTPS ===<br />
<br />
For self-signed certificates retrieved over HTTPS, the `curl` command requires a flag to retrieve insecure files, which is not enabled by default. Open `tex/texmf-context/tex/context/base/mkiv/data-sch.lua` to find:<br />
<br />
<pre><br />
local function runcurl(name,cachename) -- we use sockets instead or the curl library when possible<br />
local command = "curl --silent --create-dirs --output " .. cachename .. " " .. name<br />
os.spawn(command)<br />
end<br />
</pre><br />
<br />
Insert the `-k` or `--insecure` option:<br />
<br />
<pre><br />
local command = "curl --insecure --silent --create-dirs --output " .. cachename .. " " .. name<br />
</pre><br />
<br />
== Inline Images ==<br />
<br />
Embedding inline images via base64 encoding using the memstream function (supports pdf and png streams):<br />
<br />
<texcode><br />
\startluacode<br />
local cow = mime.unb64("JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURlY29kZT4+CnN0cmVhbQp4nJWayY40SW6E7/UUcRaQIafvfp6bAAkY9SM0oHXmMBAgvb7sM0ZmVf86CYNB/+HpC500Ghevv13ljqvwv+e/v//16+//eV3/+l9f8y4nRlz/8xVx99XW9Y9fcf2D/v8f+v+/a9q5/vSb/vnbn/7p629a+oq79L639jpjRKzcmC1fsUe927xaO3fRLwydsu/Q0C7afmj5Pv3WMb32+6zGgP61rz77Xdu4fv/KkWjXiHH3xpp12r3ONeq+W3QG1r7G6Pc8yyvmOHev19LBbXtFb/fo1zkan6GBqS3qFTWaBnLNLLfmRuvnPocpq96jXdFHu8/0ms4mMYaEP160usSMK9bUTZnS9l32VUurjGuC9LjWVWvM+1ky1t3qVZumxGZKPVftTb/zNbclraPW+/TnNkP31NAKycwh6+58Hx3C7cYJtqqzzHvkKT3qXXTKlGBoqOqnsr6/S5RbuqzzTKTRkmOl9s/Q68x1j6U9FvpfGqiyY2kMLG6nRbtqbkiWNePeUtIOWUE214AMer2WFLKbLrjWfNasVm5J+hl6zaLtuoTZq3PBga4O32PfVsHQLq3phrsvIVRThu2m7wnCXqPrWqhtozYviXPPxSblcOOu2+SmghFLescOEn3LEMvHdB0jIDKHW7Co3Xsh/T73lmgd3Pp6Sygx2LqwtiZa2fMWDr93WTJl0f16FYAWSpIBnzWyXGGKzIEs0l6UwYwC1L+lNVpmrnlv23/dtg8brOFKGH1JK8W+AwxCuKpy5RRuAFg2lpJ9RYEooqZRE3BjCkbrY+bXtJPo0nNvb7Kk0mBC6Q/elpwnNrIU3UwGOlJ/w+540QE8cpqGkScu40VngidwK2Bx0K64oFHarAYQsrxLDnASiDueM43KHtJL+CThSgNtYryei7Z113ST8Rl4Sc0iIXtH3JMB2fDYHXIPLanS4a55Z+lS311MhxKkZZirBmv4Xo+y8bGDKk0u0lMtIePF9yZx0KzPkQsnV22Jhubgn2LekQibg5YcUt+CdtTvCaxpwtHmhtAa++oebaADMd7afxiIe9jtQi4TFcXJndlX/6kVWUSjnQHEPzZHTbfbYEVcaKaBncCvDx44iClBbqcb9/1hK9Hn3IwcCEjHbs1kDzFOQddvLUGjy/fRPaRbiTa0jaR9tW7KrWOOdAfBeLPr0MyHEbSbd9F5gH9ItRWodHkdokGkC2rqeyC8Fs2FTRkS8rpIYWr/jTfgFpDCnFuIbvBxYGUWwUbBkNSCx4xVHM4+i0ZDk2gBJ7Oyu6TqrBG1jZ+XbiMJKypW1bdESsCBmUAJTYiA1hcUcCRtm9DgS9cYY7fPHhjoe6hZCz8Gwur/HpBEY+aFdHcu/Z6j7eaYnuOg8d+wp/jIwtRBeH5NQwGB8VGrV/7tXYgkNglqho/qGdIHBKWZU2hphSAgLQgSBwhW+VC3Sb6HdAOEkfHaAlKhoAbmZIhqSwdy+tZLTgsawNrCZeLxhxrJPgHZKHZX2eh90NsCcsYbiMG8lSnEPam7K/hsJQAVMkg/A0ob5T1DMr02IYxWcS9wEREKkwirGOIwOs5J943prEVrTiL1Le3YkID0hMOtmYwrW+sADaWTjI7XdAYWBw0RWCNrKMA8A1zl0ozIZxw1JQLyF4iRgxsRcDLQH9MP2WhgkUK+spCF0OuBINmR+LCPblgE7p12/QyRXiDM4WZKhI7IXonQi3RLg1fs7ZwGkIkuuzTidIdbi5G16GhA/tTwPQ7QnUVVmwEjc9/CWMAuwsSH/qPJNmV9ZxOhOC/LeI0i8tFVouoGJJBjO7PR91Ie+dFCKKPid8y6nODIBTep1qsXud5hC1ICydoKGcr5DBinOqazqAep5Us5ggZY1ADJzwEFhtGT1zYh4j3yYrvugedk1goJ+jZrkCQKc/oug4WKSwzsK8AXp76jRYSg2ZLXhS85t4YU3ZxBTxQrUcFO4A2H4KmBIkIf6Q31sVjBmbiOPH4pt5MrNeteCcI9OYg01Qc1CdVYo4zYa5rMNRTWNBCQ2asNu5/WOAtmzcbL1veUHoqWvgAIJ/VpBl7gsrX9TKjeQ59ULmCAY2TDAKhFFDPTGwZiMlR9x7+A25EQVLLrfcgY+u7fd1ziMmVGzBgPNsh1m9xXipk2K0lQIM1noKAY3aDIuiVxO1n0Gfl4VeBmeBnZS+VbN5rpiYg5WKNAsOGjxrYcLEehZhHpSFrO6QWvMIdxo8UQtQ45CAed713kgWI5D7QHhLHwBw5X5jRccCwHNHHNU9g8oDoKFlKpFz2QOWtYQxQUjvTnkMaxC7WV4H4WVUKWUI1soF1H+NiEcfmgFN+uLanGrt+8rDChTHX+zH82JEVaW2UUlSDXFpEG8iqA6/7nUpi4d0/HkmmLfjtks1iyKdsYislHaYFYg7SWf0gWREjTjnJcRIhoMTYIAU8C/abSgZIkZ9fRB7UKOSIgOayQvOU45AkEH2dh41pk1qQDR3joIonVSGLQTNEq3XYeIfwpx+p0QUoKd0hOok3HyC4CUDbyPVDt1/tRp3yGGCajU7O1SqC+iCNOFJ8lZAcrMplsSX6USyITm23fFA0CTq/OJilvyVGVPGdkDHQ1L0pHaB4jGc7mJvwmKMh0oeXc0qmkkrrAq6UDV+STeChIwdOZxA7X166Snvo6K24RGckTdTBoIReTxIalUwqyZzHReqgNkGmO/nOyOUDuRY7kRO7TYlDOKksmH9qa1IoC3fCi5naB6tR7U4r82pf4/evfvn67/vyVnYu4/vNLyYj8SXGHwHb9Vd9UHe9v0Tj/ieZaWl/Nc2dmzVXqI9qQqFaoC1IKUm5q+vS68DzwKmbwhuQkR5ae1G/PjsRbpKtUlAP2EKD0KwVUsiNJaEBoI6te54Em5MnpTRfvl4MyWbxKYZ2ylVs3q0rIovrcqtA2SlX9rUvi4Tm9CTT6JARi9iq9ff8qZNyQE9Agt6G9EUWZwcypCCRCFsGSCiFHKMYiP+Gjo6+cWahyVJwo4rErCwSn4i+5+SZjKHm7IGUAVOIp+a8kJOdoXEJ3nQk4ltTmg8V0NXXda/46PJdqRSuXOwMCV1wG8E6rWFY6DtQb1bqmV4A1f6IC1IgmO/petCOEE2VEyxJC/nvlmWFR9sCY8oJim8b2lkEuZa/wTUkNBbOzSYJqljpKzRYru3xTmudCCnsLvRaRMvJYSGbSmAJ7vlcZtsBGk6XZWqovfMs4y5qExDmdiJso4gu+JXZ15/X6fiztSetYGoLSRMEk/04SfKs1iu1+Tl623U5/+DfBLnY2QJTzeZdo3oWG1s5oWZ+ZxUUqOypTgcabYafimCsSLPw5FDWb+ToxqguC4S0wAGmpVyHuQip+D3qETcSM9WL41Elnx79VRJpS6WTn1hBg0XrLnWHmKQ6M3Iq6tl1kt9O5lo10qMzsW8+AfHjbWUU3uv2wsggYOoAmCjOLbBFv/qDq8q/SL2pIW9R9PHPY3s4e2efc/aO1IgeqbxsyN4wodw/e+xDgrZbnc8735SSndFwsvI5BafszuVqlD0v8/gUGUdFpSSQieBuD2Mt2Z6QK3dn19rDuFvBZb6R7W5numJyswGL/1dyRBONjpzMFLyNz0rxN4cIhLRWvBVKDZzxEtTaLe7X1tJcmfV909TTfe4RkzjPwpJNoSHFoNmuBCmN0TceoX+MRIiDWeRFbLWqnz6PJvZT3AH7casoaJL30xtrzScqbfObDRSiQzTTE63u1btDojrn/bBJbiCiLU7/Q2kGwUaq3fn4aTlJ8TnenOsgFprcdyhzTVHzsYqZWWptXmko2cMXEu1zX4DppdMXmkcSu4+wtazv6VAdCQgrdqNShPkfe7/l1mY4qxLZgbmV+eSZejd5oRFhvRBclRVKjN6IlHVd/TO23Ayw+aCf49wJpDwIqv+P15zKZIPMuw9NXedavRfzcfHJYhooPABdJO3jqGS5F3Fhljf42Yq5OtEVz8rT3s3czxHdO3SXj9zA5rjLfqh5W8YbR5Pb4vxRuzg5HPH1FEnTsnoHQ8SXIl59aOqvDeH/BTL2bmTsOEy3jzeoleeRkQEo4C0zre224eYYmSsbZk0HT9AjT8eUyOvA7At00Yf8h7P3+9S9/9/98GGrFma1vW6+fI5LTXcNWXFVX2nq/DJSn3So9FDof1dDNBubTsxXmyQ4PuTqtuyllZBf00HfzEHyptNOpPW0TIjG9VFKyTk/nx0nahJZK5dnB6a1LSjI6GkPTA42cuRJFskYRPUvVTnDh95ccUg5NvkH/XgcBxLK+G34UFxKq0QdSZeVHqINNJ102us4MDKRkAPt60WcO+Zuq4tdZWW7WSlVoxfRMiWlAZMtVgHMqW7cbZC/3NWhbySh5o1bynYoEvdYsFGbWDrAAjSD4xWqgwbHbj6epKlc4z3tX+CqVXoY2/oufwNKWqsby0QtXm05tx/MKdvyPyuvEYwNa5s0N35JPa1iQhwA6bm6uE915RJnih6e4VP0PTT1dcOqjQStAgKh+z/kFieR0nPQ84lE1heE5p2uuIMh0FzzimgVBTj9fvtzFKmRotK5T4qH19B/wFks8wo+flaTZNfVwv6sWaPHpntdEmps470Jxk8Ftb/ZyXws9BM3mtyOQWDgJ95sqP9G2lEZoMAJFMgZl11LzG5zSonuD7i8Kv5VOVCXFcEu10NxBCeDMVR/kDe1WOhQd98JIJt79PGXSYKL62RDDg7OepSJFmOdws/Xk5r4hSSBtpYU9s4Qr2pB9SCB9aTQ24DgKKd4dCF90yr4XbT+camiLAEHnrulfsueglfXa7qjDuTT8spVMqNFkMeH0ScsmErfxErDzhUB6hYnXu0s5UR3S8aJBKzy6y+AAifRDF4+Qw0GBqp+20qCRYD5umFxT6GCQ2oXbkq8TFPPuDVau6vcxYeDUzxCqIhiRSfKwDRiGlRh+3HmaMEmU70bYy4krb9S0jqcR1LJYBxXxWGm5AfZplX0UHk9f+A0QmabRnkoMNVupTPeaXkC/j/HZ+EVBuxHv+6RN3jC5grNEaBEYU5tIblqcbw4MvCK7ldtvI84ZD+2NF8lkby37Xphg8/gg3B7dsSdbUeQPpd2n0UfiPZtOEy0h+TLNJ+FXIuzjuhugoPLd/AcCHJCLaBaJVA9msrykmeI8et8nWfvNyVxlO4QcOmwXj+PFaH30sCgA3nHoGVr5bPV/20iHxza6Llwxu6kJBBUwFOrZYMtWNu8S3Z7e6LNmzrSfd7/WzSA9eG31nMGZV2t0vdxIWtlVUfVZ+xtFxQ9Ygqmp69mEp4V5POBXgYtexN4P2eYfU/CYS4dMAy3DjizcDaJ38+mZ4UU7m010Q/23HLTp5JyO2H7K9MNG/KH7FHYvHbdKdp+m63n5wHJk2BgNnlVIe5rkxRyMtwEcuk05QDTJPxGZ1krlbxCe6LHo4K0fc/bDmvRVzJK7Wwt06p7u09FBEqJR/hUOoiXQU/3LPrvdFb0g/5hPD7T64c39hbB0w0GTthO9BP5IhCAv/S+3NfNKlHrkedvKfYIo2ff0ozCdh95+wjt4liFTpQ5PvFDAgkwFcGOBh474QNlQIK3GS+Q2tPDDT/DUTMUda4Jhc9+/8Pb1dPsi46PiV5IOz2B2c23jTjUVyHZu2x6+cwAnNMgh3AKXIV3b1ppPRp/vfOrJrCD/SAfW81sHhA05N79V+894CrxidNZnUW5DfDatrkjKnE4OnX5sIqn7j08aI9STH6maGU/A31ZlUJk6Q/0lbXh3Ff/89b/apSg4ZW5kc3RyZWFtCmVuZG9iago2IDAgb2JqCjQzMjEKZW5kb2JqCjQgMCBvYmoKPDwvVHlwZS9QYWdlL01lZGlhQm94IFswIDAgMjc1IDIwMF0KL1BhcmVudCAzIDAgUgovUmVzb3VyY2VzPDwvUHJvY1NldFsvUERGXQovQ29sb3JTcGFjZSAxMCAwIFIKL0V4dEdTdGF0ZSAxMSAwIFIKPj4KL0NvbnRlbnRzIDUgMCBSCj4+CmVuZG9iagozIDAgb2JqCjw8IC9UeXBlIC9QYWdlcyAvS2lkcyBbCjQgMCBSCl0gL0NvdW50IDEKPj4KZW5kb2JqCjEgMCBvYmoKPDwvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMyAwIFIKPj4KZW5kb2JqCjcgMCBvYmoKPDwvVHlwZS9FeHRHU3RhdGUKL09QTSAxPj5lbmRvYmoKOSAwIG9iagpbL1NlcGFyYXRpb24KL0JsYWNrCi9EZXZpY2VDTVlLCjggMCBSXWVuZG9iagoxMCAwIG9iago8PC9SOQo5IDAgUj4+CmVuZG9iagoxMSAwIG9iago8PC9SNwo3IDAgUj4+CmVuZG9iago4IDAgb2JqCjw8L0ZpbHRlci9GbGF0ZURlY29kZQovRnVuY3Rpb25UeXBlIDQKL0RvbWFpblswCjFdCi9SYW5nZVswCjEKMAoxCjAKMQowCjFdL0xlbmd0aCAyOT4+c3RyZWFtCnicq04pLVAwUMgtzVFIrUjOUMDPNQQzawHfFRGFCmVuZHN0cmVhbQplbmRvYmoKMiAwIG9iago8PC9Qcm9kdWNlcihBRlBMIEdob3N0c2NyaXB0IDguNTIpCi9DcmVhdGlvbkRhdGUoRDoyMDA2MDUxNTEyMjA1OSkKL01vZERhdGUoRDoyMDA2MDUxNTEyMjA1OSkKL0NyZWF0b3IoQ29yZWxEUkFXISkKL1RpdGxlKENPVy5FUFMpPj5lbmRvYmoKeHJlZgowIDEyCjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwNDYzNiAwMDAwMCBuIAowMDAwMDA0OTg2IDAwMDAwIG4gCjAwMDAwMDQ1NzcgMDAwMDAgbiAKMDAwMDAwNDQyNiAwMDAwMCBuIAowMDAwMDAwMDE1IDAwMDAwIG4gCjAwMDAwMDQ0MDYgMDAwMDAgbiAKMDAwMDAwNDY4NCAwMDAwMCBuIAowMDAwMDA0ODM4IDAwMDAwIG4gCjAwMDAwMDQ3MjUgMDAwMDAgbiAKMDAwMDAwNDc3OCAwMDAwMCBuIAowMDAwMDA0ODA4IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgMTIgL1Jvb3QgMSAwIFIgL0luZm8gMiAwIFIKL0lEIFs8ODE0NjQ5NTc3Qzg3MTE1QzRDQzBDQjg0QkU3RTQ1MEY+PDgxNDY0OTU3N0M4NzExNUM0Q0MwQ0I4NEJFN0U0NTBGPl0KPj4Kc3RhcnR4cmVmCjUxMzMKJSVFT0YK")<br />
figures.setmemstream("inline",cow)<br />
context.externalfigure({"memstream:///inline"})<br />
\stopluacode<br />
</texcode><br />
<br />
== Custom Processing ==<br />
<br />
The following example changes the width of images based on file name extensions:<br />
<br />
<texcode><br />
\setupexternalfigures[<br />
location={local,global,default},<br />
width=\textwidth<br />
]<br />
\defineexternalfigure[svg][width=1cm]<br />
\defineexternalfigure[jpg][width=2cm]<br />
\defineexternalfigure[png][width=4cm]<br />
<br />
% Won't be applied because there's no process action.<br />
% Default (\textwidth) is used, as defined above.<br />
\defineexternalfigure[pdf][width=6cm]<br />
<br />
\starttexdefinition includegraphics #1<br />
\splitfilename{#1}<br />
<br />
\processaction[\splitofftype][<br />
jpg=>{\externalfigure[#1][jpg]},<br />
png=>{\externalfigure[#1][png]},<br />
svg=>{\externalfigure[#1][svg][conversion=mp]},<br />
default=>{\externalfigure[#1]},<br />
unknown=>{\externalfigure[#1]}<br />
]<br />
\stoptexdefinition<br />
<br />
\starttext<br />
\includegraphics{kitten.jpg}<br />
\includegraphics{mill.png}<br />
\includegraphics{cow.pdf}<br />
\includegraphics{tiger.svg}<br />
\stoptext<br />
</texcode><br />
<br />
It's also possible to use {{cmd|setfigureconversion}} to instruct ConTeXt to use MetaPost when rendering SVG files. Such as:<br />
<br />
<texcode><br />
\setfigureconversion[svg][mp]<br />
<br />
\starttext<br />
\externalfigure[kitten.jpg][width=2cm]<br />
\externalfigure[mill.png] [width=4cm]<br />
\externalfigure[cow.pdf] [width=6cm]<br />
\externalfigure[tiger.svg] [width=1cm]<br />
\stoptext<br />
</texcode><br />
<br />
= Transformations =<br />
<br />
== Image Scaling ==<br />
<br />
{{ note | If either <tt>width</tt> or <tt>height</tt> is specified, then the <tt>scale</tt> key has no effect. }}<br />
<br />
<br />
To scale an image use the <tt>scale</tt> key: <tt>scale=1000</tt> corresponds to the original dimensions of the image, <tt>scale=500</tt> scales the image to 50% of the original size, <tt>scale=1500</tt> scales the images to 150% of the original size, and so on. For example:<br />
<br />
<texcode>\externalfigure[logo.pdf][scale=500]</texcode><br />
<br />
scales the image to 50% of its size.<br />
<br />
Use <tt>\setupexternalfigures</tt> to set the scale of all images. For example, to scale all images to be twice their original size, use:<br />
<br />
<texcode>\setupexternalfigures[scale=2000]</texcode><br />
<br />
In addition, the <tt>xscale</tt> and <tt>yscale</tt> keys scale the image in only one dimension. For example:<br />
<br />
<texcode>\externalfigure[logo.pdf][xscale=500]<br />
\externalfigure[logo.pdf][yscale=500]</texcode><br />
<br />
Scaling changes the visible size of a picture, but not the data or file size. If you want to reduce your file size by decreasing image resolution, see [[Downsampling]].<br />
<br />
== Image Dimension Restriction ==<br />
<br />
ConTeXt can limit included images to particular dimensions. For example, to ensure that an included image is not more than <tt>0.2\textwidth</tt>:<br />
<br />
<texcode>\externalfigure[logo.pdf][maxwidth=0.2\textwidth]</texcode><br />
<br />
If <tt>maxwidth</tt> is specified and the width of the image is less than <tt>maxwidth</tt>, then the image is not scaled; if the width of the image is greater than <tt>maxwidth</tt>, then the width is restricted to <tt>maxwidth</tt> and the height is scaled appropriately to maintain the original aspect ratio.<br />
<br />
The option <tt>maxheight</tt> is analogous to <tt>maxwidth</tt>, for checking the height of the image.<br />
<br />
For example, to ensure that figures do not overflow the text~area, one may set:<br />
<br />
<texcode>\setupexternalfigures<br />
[maxwidth=\textwidth,<br />
maxheight=0.8\textheight]</texcode><br />
<br />
== Image Rotation ==<br />
<br />
Rotate included images by 90°, 180°, or 270° using the <tt>orientation</tt> key. For example:<br />
<br />
<texcode>\externalfigure[logo.pdf][orientation=90]</texcode><br />
<br />
To rotate by an arbitrary angle, use the {{cmd|rotate}} command. For example:<br />
<br />
<texcode>\rotate[rotation=45]{\externalfigure[logo.pdf]}</texcode><br />
<br />
== Image Mirroring ==<br />
<br />
To mirror (flip) an image, use the generic {{cmd|mirror}} command. For example, to mirror horizontally:<br />
<br />
<texcode>\mirror{\externalfigure[logo.pdf]}</texcode><br />
<br />
To mirror vertically, first rotate the image by 180° and then mirror it:<br />
<br />
<texcode>\mirror{\externalfigure[logo.pdf][orientation=180]}</texcode><br />
<br />
== Image Clipping ==<br />
<br />
Clip an image using the generic {{cmd|clip}} command. For example, to clip the original image to a <tt>1cm x 2cm</tt> rectangle at an offset of <tt>(3mm,5mm)</tt> from the top left corner:<br />
<br />
<texcode>\clip[width=1cm, height=2cm, hoffset=3mm, voffset=5mm]<br />
{\externalfigure[logo.pdf]}</texcode><br />
<br />
As another example, this cuts the image into a <tt>3x3</tt> pieces and then outputs the <tt>(2,2)</tt> piece:<br />
<br />
<texcode>\clip[nx=3,ny=3,x=2,y=2]<br />
{\externalfigure[logo.pdf]}</texcode><br />
<br />
<br />
In PDF files, it is possible to specify different size information in PDF headers MediaBox, TrimBox, CropBox, and ArtBox. To clip to one of these sizes, use<br />
<br />
<texcode>\externalfigure[logo.pdf][size=art]</texcode><br />
<br />
Other options are: `none` (detault), `media` for MediaBox, `crop` for CropBox, `trim` for TrimBox, and `art` for ArtBox.<br />
<br />
= Troubleshooting =<br />
<br />
This section describes various tips for discovering problems with embedded images.<br />
<br />
== Visualize Bounding Box ==<br />
<br />
If, for instance, the image is taking more space than expected, it can be useful to visualize the bounding box of the image. To do this:<br />
<br />
<texcode>\externalfigure[logo.pdf][frame=on]</texcode><br />
<br />
ConTeXt includes a Perl script <tt>pdftrimwhite</tt> that removes extra white space at the borders of a PDF file. To run this script:<br />
<br />
<pre>mtxrun --script pdftrimwhite [flags] input output</pre><br />
<br />
The most important flag is <tt>--offset=dimen</tt>, which keeps some extra space around the trimmed image.<br />
<br />
Similar functionality is provided by another Perl script, <tt>pdfcrop</tt>, that is included in most TeX distributions.<br />
<br />
== Diagnostic Tracking ==<br />
<br />
To get diagnostic information about image inclusion, enable the tracker <tt>graphics.locating</tt> by editing the ConTeXt file and adding:<br />
<br />
<texcode>\enabletrackers[graphics.locating]</texcode><br />
<br />
Alternatively, compile the ConTeXt file using:<br />
<br />
<texcode>context --trackers=graphics.locating filename</texcode><br />
<br />
The tracker writes diagnostics to the console. Suppose we use <tt>\externalfigure[somefile.pdf]</tt> and ConTeXt finds the file in the current search path; then the following information is printed on the console:<br />
<br />
<pre>graphics &gt; inclusion &gt; locations: local,global<br />
graphics &gt; inclusion &gt; path list: . .. ../..<br />
graphics &gt; inclusion &gt; strategy: forced format pdf<br />
graphics &gt; inclusion &gt; found: somefile.pdf -&gt; somefile.pdf<br />
graphics &gt; inclusion &gt; format natively supported by backend: pdf</pre><br />
If the file <tt>somefile.pdf</tt> is not found in the current search path, then the following information is printed on the console (even if the <tt>graphics.locating</tt> tracker is not set):<br />
<br />
<pre>graphics &gt; inclusion &gt; strategy: forced format pdf<br />
graphics &gt; inclusion &gt; not found: somefile.pdf<br />
graphics &gt; inclusion &gt; not found: ./somefile.pdf<br />
graphics &gt; inclusion &gt; not found: ../somefile.pdf<br />
graphics &gt; inclusion &gt; not found: ../../somefile.pdf<br />
graphics &gt; inclusion &gt; not found: images/somefile.pdf<br />
graphics &gt; inclusion &gt; not found: /home/user/images/somefile.pdf<br />
graphics &gt; inclusion &gt; format not supported: </pre><br />
and a placeholder gray box is put in the output:<br />
<br />
<context> </context><br />
<br />
Sometimes, one would rather use a placeholder image for an image that is yet to be made. In such cases, load the MP library <tt>dum</tt> via:<br />
<br />
<texcode>\useMPlibrary[dum]</texcode><br />
<br />
Then, whenever an image file is not found in the current search path, a random MetaPost image is shown in the output.<br />
<br />
<context> </context><br />
<br />
== Leading Paragraph ==<br />
<br />
Using {{cmd|externalfigure}}<tt>[...]</tt> at the beginning of a paragraph results in a line break after the image. This is because {{cmd|externalfigure}} is a {{cmd|vbox}} and when a {{cmd|vbox}} is encountered at (what appears to be) the beginning of a paragraph, it remains in vertical mode. To prevent this, add {{cmd|dontleavehmode}} before {{cmd|externalfigure}}, like this:<br />
<br />
<texcode>\dontleavehmode<br />
\externalfigure[...] ... first line ...</texcode><br />
<br />
= Multiple Image Settings =<br />
<br />
== Image Settings ==<br />
<br />
Suppose your document contains many side-by-side images, and you want all of these images to be of the same size. In addition, you want to control the size of all images by changing only one setup. To do this, you can use the {{cmd|defineexternalfigure}} macro, which defines a named collection of image settings. For example, to define a collection where the image width is <tt>3cm</tt>, use:<br />
<br />
<texcode>\defineexternalfigure[logo-settings]<br />
[width=3cm]</texcode><br />
<br />
And then to use these settings in an image, use:<br />
<br />
<texcode>\externalfigure[group.pdf][logo-settings]</texcode><br />
<br />
or, if you want to add or override settings, use:<br />
<br />
<texcode>\externalfigure[group.pdf][logo-settings]<br />
[height=2cm]</texcode><br />
<br />
== Image Labels ==<br />
<br />
Suppose your document contains an image at multiple locations; all of these images are to be of the same size, which is not necessarily the same as the natural size of the image. Furthermore, as before, you want to set the size of all the images by changing only one setup. Here, the macro to use is {{cmd|useexternalfigure}}, which defines a symbolic label for inserting an image plus settings. For example:<br />
<br />
<texcode>\useexternalfigure[mylogo]<br />
[logo.pdf][width=2cm]</texcode><br />
<br />
defines an image label <tt>mylogo</tt> that maps to the image file <tt>logo.pdf</tt> and sets its width to <tt>2cm</tt>. This image label may be used as a normal image filename:<br />
<br />
<texcode>\externalfigure[mylogo]</texcode><br />
<br />
<br />
= Movies =<br />
<br />
Movies aren't recognized automatically yet; they must be delcared verbosely:<br />
<br />
<texcode><br />
\externalfigure[demo.mov][label=demo,width=4cm,height=4cm,preview=yes]<br />
</texcode><br />
<br />
<tt>preview=yes</tt> shows the first image as preview.<br />
You find more about interactive Elements in [http://www.pragma-ade.nl/general/manuals/mwidget-s.pdf mwidget-s.pdf]<br />
<br />
Unfortunately, people who are fond of Linux cannot embed movies because the linux release of acroread doesn't support that. An alternative solution consists in launching your prefered player (MPlayer) from acroread:<br />
<br />
<texcode><br />
\defineprogram[dummy.mpeg][dummy.mpeg.sh]<br />
<br />
\starttext<br />
\goto{\externalfigure[dummy-preview][width=0.48\textwidth]}[program(dummy.mpeg{})]<br />
\stoptext<br />
</texcode><br />
<br />
The script dummy.mpeg.sh should contain:<br />
<pre><nowiki><br />
FILE=$(basename "$0"); mplayer -fs -zoom ${FILE/.sh/}<br />
</nowiki></pre><br />
<br />
<br />
[[Category:Graphics]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Talk:Improving_the_manuals&diff=33888Talk:Improving the manuals2023-03-30T00:21:05Z<p>Zsd: </p>
<hr />
<div>(1) The link to the mailing list is not useful.<br />
<br />
(2) The name of the page should really be "Translating the manuals" since that seems to be the contents of the page.</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Talk:Improving_the_manuals&diff=33887Talk:Improving the manuals2023-03-30T00:20:04Z<p>Zsd: Created page with "The link to the mailing list is not useful."</p>
<hr />
<div>The link to the mailing list is not useful.</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/nolist&diff=33886Command/nolist2023-03-29T22:00:11Z<p>Zsd: /* Description */</p>
<hr />
<div>{{Reference<br />
|name=nolist<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>nolist</syntax><br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\nolist<span class="first" >{...}</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">{...}</td><br />
<td><i>text</i> </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
If used inside a sectioning command, the argument will appear in the title, but not in the list of contents.<br />
<br />
NOTE: As mentioned in the mailing list (December 28, 2015) the \nolist command no longer exists.<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Lists|nolist]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Table&diff=23051Table2016-03-14T21:21:59Z<p>Zsd: fixed a type I just created</p>
<hr />
<div>< [[Tables Overview]] | [[Tabulate]] | [[Tables]] ><br />
<br />
This is ConTeXts oldest table module. It uses the same formatting as [[Tabulate]] (see [[Tables Overview]]).<br />
<br />
This mode is based on Michael Wichura's TaBlE package for PlainTeX. The official manual for it is commercial (about 40 USD), see [http://www.pctex.com/books.html PCTeX] -- but note that the TaBlE manual only talks about the original syntax, which does not use <cmd>NC</cmd>, <cmd>HL</cmd> cum suis.<br />
<br />
The only ConTeXt docs are in [[manual:ms-cb-en.pdf|ConTeXt - an excursion]]. There is also two introductory articles in tugboat [http://tug.org/TUGboat/Articles/tb28-3/tb90mahajan.pdf ConTeXt basics for users: Table macros] [http://www.tug.org/TUGboat/Articles/tb29-1/tb91mahajan.pdf Table macros II] by Aditya Mahajan (2007 and 2008).<br />
<br />
== Basic Commands ==<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
* You get vertical lines (rules), if you use <cmd>VL</cmd> instead of <cmd>NC</cmd>.<br />
* Better use <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd>, <cmd>LR</cmd> instead of <cmd>NR</cmd>.<br />
* You can also use <cmd>AR</cmd> instead of <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd> and <cmd>LR</cmd> (AR for automatic row).<br />
* You can leave out the <cmd>NC</cmd> before the "row" command, but not if you use <cmd>AR</cmd> in a last or single row (see example).<br />
* You can influence the table with <cmd>setuptables</cmd>.<br />
<br />
==Column Definition==<br />
<br />
The table is defined by the template enclosed in square brackets after <cmd>starttable</cmd>. The template has the form<br />
<tt>|keys for the first column|keys for the second column|...|keys for the last column|</tt>. Please note that each column is surrounded by <tt>|</tt> signs. These are necessary. The formatting keys for each column can be a choice of<br />
<br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|lp(.5\textwidth)|]<br />
\HL<br />
\NC \bf Key \VL \bf Meaning \SR<br />
\HL<br />
\NC \NC Primitive Keys \SR<br />
\HL<br />
\NC \type{a{tokens}}\VL Adds \type{tokens} {\em after} the column content\AR<br />
\NC \type{b{tokens}}\VL Adds \type{tokens} '''before''' the column content\AR<br />
\NC {\tt \backslash\{ } \VL Enclose the column in braces (grouping)\AR<br />
\NC \type{*{n}{keys}}\VL Equivalent to repeating the formatting keys \type{keys} \type{n} times\NC\LR<br />
\HL<br />
\NC \NC Positioning Keys\SR<br />
\HL<br />
\NC \type{\LeftGlue} \VL Specifies the left glue to be used before the column\AR<br />
\NC \type{\RightGlue} \VL Specifies the right glue to be used after the column\AR<br />
\NC \type{l} \VL left-aligned column\AR<br />
\NC \type{c} \VL centered column\AR<br />
\NC \type{r} \VL right-aligned column\AR<br />
\NC \type{p(width)} \VL Set each cell as a paragraph\AR<br />
\NC \type{s(width)} \VL Specify the inter-column width\AR<br />
\NC \type{w} \VL Set minimum column width\AR<br />
\NC \type{k} \VL Insert a kern both left and right of the column\AR<br />
\NC \type{i} \VL Add a kern to the left of the column\AR<br />
\NC \type{j} \VL Add a kern to the right of the column\LR<br />
\HL<br />
\NC \NC Numeric and Math Item Keys \SR<br />
\HL<br />
\NC \type{n} \VL Numeric item not in math mode\AR<br />
\NC \type{N} \VL Numeric item in math mode\AR<br />
\NC \type{m} \VL Each cell is in (inline) math mode. Equivalent to \type{b$ a$}\AR<br />
\NC \type{M} \VL Each cell is in display math mode. Equivalent to \type{\{b{$\displaystyle}a$}} \AR<br />
\NC \type{\m} \VL Equivalent to \type{l b{{}}m}\AR<br />
\NC \type{\M} \VL Equivalent to \type{l b{{}}M}\LR<br />
\HL<br />
\NC \NC Style Keys \SR<br />
\HL<br />
\NC \type{f\command} \VL Set font according to following \tex{command}\AR<br />
\NC \type{B} \VL Bold. Equivalent to \type{f\bf}\AR<br />
\NC \type{I} \VL Italic. Equivalent to \type{f\it}\AR<br />
\NC \type{S} \VL Slanted. Equivalent to \type{f\sl}\AR<br />
\NC \type{R} \VL Roman. Equivalent to \type{f\rm}\AR<br />
\NC \type{T} \VL Teletype. Equivalent to \type{f\tt}\AR<br />
\NC \type{C} \VL Color. Use it in combination with \backslash\{ (e.g. \backslash\{C\{red\} )\LR<br />
\HL<br />
\NC \NC Tabskip Keys \SR<br />
\HL<br />
\NC \type{s} \VL Set the tabskip to the right of this column and of all following columns up to the next \type{s} or \type{o} key\AR<br />
\NC \type{o} \VL Set the tabskip to the right of this column only\LR<br />
\HL<br />
\stoptable<br />
</context><br />
<br />
=== Column definition examples===<br />
; <code>|l|</code> : a left aligned column, as wide as necessary<br />
; <code>|lw(2cm)|</code> : a left aligned column of at least 2 cm width<br />
; <code>|p(2cm)|</code> : a centered(!) paragraph of 2 cm width<br />
; <code>|lp(.5\textwidth)|</code> : a left aligned paragraph of specified width<br />
; <code>|rp(.5\textwidth)|</code> : a right aligned paragraph of specified width<br />
; <code>|cp(.5\textwidth)|</code> : a center aligned paragraph of specified width<br />
; <code>|xp(.5\textwidth)|</code> : a justified paragraph of specified width<br />
; <code>...</code> : Please add more<br />
; <code>...</code> : <br />
<br />
{{todo|add more examples of column definitions}}<br />
<br />
==Column Spans==<br />
<br />
It's possible to create columnspans (i.e. cells that span more than one column) with the command <cmd>use{<i>N</i>}</cmd> where ''N'' is the number of columns spanned by the cell. It's often necessary to use <cmd>ReFormat[<i>new keys</i>]{}</cmd> to reformat this specific cell according to the ''new keys''.<br />
<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR % slightly shorted<br />
\HL<br />
\NC left text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR<br />
\HL<br />
\NC left text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
<br />
(<cmd>ReFormat</cmd> can be abbreviated <cmd>REF</cmd> for brevity.)<br />
== Row Spans==<br />
<br />
It's also possible to create rowspans (i.e. cells that span more than one row) with the command <cmd>Raise(<i>dimen</i>){<i>content</i>}</cmd> or <cmd>Lower(<i>dimen</i>){</i>content</i>}</cmd> that raise or lower ''content'' by ''dimen''.<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
(<cmd>Lower(.5\lineheight){a}</cmd> can be abbreviated <cmd>LOW{a}</cmd> for brevity.)<br />
<br />
An alternative means of spanning rows by a tall object makes use of a bit of TeX magic:<br />
<cmd>smash{tall object}</cmd>:<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
==Table as Floating Object==<br />
<br />
<texcode><br />
\placetable[here][tab:sample]{sample table}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
* See [[Floating Objects]] in general.<br />
* If you need information about <cmd>placetable</cmd> look after <cmd>placefloat</cmd> in the manual or texshow!<br />
* If you do not want a caption for your table, to get rid of it altogether you have to add "none" to settings and then leave the braces empty; if you only leave the braces empty, your table will still be numbered ("Table 1" etc.).<br />
<br />
<texcode><br />
\placetable[here,none][tab:sample]{}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
==Background Colors==<br />
<br />
Note: Adding color to tables using the `\CL` and `\BL` commands appears to be deprecated in MKIV; see: http://wiki.contextgarden.net/Tabulate<br />
<br />
A very nice application in table are background colors for rows/cells (a feature that doesn't work in [[Tabulate]]):<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><br />
</tr></table><br />
The commands work something like this: first, you say what background colour you want for the next row<br />
and then you typeset the row. Observe: the line with the colour-command and the row it is supposed<br />
to colour should end in the same command (i.e. both \SR, \LR, \FR, ...). If they don't, the background<br />
won't cover the whole cell.<br />
<br />
* <cmd>BL</cmd> makes a gray background: the optional argument tells BL how many cells it should color<br />
* <cmd>CL</cmd> makes a colored row<br />
<br />
==Fit Table Width==<br />
<br />
Hans posted a solution to the list for fitting a wide table (with paragraphs and vertical lines) to the page width. The key to his solution is the <code>.45\textwidth</code> settings when setting each cell as a paragraph.<br />
<br />
<texcode><br />
\SetTableToWidth{\textwidth}<br />
<br />
\starttable[|p(.45\textwidth)|p(.45\textwidth)|]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<!-- It makes no sense to typeset this here. --><br />
<br />
Since table module has been under [http://www.ntg.nl/pipermail/ntg-context/2010/055004.html reconstruction] this approach works only for MKII. In MKIV one can use <br />
<br />
<texcode><br />
\starttable[|l|l|][textwidth=max]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<br />
to change the width of the current table only.<br />
<br />
<code>\setuptables[textwidth=...]</code> will affect the behavior of every table.<br />
<br />
== Booktabs ==<br />
<br />
Latex has an excellent package called booktabs for typesetting tables. The main features of that package is that you can have top, mid, and bottom rules of different thickness. It is possible to achieve similar effects using tables. For example, to match the default settings of booktabs (Well almost, this gives a top and bottom rules of 0.09em while booktabs sets it to 0.08em).<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
[[Category:Tables]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Table&diff=23050Table2016-03-14T21:21:25Z<p>Zsd: Added description of 's' format key, which was used below without explanation.</p>
<hr />
<div>< [[Tables Overview]] | [[Tabulate]] | [[Tables]] ><br />
<br />
This is ConTeXts oldest table module. It uses the same formatting as [[Tabulate]] (see [[Tables Overview]]).<br />
<br />
This mode is based on Michael Wichura's TaBlE package for PlainTeX. The official manual for it is commercial (about 40 USD), see [http://www.pctex.com/books.html PCTeX] -- but note that the TaBlE manual only talks about the original syntax, which does not use <cmd>NC</cmd>, <cmd>HL</cmd> cum suis.<br />
<br />
The only ConTeXt docs are in [[manual:ms-cb-en.pdf|ConTeXt - an excursion]]. There is also two introductory articles in tugboat [http://tug.org/TUGboat/Articles/tb28-3/tb90mahajan.pdf ConTeXt basics for users: Table macros] [http://www.tug.org/TUGboat/Articles/tb29-1/tb91mahajan.pdf Table macros II] by Aditya Mahajan (2007 and 2008).<br />
<br />
== Basic Commands ==<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
* You get vertical lines (rules), if you use <cmd>VL</cmd> instead of <cmd>NC</cmd>.<br />
* Better use <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd>, <cmd>LR</cmd> instead of <cmd>NR</cmd>.<br />
* You can also use <cmd>AR</cmd> instead of <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd> and <cmd>LR</cmd> (AR for automatic row).<br />
* You can leave out the <cmd>NC</cmd> before the "row" command, but not if you use <cmd>AR</cmd> in a last or single row (see example).<br />
* You can influence the table with <cmd>setuptables</cmd>.<br />
<br />
==Column Definition==<br />
<br />
The table is defined by the template enclosed in square brackets after <cmd>starttable</cmd>. The template has the form<br />
<tt>|keys for the first column|keys for the second column|...|keys for the last column|</tt>. Please note that each column is surrounded by <tt>|</tt> signs. These are necessary. The formatting keys for each column can be a choice of<br />
<br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|lp(.5\textwidth)|]<br />
\HL<br />
\NC \bf Key \VL \bf Meaning \SR<br />
\HL<br />
\NC \NC Primitive Keys \SR<br />
\HL<br />
\NC \type{a{tokens}}\VL Adds \type{tokens} {\em after} the column content\AR<br />
\NC \type{b{tokens}}\VL Adds \type{tokens} '''before''' the column content\AR<br />
\NC {\tt \backslash\{ } \VL Enclose the column in braces (grouping)\AR<br />
\NC \type{*{n}{keys}}\VL Equivalent to repeating the formatting keys \type{keys} \type{n} times\NC\LR<br />
\HL<br />
\NC \NC Positioning Keys\SR<br />
\HL<br />
\NC \type{\LeftGlue} \VL Specifies the left glue to be used before the column\AR<br />
\NC \type{\RightGlue} \VL Specifies the right glue to be used after the column\AR<br />
\NC \type{l} \VL left-aligned column\AR<br />
\NC \type{c} \VL centered column\AR<br />
\NC \type{r} \VL right-aligned column\AR<br />
\NC \type{p(width)} \VL Set each cell as a paragraph\AR<br />
\NC \type{s(width)} \VL Specify the inter=column width\AR<br />
\NC \type{w} \VL Set minimum column width\AR<br />
\NC \type{k} \VL Insert a kern both left and right of the column\AR<br />
\NC \type{i} \VL Add a kern to the left of the column\AR<br />
\NC \type{j} \VL Add a kern to the right of the column\LR<br />
\HL<br />
\NC \NC Numeric and Math Item Keys \SR<br />
\HL<br />
\NC \type{n} \VL Numeric item not in math mode\AR<br />
\NC \type{N} \VL Numeric item in math mode\AR<br />
\NC \type{m} \VL Each cell is in (inline) math mode. Equivalent to \type{b$ a$}\AR<br />
\NC \type{M} \VL Each cell is in display math mode. Equivalent to \type{\{b{$\displaystyle}a$}} \AR<br />
\NC \type{\m} \VL Equivalent to \type{l b{{}}m}\AR<br />
\NC \type{\M} \VL Equivalent to \type{l b{{}}M}\LR<br />
\HL<br />
\NC \NC Style Keys \SR<br />
\HL<br />
\NC \type{f\command} \VL Set font according to following \tex{command}\AR<br />
\NC \type{B} \VL Bold. Equivalent to \type{f\bf}\AR<br />
\NC \type{I} \VL Italic. Equivalent to \type{f\it}\AR<br />
\NC \type{S} \VL Slanted. Equivalent to \type{f\sl}\AR<br />
\NC \type{R} \VL Roman. Equivalent to \type{f\rm}\AR<br />
\NC \type{T} \VL Teletype. Equivalent to \type{f\tt}\AR<br />
\NC \type{C} \VL Color. Use it in combination with \backslash\{ (e.g. \backslash\{C\{red\} )\LR<br />
\HL<br />
\NC \NC Tabskip Keys \SR<br />
\HL<br />
\NC \type{s} \VL Set the tabskip to the right of this column and of all following columns up to the next \type{s} or \type{o} key\AR<br />
\NC \type{o} \VL Set the tabskip to the right of this column only\LR<br />
\HL<br />
\stoptable<br />
</context><br />
<br />
=== Column definition examples===<br />
; <code>|l|</code> : a left aligned column, as wide as necessary<br />
; <code>|lw(2cm)|</code> : a left aligned column of at least 2 cm width<br />
; <code>|p(2cm)|</code> : a centered(!) paragraph of 2 cm width<br />
; <code>|lp(.5\textwidth)|</code> : a left aligned paragraph of specified width<br />
; <code>|rp(.5\textwidth)|</code> : a right aligned paragraph of specified width<br />
; <code>|cp(.5\textwidth)|</code> : a center aligned paragraph of specified width<br />
; <code>|xp(.5\textwidth)|</code> : a justified paragraph of specified width<br />
; <code>...</code> : Please add more<br />
; <code>...</code> : <br />
<br />
{{todo|add more examples of column definitions}}<br />
<br />
==Column Spans==<br />
<br />
It's possible to create columnspans (i.e. cells that span more than one column) with the command <cmd>use{<i>N</i>}</cmd> where ''N'' is the number of columns spanned by the cell. It's often necessary to use <cmd>ReFormat[<i>new keys</i>]{}</cmd> to reformat this specific cell according to the ''new keys''.<br />
<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR % slightly shorted<br />
\HL<br />
\NC left text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR<br />
\HL<br />
\NC left text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
<br />
(<cmd>ReFormat</cmd> can be abbreviated <cmd>REF</cmd> for brevity.)<br />
== Row Spans==<br />
<br />
It's also possible to create rowspans (i.e. cells that span more than one row) with the command <cmd>Raise(<i>dimen</i>){<i>content</i>}</cmd> or <cmd>Lower(<i>dimen</i>){</i>content</i>}</cmd> that raise or lower ''content'' by ''dimen''.<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
(<cmd>Lower(.5\lineheight){a}</cmd> can be abbreviated <cmd>LOW{a}</cmd> for brevity.)<br />
<br />
An alternative means of spanning rows by a tall object makes use of a bit of TeX magic:<br />
<cmd>smash{tall object}</cmd>:<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
==Table as Floating Object==<br />
<br />
<texcode><br />
\placetable[here][tab:sample]{sample table}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
* See [[Floating Objects]] in general.<br />
* If you need information about <cmd>placetable</cmd> look after <cmd>placefloat</cmd> in the manual or texshow!<br />
* If you do not want a caption for your table, to get rid of it altogether you have to add "none" to settings and then leave the braces empty; if you only leave the braces empty, your table will still be numbered ("Table 1" etc.).<br />
<br />
<texcode><br />
\placetable[here,none][tab:sample]{}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
==Background Colors==<br />
<br />
Note: Adding color to tables using the `\CL` and `\BL` commands appears to be deprecated in MKIV; see: http://wiki.contextgarden.net/Tabulate<br />
<br />
A very nice application in table are background colors for rows/cells (a feature that doesn't work in [[Tabulate]]):<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><br />
</tr></table><br />
The commands work something like this: first, you say what background colour you want for the next row<br />
and then you typeset the row. Observe: the line with the colour-command and the row it is supposed<br />
to colour should end in the same command (i.e. both \SR, \LR, \FR, ...). If they don't, the background<br />
won't cover the whole cell.<br />
<br />
* <cmd>BL</cmd> makes a gray background: the optional argument tells BL how many cells it should color<br />
* <cmd>CL</cmd> makes a colored row<br />
<br />
==Fit Table Width==<br />
<br />
Hans posted a solution to the list for fitting a wide table (with paragraphs and vertical lines) to the page width. The key to his solution is the <code>.45\textwidth</code> settings when setting each cell as a paragraph.<br />
<br />
<texcode><br />
\SetTableToWidth{\textwidth}<br />
<br />
\starttable[|p(.45\textwidth)|p(.45\textwidth)|]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<!-- It makes no sense to typeset this here. --><br />
<br />
Since table module has been under [http://www.ntg.nl/pipermail/ntg-context/2010/055004.html reconstruction] this approach works only for MKII. In MKIV one can use <br />
<br />
<texcode><br />
\starttable[|l|l|][textwidth=max]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<br />
to change the width of the current table only.<br />
<br />
<code>\setuptables[textwidth=...]</code> will affect the behavior of every table.<br />
<br />
== Booktabs ==<br />
<br />
Latex has an excellent package called booktabs for typesetting tables. The main features of that package is that you can have top, mid, and bottom rules of different thickness. It is possible to achieve similar effects using tables. For example, to match the default settings of booktabs (Well almost, this gives a top and bottom rules of 0.09em while booktabs sets it to 0.08em).<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
[[Category:Tables]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Table&diff=23049Table2016-03-14T21:14:02Z<p>Zsd: fixed a misspelling</p>
<hr />
<div>< [[Tables Overview]] | [[Tabulate]] | [[Tables]] ><br />
<br />
This is ConTeXts oldest table module. It uses the same formatting as [[Tabulate]] (see [[Tables Overview]]).<br />
<br />
This mode is based on Michael Wichura's TaBlE package for PlainTeX. The official manual for it is commercial (about 40 USD), see [http://www.pctex.com/books.html PCTeX] -- but note that the TaBlE manual only talks about the original syntax, which does not use <cmd>NC</cmd>, <cmd>HL</cmd> cum suis.<br />
<br />
The only ConTeXt docs are in [[manual:ms-cb-en.pdf|ConTeXt - an excursion]]. There is also two introductory articles in tugboat [http://tug.org/TUGboat/Articles/tb28-3/tb90mahajan.pdf ConTeXt basics for users: Table macros] [http://www.tug.org/TUGboat/Articles/tb29-1/tb91mahajan.pdf Table macros II] by Aditya Mahajan (2007 and 2008).<br />
<br />
== Basic Commands ==<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|l|]<br />
\HL<br />
\NC Command \VL Meaning \SR % or \NC\AR<br />
\HL<br />
\NC \tex{NC} \VL next column \AR<br />
\NC \tex{HL} \VL horizontal line \AR<br />
\NC \tex{VL} \VL vertical line \AR<br />
\NC \tex{NR} \VL next row \LR<br />
\HL<br />
\NC \tex{SR} \VL single row \AR<br />
\NC \tex{FR} \VL first row \AR<br />
\NC \tex{MR} \VL middle row \AR<br />
\NC \tex{LR} \VL last row \LR % or \NC\AR<br />
\HL<br />
\NC \tex{AR} \VL automatic row \SR % or \NC\AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
* You get vertical lines (rules), if you use <cmd>VL</cmd> instead of <cmd>NC</cmd>.<br />
* Better use <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd>, <cmd>LR</cmd> instead of <cmd>NR</cmd>.<br />
* You can also use <cmd>AR</cmd> instead of <cmd>SR</cmd>, <cmd>FR</cmd>, <cmd>MR</cmd> and <cmd>LR</cmd> (AR for automatic row).<br />
* You can leave out the <cmd>NC</cmd> before the "row" command, but not if you use <cmd>AR</cmd> in a last or single row (see example).<br />
* You can influence the table with <cmd>setuptables</cmd>.<br />
<br />
==Column Definition==<br />
<br />
The table is defined by the template enclosed in square brackets after <cmd>starttable</cmd>. The template has the form<br />
<tt>|keys for the first column|keys for the second column|...|keys for the last column|</tt>. Please note that each column is surrounded by <tt>|</tt> signs. These are necessary. The formatting keys for each column can be a choice of<br />
<br />
<context><br />
\switchtobodyfont[ss, 8pt]<br />
\starttable[|l|lp(.5\textwidth)|]<br />
\HL<br />
\NC \bf Key \VL \bf Meaning \SR<br />
\HL<br />
\NC \NC Primitive Keys \SR<br />
\HL<br />
\NC \type{a{tokens}}\VL Adds \type{tokens} {\em after} the column content\AR<br />
\NC \type{b{tokens}}\VL Adds \type{tokens} '''before''' the column content\AR<br />
\NC {\tt \backslash\{ } \VL Enclose the column in braces (grouping)\AR<br />
\NC \type{*{n}{keys}}\VL Equivalent to repeating the formatting keys \type{keys} \type{n} times\NC\LR<br />
\HL<br />
\NC \NC Positioning Keys\SR<br />
\HL<br />
\NC \type{\LeftGlue} \VL Specifies the left glue to be used before the column\AR<br />
\NC \type{\RightGlue} \VL Specifies the right glue to be used after the column\AR<br />
\NC \type{l} \VL left-aligned column\AR<br />
\NC \type{c} \VL centered column\AR<br />
\NC \type{r} \VL right-aligned column\AR<br />
\NC \type{p(width)} \VL Set each cell as a paragraph\AR<br />
\NC \type{w} \VL Set minimum column width\AR<br />
\NC \type{k} \VL Insert a kern both left and right of the column\AR<br />
\NC \type{i} \VL Add a kern to the left of the column\AR<br />
\NC \type{j} \VL Add a kern to the right of the column\LR<br />
\HL<br />
\NC \NC Numeric and Math Item Keys \SR<br />
\HL<br />
\NC \type{n} \VL Numeric item not in math mode\AR<br />
\NC \type{N} \VL Numeric item in math mode\AR<br />
\NC \type{m} \VL Each cell is in (inline) math mode. Equivalent to \type{b$ a$}\AR<br />
\NC \type{M} \VL Each cell is in display math mode. Equivalent to \type{\{b{$\displaystyle}a$}} \AR<br />
\NC \type{\m} \VL Equivalent to \type{l b{{}}m}\AR<br />
\NC \type{\M} \VL Equivalent to \type{l b{{}}M}\LR<br />
\HL<br />
\NC \NC Style Keys \SR<br />
\HL<br />
\NC \type{f\command} \VL Set font according to following \tex{command}\AR<br />
\NC \type{B} \VL Bold. Equivalent to \type{f\bf}\AR<br />
\NC \type{I} \VL Italic. Equivalent to \type{f\it}\AR<br />
\NC \type{S} \VL Slanted. Equivalent to \type{f\sl}\AR<br />
\NC \type{R} \VL Roman. Equivalent to \type{f\rm}\AR<br />
\NC \type{T} \VL Teletype. Equivalent to \type{f\tt}\AR<br />
\NC \type{C} \VL Color. Use it in combination with \backslash\{ (e.g. \backslash\{C\{red\} )\LR<br />
\HL<br />
\NC \NC Tabskip Keys \SR<br />
\HL<br />
\NC \type{s} \VL Set the tabskip to the right of this column and of all following columns up to the next \type{s} or \type{o} key\AR<br />
\NC \type{o} \VL Set the tabskip to the right of this column only\LR<br />
\HL<br />
\stoptable<br />
</context><br />
<br />
=== Column definition examples===<br />
; <code>|l|</code> : a left aligned column, as wide as necessary<br />
; <code>|lw(2cm)|</code> : a left aligned column of at least 2 cm width<br />
; <code>|p(2cm)|</code> : a centered(!) paragraph of 2 cm width<br />
; <code>|lp(.5\textwidth)|</code> : a left aligned paragraph of specified width<br />
; <code>|rp(.5\textwidth)|</code> : a right aligned paragraph of specified width<br />
; <code>|cp(.5\textwidth)|</code> : a center aligned paragraph of specified width<br />
; <code>|xp(.5\textwidth)|</code> : a justified paragraph of specified width<br />
; <code>...</code> : Please add more<br />
; <code>...</code> : <br />
<br />
{{todo|add more examples of column definitions}}<br />
<br />
==Column Spans==<br />
<br />
It's possible to create columnspans (i.e. cells that span more than one column) with the command <cmd>use{<i>N</i>}</cmd> where ''N'' is the number of columns spanned by the cell. It's often necessary to use <cmd>ReFormat[<i>new keys</i>]{}</cmd> to reformat this specific cell according to the ''new keys''.<br />
<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR % slightly shorted<br />
\HL<br />
\NC left text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\starttable[s(0pt)|ls(10pt)|rs(0pt)|]<br />
\HL<br />
\NC \use{2}\ReFormat[cB]{Spanning head} \SR<br />
\HL<br />
\NC \Use{2}[cB]{Spanning head} \SR<br />
\HL<br />
\NC left text \VL right column text \NC \AR<br />
\NC new row \VL new row \NC \AR<br />
\NC left text \VL \ReFormat[l]{reformatted} \NC \AR<br />
\HL<br />
\NC \use{2}Spanning entry \SR <br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
<br />
(<cmd>ReFormat</cmd> can be abbreviated <cmd>REF</cmd> for brevity.)<br />
== Row Spans==<br />
<br />
It's also possible to create rowspans (i.e. cells that span more than one row) with the command <cmd>Raise(<i>dimen</i>){<i>content</i>}</cmd> or <cmd>Lower(<i>dimen</i>){</i>content</i>}</cmd> that raise or lower ''content'' by ''dimen''.<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|c|c|]<br />
\HL<br />
\VL \Lower(.5\lineheight){a} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
(<cmd>Lower(.5\lineheight){a}</cmd> can be abbreviated <cmd>LOW{a}</cmd> for brevity.)<br />
<br />
An alternative means of spanning rows by a tall object makes use of a bit of TeX magic:<br />
<cmd>smash{tall object}</cmd>:<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\starttable[|M|c|]<br />
\HL<br />
\VL \VL a \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \smash{\sum_0^N} \VL b \VL \AR<br />
\DC \DL[1] \DR<br />
\VL \VL c \VL \AR<br />
\HL<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
<br />
==Table as Floating Object==<br />
<br />
<texcode><br />
\placetable[here][tab:sample]{sample table}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
* See [[Floating Objects]] in general.<br />
* If you need information about <cmd>placetable</cmd> look after <cmd>placefloat</cmd> in the manual or texshow!<br />
* If you do not want a caption for your table, to get rid of it altogether you have to add "none" to settings and then leave the braces empty; if you only leave the braces empty, your table will still be numbered ("Table 1" etc.).<br />
<br />
<texcode><br />
\placetable[here,none][tab:sample]{}{<br />
\starttable ...<br />
\stoptable<br />
}<br />
</texcode><br />
<br />
==Background Colors==<br />
<br />
Note: Adding color to tables using the `\CL` and `\BL` commands appears to be deprecated in MKIV; see: http://wiki.contextgarden.net/Tabulate<br />
<br />
A very nice application in table are background colors for rows/cells (a feature that doesn't work in [[Tabulate]]):<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setupcolors[state=start]<br />
\starttable[|l|l|]<br />
\HL<br />
\BL[1]\SR<br />
\NC Command \NC Meaning \NC\SR<br />
\HL<br />
\NC \tex{NC} \NC next column \NC\FR<br />
\NC \tex{NR} \NC next row \NC\LR<br />
\HL<br />
\CL[green]\SR<br />
\NC \tex{AR} \NC automatic row\NC\SR<br />
\HL<br />
\stoptable<br />
</context><br />
</td><br />
</tr></table><br />
The commands work something like this: first, you say what background colour you want for the next row<br />
and then you typeset the row. Observe: the line with the colour-command and the row it is supposed<br />
to colour should end in the same command (i.e. both \SR, \LR, \FR, ...). If they don't, the background<br />
won't cover the whole cell.<br />
<br />
* <cmd>BL</cmd> makes a gray background: the optional argument tells BL how many cells it should color<br />
* <cmd>CL</cmd> makes a colored row<br />
<br />
==Fit Table Width==<br />
<br />
Hans posted a solution to the list for fitting a wide table (with paragraphs and vertical lines) to the page width. The key to his solution is the <code>.45\textwidth</code> settings when setting each cell as a paragraph.<br />
<br />
<texcode><br />
\SetTableToWidth{\textwidth}<br />
<br />
\starttable[|p(.45\textwidth)|p(.45\textwidth)|]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<!-- It makes no sense to typeset this here. --><br />
<br />
Since table module has been under [http://www.ntg.nl/pipermail/ntg-context/2010/055004.html reconstruction] this approach works only for MKII. In MKIV one can use <br />
<br />
<texcode><br />
\starttable[|l|l|][textwidth=max]<br />
\HL<br />
\VL foo foo foo foo foo foo \VL bar bar bar bar bar bar \VL\AR<br />
\HL<br />
\stoptable<br />
</texcode><br />
<br />
to change the width of the current table only.<br />
<br />
<code>\setuptables[textwidth=...]</code> will affect the behavior of every table.<br />
<br />
== Booktabs ==<br />
<br />
Latex has an excellent package called booktabs for typesetting tables. The main features of that package is that you can have top, mid, and bottom rules of different thickness. It is possible to achieve similar effects using tables. For example, to match the default settings of booktabs (Well almost, this gives a top and bottom rules of 0.09em while booktabs sets it to 0.08em).<br />
<br />
<table cols="2"><tr valign="top"><td><br />
<texcode><br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\setuptables[rulethickness=0.03em]<br />
<br />
\starttable[s0|l|i2l|i2r|]<br />
\HL[3]<br />
\NC \Use2[c]{Item} \NC \NC \AR<br />
\DL[2] \DC \DR<br />
\NC Animal \NC Description \NC Price (\$) \NC \AR<br />
\HL[2]<br />
\NC Gnat \NC per gram \NC 13.65 \NC \AR<br />
\NC \NC each \NC 0.01 \NC \AR<br />
\NC Gnu \NC stuffed \NC 92.50 \NC \AR<br />
\NC Emu \NC stuffed \NC 33.33 \NC \AR<br />
\NC Armadillo \NC frozen \NC 8.99 \NC \AR<br />
\HL[3]<br />
\stoptable<br />
</context><br />
</td></tr></table><br />
[[Category:Tables]]</div>Zsdhttps://wiki.contextgarden.net/index.php?title=MkIV_Differences&diff=23048MkIV Differences2016-03-14T18:15:36Z<p>Zsd: make mkii capitalization even more consistent</p>
<hr />
<div>In [[Mark IV]], much has changed. Most of the changes are not noticeable at the source document level, but there are in fact a few important differences. This page attempts to list the intentional as well as the unavoidable incompatibilities between Mark IV and Mark II (but not bugs). <br />
<br />
= Command line =<br />
<br />
You start Mark IV with the '''context''' command, and Mark II with '''texexec'''. The two programs are not the same, and even though they have mostly the same command line, there are some differences. Mostly, this is because '''context''' is still lacking a number of options of texexec like for example --passon (those will probably be implemented at some point in the future), but it also parses the command line differently. You must remember to always give the full name of the options, and then the effects should be almost unnoticeable.<br />
<br />
= Parameter processing =<br />
<br />
Mark IV delegates an ever growing amount of the key-value processing to lua, and as a result you should always provide 'expanded' numbers in Mark IV:<br />
<br />
\setuplayout[width=\the\hsize] % not just \hsize<br />
\definetypeface [joke] [ss] [sans] [joke] [default] [rscale=0.9] % not just .9<br />
<br />
The underlying reason is that the scanning via lua does not have the special behaviour of TeX itself.<br />
<br />
= Paragraph formatting =<br />
<br />
Mark IV extends the <cmd>definefontfeature</cmd> to make full use of the lua opentype engine by adding <br />
'''mode=node''', and various opentype tags features that you want on or off. In the distribution, there is only one case of this:<br />
<br />
<texcode><br />
\definefontfeature<br />
[arabic]<br />
[mode=node,language=dflt,script=arab,ccmp=yes,<br />
init=yes,medi=yes,fina=yes,isol=yes,<br />
liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes,<br />
mark=yes,mkmk=yes,kern=yes,curs=yes]<br />
</texcode><br />
<br />
It should come as no surprise that such a '''mode=node''' generates different effects, but even with a traditional font setup there are incompatibilies unless you use tfm-only fonts, because the metric information of fonts used in Mark IV <br />
(afm, ttf, otf) are often subtly different from the tfm metrics used by Mark II.<br />
<br />
== Actual font usage ==<br />
<br />
If you have a font in both OpenType and traditional Type 1, then Mark IV will typically use one version and Mark II the other. There is no guarantee that both sets have the same metrics.<br />
<br />
This is related to open type fonts metrics not having the limitations of traditional tfm metrics (and the fact that internally luatex has some limitations removed)<br />
<br />
== Interword spacing ==<br />
<br />
TFM-based (Type 1) fonts, especially those generated by afmtotfm, tend to use heuristics to decide on the width of the interword space instead of looking at the actual value inside the font. In Mark IV, it is much more likely that the actual value from the font is used, because Mark IV prefers the actual AFM files over any existing TFM files. As this affects interword spacing, linebreaks in Mark IV can be quite different from the ones in Mark II.<br />
<br />
== Line spacing ==<br />
<br />
TFM-based fonts often have to round heights and depths to allow for restrictions in the TFM format. This affects individual glyphs but more importantly, it can change the value of '1ex'. This can affect line spacing, because ConTeXt by default uses the value '2.8ex' for the setting of \baselineskip.<br />
<br />
= Languages and Regimes =<br />
<br />
Mark IV needs your input to be in UTF-8. Legacy documents using 8bit encodings have to be converted to utf-8 before they are usable.<br />
<br />
Linebreaks can be different because full-blown UTF-8 hyphenation patterns are used.<br />
<br />
Even strange symbols can be directly used in your source code, your code may become more human readable. You can use this [[Symbols/utf8|handy utf-8 list]] or use program like [http://live.gnome.org/Gucharmap Gucharmap] or [http://utils.kde.org/projects/kcharselect/ kcharselect] for copy/pasting some characters. If you're using Linux, you can also use ~/.XCompose file.<br />
<br />
<br />
HH: regimes still work so unless something is broken other encodings also should work but going utf8 is definitely wise<br />
<br />
= Fonts and Typescripts =<br />
<br />
Typescripts in Mark IV never specify any encoding at all (Unicode is mandatory).<br />
<br />
= Metapost =<br />
<br />
All inline metapost code in your document is executed in a large continuous run.<br />
<br />
This means there are two things you have to watch out for:<br />
<br />
# You should load the MP packages you need in <cmd>startMPinclusions</cmd>..<cmd>stopMPinclusions</cmd>; not inside a graphic.<br />
# You have to make sure that you do not re-state equations that were already solved in a previous graphic.<br />
<br />
These are in fact the exact same rules that you have to adhere to in MkII if <cmd>runMPgraphicsfalse</cmd> is active.<br />
<br />
<br />
Another difference is the way text is handled in MkIV. In particular, color (<code>withcolor</code>)<br />
is not applied to metapost text. For example,<br />
<br />
<texcode><br />
draw thelabel(decimal i, (i, 0) scaled 1cm) withcolor red ;<br />
</texcode><br />
<br />
currently does <b>not</b> work in MkIV. However,<br />
<br />
<texcode><br />
label(textext("\color[red]"& decimal i), (i, 0) scaled 1cm) ;<br />
</texcode><br />
<br />
does work. This second solution works both in MkIV and in MkII.<br />
(Note that <code>\color[red]</code> can be abbreviated <code>\red</code>.)<br />
<br />
= Indices and sorting =<br />
<br />
Sort orders can be different because of changes to the sort order lists.<br />
<br />
= Images =<br />
<br />
The official way of placing image in in MkIV:<br />
<texcode><br />
\placefigure[middle,none]{}{...}<br />
</texcode><br />
<br />
The MkII way was<br />
<texcode><br />
\placefigure[middle]{none}{...}<br />
</texcode><br />
<br />
= Logos =<br />
<br />
The logo commands (<cmd>definelogo</cmd> c.s.) do not exist in MkIV; use layers instead.<br />
<br />
= Itemizations =<br />
<br />
''Bare'' <cmd>item</cmd> paragraphs (without enclosing list) are not allowed.<br />
<br />
= Nomarking/Select =<br />
<br />
<cmd>nomarking</cmd> is currently broken and will likely be removed from MkIV; use <cmd>select</cmd> instead:<br />
<br />
<texcode><br />
\defineselector [caption] [max=2,n=2] % alternate {short}{long} caption<br />
<br />
\starttext<br />
<br />
\placefigure<br />
{\select{caption}<br />
{A cow}<br />
{This image represents a typical black and white milk cow.<br />
In many regions of the world, cows may look quite different.}<br />
}<br />
{\externalfigure[cow]}<br />
<br />
\setupselector [caption] [n=1]<br />
\completelistoffigures<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
= Table of Contents =<br />
<br />
If you want to modify [[Table of Contents|TOC]] you may find that <code>level</code> parameter has recently(02/2010) and probably for ever no effect in [[Mark IV]]. You may use {{cmd|placelist}}[chapter,section] instead of {{cmd|setupcombinedlist}}[content][level=2].<br />
<br />
= Grid typesetting =<br />
<br />
The implementation in MkIV is completely new, and various details have changed. The most important difference seems to be that the new grid by default is less tolerant for superscripts, but it can be made so by using {{cmd|setuplayout}}[grid=tolerant].<br />
<br />
= External figures =<br />
<br />
There was a change in the default path search for external figures, but I don't know the exact details off-hand.<br />
IIRC, the main problem is that texmf tree images are now found before local images. To change this ordering,<br />
use the <tt>location</tt> key to <cmd>setupexternalfigures</cmd>:<br />
<br />
<texcode><br />
\setupexternalfigures[location={local,global,default}]<br />
</texcode><br />
<br />
<tt>local</tt>: current directory + <tt>..</tt> + <tt>../..</tt><br />
<br />
<tt>global</tt>: paths set with <tt>directory=...</tt><br />
<br />
<tt>default</tt>: texmf tree<br />
<br />
= Frames =<br />
<br />
The macro <tt>\setuplocalframed</tt> is no longer defined in Mark IV (08.2010).<br />
You can use the <tt>\getparameters</tt> macro as adequate substitute.<br />
<br />
= Trialtypesetting =<br />
<br />
The macros for (de)activating trial typesetting (<tt>\trialtypesettingtrue</tt> and <tt>\trialtypesettingfalse</tt>) have been changed. They are no longer part of a <tt>\newif</tt> statement. The new names are <texcode>\settrialtypesetting</texcode> for activation and <texcode>\resettrialtypesetting</texcode> for deactivation.<br />
<br />
= Programming internals =<br />
<br />
== <tt>read*file</tt><br />
<br />
Commands like <tt>\readlocfile</tt> no longer default to a <tt>.tex</tt> extension, explicit file extensions are now required.<br />
<br />
= Sectioning =<br />
<br />
In MkIV, after <tt>\setuphead[section][placehead=no]</tt> there may still be some output on the page, because MkIV stores the reference target(s) to the section in an invisible box on the current page. Use <tt>\setuphead[section][placehead=hidden]</tt> if that interferes with the rest of your typesetting.</div>Zsdhttps://wiki.contextgarden.net/index.php?title=MkIV_Differences&diff=23047MkIV Differences2016-03-14T18:14:05Z<p>Zsd: make capitalization of MkIV and MkII more consistent</p>
<hr />
<div>In [[Mark IV]], much has changed. Most of the changes are not noticeable at the source document level, but there are in fact a few important differences. This page attempts to list the intentional as well as the unavoidable incompatibilities between Mark IV and Mark II (but not bugs). <br />
<br />
= Command line =<br />
<br />
You start Mark IV with the '''context''' command, and Mark II with '''texexec'''. The two programs are not the same, and even though they have mostly the same command line, there are some differences. Mostly, this is because '''context''' is still lacking a number of options of texexec like for example --passon (those will probably be implemented at some point in the future), but it also parses the command line differently. You must remember to always give the full name of the options, and then the effects should be almost unnoticeable.<br />
<br />
= Parameter processing =<br />
<br />
Mark IV delegates an ever growing amount of the key-value processing to lua, and as a result you should always provide 'expanded' numbers in Mark IV:<br />
<br />
\setuplayout[width=\the\hsize] % not just \hsize<br />
\definetypeface [joke] [ss] [sans] [joke] [default] [rscale=0.9] % not just .9<br />
<br />
The underlying reason is that the scanning via lua does not have the special behaviour of TeX itself.<br />
<br />
= Paragraph formatting =<br />
<br />
Mark IV extends the <cmd>definefontfeature</cmd> to make full use of the lua opentype engine by adding <br />
'''mode=node''', and various opentype tags features that you want on or off. In the distribution, there is only one case of this:<br />
<br />
<texcode><br />
\definefontfeature<br />
[arabic]<br />
[mode=node,language=dflt,script=arab,ccmp=yes,<br />
init=yes,medi=yes,fina=yes,isol=yes,<br />
liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes,<br />
mark=yes,mkmk=yes,kern=yes,curs=yes]<br />
</texcode><br />
<br />
It should come as no surprise that such a '''mode=node''' generates different effects, but even with a traditional font setup there are incompatibilies unless you use tfm-only fonts, because the metric information of fonts used in Mark IV <br />
(afm, ttf, otf) are often subtly different from the tfm metrics used by Mark II.<br />
<br />
== Actual font usage ==<br />
<br />
If you have a font in both OpenType and traditional Type 1, then Mark IV will typically use one version and Mark II the other. There is no guarantee that both sets have the same metrics.<br />
<br />
This is related to open type fonts metrics not having the limitations of traditional tfm metrics (and the fact that internally luatex has some limitations removed)<br />
<br />
== Interword spacing ==<br />
<br />
TFM-based (Type 1) fonts, especially those generated by afmtotfm, tend to use heuristics to decide on the width of the interword space instead of looking at the actual value inside the font. In Mark IV, it is much more likely that the actual value from the font is used, because Mark IV prefers the actual AFM files over any existing TFM files. As this affects interword spacing, linebreaks in Mark IV can be quite different from the ones in Mark II.<br />
<br />
== Line spacing ==<br />
<br />
TFM-based fonts often have to round heights and depths to allow for restrictions in the TFM format. This affects individual glyphs but more importantly, it can change the value of '1ex'. This can affect line spacing, because ConTeXt by default uses the value '2.8ex' for the setting of \baselineskip.<br />
<br />
= Languages and Regimes =<br />
<br />
Mark IV needs your input to be in UTF-8. Legacy documents using 8bit encodings have to be converted to utf-8 before they are usable.<br />
<br />
Linebreaks can be different because full-blown UTF-8 hyphenation patterns are used.<br />
<br />
Even strange symbols can be directly used in your source code, your code may become more human readable. You can use this [[Symbols/utf8|handy utf-8 list]] or use program like [http://live.gnome.org/Gucharmap Gucharmap] or [http://utils.kde.org/projects/kcharselect/ kcharselect] for copy/pasting some characters. If you're using Linux, you can also use ~/.XCompose file.<br />
<br />
<br />
HH: regimes still work so unless something is broken other encodings also should work but going utf8 is definitely wise<br />
<br />
= Fonts and Typescripts =<br />
<br />
Typescripts in Mark IV never specify any encoding at all (Unicode is mandatory).<br />
<br />
= Metapost =<br />
<br />
All inline metapost code in your document is executed in a large continuous run.<br />
<br />
This means there are two things you have to watch out for:<br />
<br />
# You should load the MP packages you need in <cmd>startMPinclusions</cmd>..<cmd>stopMPinclusions</cmd>; not inside a graphic.<br />
# You have to make sure that you do not re-state equations that were already solved in a previous graphic.<br />
<br />
These are in fact the exact same rules that you have to adhere to in mkii if <cmd>runMPgraphicsfalse</cmd> is active.<br />
<br />
<br />
Another difference is the way text is handled in MkIV. In particular, color (<code>withcolor</code>)<br />
is not applied to metapost text. For example,<br />
<br />
<texcode><br />
draw thelabel(decimal i, (i, 0) scaled 1cm) withcolor red ;<br />
</texcode><br />
<br />
currently does <b>not</b> work in MkIV. However,<br />
<br />
<texcode><br />
label(textext("\color[red]"& decimal i), (i, 0) scaled 1cm) ;<br />
</texcode><br />
<br />
does work. This second solution works both in MkIV and in MkII.<br />
(Note that <code>\color[red]</code> can be abbreviated <code>\red</code>.)<br />
<br />
= Indices and sorting =<br />
<br />
Sort orders can be different because of changes to the sort order lists.<br />
<br />
= Images =<br />
<br />
The official way of placing image in in MkIV:<br />
<texcode><br />
\placefigure[middle,none]{}{...}<br />
</texcode><br />
<br />
mkii way was<br />
<texcode><br />
\placefigure[middle]{none}{...}<br />
</texcode><br />
<br />
= Logos =<br />
<br />
The logo commands (<cmd>definelogo</cmd> c.s.) do not exist in MkIV; use layers instead.<br />
<br />
= Itemizations =<br />
<br />
''Bare'' <cmd>item</cmd> paragraphs (without enclosing list) are not allowed.<br />
<br />
= Nomarking/Select =<br />
<br />
<cmd>nomarking</cmd> is currently broken and will likely be removed from MkIV; use <cmd>select</cmd> instead:<br />
<br />
<texcode><br />
\defineselector [caption] [max=2,n=2] % alternate {short}{long} caption<br />
<br />
\starttext<br />
<br />
\placefigure<br />
{\select{caption}<br />
{A cow}<br />
{This image represents a typical black and white milk cow.<br />
In many regions of the world, cows may look quite different.}<br />
}<br />
{\externalfigure[cow]}<br />
<br />
\setupselector [caption] [n=1]<br />
\completelistoffigures<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
= Table of Contents =<br />
<br />
If you want to modify [[Table of Contents|TOC]] you may find that <code>level</code> parameter has recently(02/2010) and probably for ever no effect in [[Mark IV]]. You may use {{cmd|placelist}}[chapter,section] instead of {{cmd|setupcombinedlist}}[content][level=2].<br />
<br />
= Grid typesetting =<br />
<br />
The implementation in MkIV is completely new, and various details have changed. The most important difference seems to be that the new grid by default is less tolerant for superscripts, but it can be made so by using {{cmd|setuplayout}}[grid=tolerant].<br />
<br />
= External figures =<br />
<br />
There was a change in the default path search for external figures, but I don't know the exact details off-hand.<br />
IIRC, the main problem is that texmf tree images are now found before local images. To change this ordering,<br />
use the <tt>location</tt> key to <cmd>setupexternalfigures</cmd>:<br />
<br />
<texcode><br />
\setupexternalfigures[location={local,global,default}]<br />
</texcode><br />
<br />
<tt>local</tt>: current directory + <tt>..</tt> + <tt>../..</tt><br />
<br />
<tt>global</tt>: paths set with <tt>directory=...</tt><br />
<br />
<tt>default</tt>: texmf tree<br />
<br />
= Frames =<br />
<br />
The macro <tt>\setuplocalframed</tt> is no longer defined in Mark IV (08.2010).<br />
You can use the <tt>\getparameters</tt> macro as adequate substitute.<br />
<br />
= Trialtypesetting =<br />
<br />
The macros for (de)activating trial typesetting (<tt>\trialtypesettingtrue</tt> and <tt>\trialtypesettingfalse</tt>) have been changed. They are no longer part of a <tt>\newif</tt> statement. The new names are <texcode>\settrialtypesetting</texcode> for activation and <texcode>\resettrialtypesetting</texcode> for deactivation.<br />
<br />
= Programming internals =<br />
<br />
== <tt>read*file</tt><br />
<br />
Commands like <tt>\readlocfile</tt> no longer default to a <tt>.tex</tt> extension, explicit file extensions are now required.<br />
<br />
= Sectioning =<br />
<br />
In MkIV, after <tt>\setuphead[section][placehead=no]</tt> there may still be some output on the page, because MkIV stores the reference target(s) to the section in an invisible box on the current page. Use <tt>\setuphead[section][placehead=hidden]</tt> if that interferes with the rest of your typesetting.</div>Zsdhttps://wiki.contextgarden.net/index.php?title=MkIV_Differences&diff=23046MkIV Differences2016-03-14T18:10:04Z<p>Zsd: </p>
<hr />
<div>In [[Mark IV]], much has changed. Most of the changes are not noticeable at the source document level, but there are in fact a few important differences. This page attempts to list the intentional as well as the unavoidable incompatibilities between Mark IV and Mark II (but not bugs). <br />
<br />
= Command line =<br />
<br />
You start Mark IV with the '''context''' command, and Mark II with '''texexec'''. The two programs are not the same, and even though they have mostly the same command line, there are some differences. Mostly, this is because '''context''' is still lacking a number of options of texexec like for example --passon (those will probably be implemented at some point in the future), but it also parses the command line differently. You must remember to always give the full name of the options, and then the effects should be almost unnoticeable.<br />
<br />
= Parameter processing =<br />
<br />
Mark IV delegates an ever growing amount of the key-value processing to lua, and as a result you should always provide 'expanded' numbers in Mark IV:<br />
<br />
\setuplayout[width=\the\hsize] % not just \hsize<br />
\definetypeface [joke] [ss] [sans] [joke] [default] [rscale=0.9] % not just .9<br />
<br />
The underlying reason is that the scanning via lua does not have the special behaviour of TeX itself.<br />
<br />
= Paragraph formatting =<br />
<br />
Mark IV extends the <cmd>definefontfeature</cmd> to make full use of the lua opentype engine by adding <br />
'''mode=node''', and various opentype tags features that you want on or off. In the distribution, there is only one case of this:<br />
<br />
<texcode><br />
\definefontfeature<br />
[arabic]<br />
[mode=node,language=dflt,script=arab,ccmp=yes,<br />
init=yes,medi=yes,fina=yes,isol=yes,<br />
liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes,<br />
mark=yes,mkmk=yes,kern=yes,curs=yes]<br />
</texcode><br />
<br />
It should come as no surprise that such a '''mode=node''' generates different effects, but even with a traditional font setup there are incompatibilies unless you use tfm-only fonts, because the metric information of fonts used in Mark IV <br />
(afm, ttf, otf) are often subtly different from the tfm metrics used by Mark II.<br />
<br />
== Actual font usage ==<br />
<br />
If you have a font in both OpenType and traditional Type 1, then Mark IV will typically use one version and Mark II the other. There is no guarantee that both sets have the same metrics.<br />
<br />
This is related to open type fonts metrics not having the limitations of traditional tfm metrics (and the fact that internally luatex has some limitations removed)<br />
<br />
== Interword spacing ==<br />
<br />
TFM-based (Type 1) fonts, especially those generated by afmtotfm, tend to use heuristics to decide on the width of the interword space instead of looking at the actual value inside the font. In Mark IV, it is much more likely that the actual value from the font is used, because Mark IV prefers the actual AFM files over any existing TFM files. As this affects interword spacing, linebreaks in Mark IV can be quite different from the ones in Mark II.<br />
<br />
== Line spacing ==<br />
<br />
TFM-based fonts often have to round heights and depths to allow for restrictions in the TFM format. This affects individual glyphs but more importantly, it can change the value of '1ex'. This can affect line spacing, because ConTeXt by default uses the value '2.8ex' for the setting of \baselineskip.<br />
<br />
= Languages and Regimes =<br />
<br />
Mark IV needs your input to be in UTF-8. Legacy documents using 8bit encodings have to be converted to utf-8 before they are usable.<br />
<br />
Linebreaks can be different because full-blown UTF-8 hyphenation patterns are used.<br />
<br />
Even strange symbols can be directly used in your source code, your code may become more human readable. You can use this [[Symbols/utf8|handy utf-8 list]] or use program like [http://live.gnome.org/Gucharmap Gucharmap] or [http://utils.kde.org/projects/kcharselect/ kcharselect] for copy/pasting some characters. If you're using Linux, you can also use ~/.XCompose file.<br />
<br />
<br />
HH: regimes still work so unless something is broken other encodings also should work but going utf8 is definitely wise<br />
<br />
= Fonts and Typescripts =<br />
<br />
Typescripts in Mark IV never specify any encoding at all (Unicode is mandatory).<br />
<br />
= Metapost =<br />
<br />
All inline metapost code in your document is executed in a large continuous run.<br />
<br />
This means there are two things you have to watch out for:<br />
<br />
# You should load the MP packages you need in <cmd>startMPinclusions</cmd>..<cmd>stopMPinclusions</cmd>; not inside a graphic.<br />
# You have to make sure that you do not re-state equations that were already solved in a previous graphic.<br />
<br />
These are in fact the exact same rules that you have to adhere to in mkii if <cmd>runMPgraphicsfalse</cmd> is active.<br />
<br />
<br />
Another difference is the way text is handled in mkiv. In particular, color (<code>withcolor</code>)<br />
is not applied to metapost text. For example,<br />
<br />
<texcode><br />
draw thelabel(decimal i, (i, 0) scaled 1cm) withcolor red ;<br />
</texcode><br />
<br />
currently does <b>not</b> work in mkiv. However,<br />
<br />
<texcode><br />
label(textext("\color[red]"& decimal i), (i, 0) scaled 1cm) ;<br />
</texcode><br />
<br />
does work. This second solution works both in mkiv and in mkii.<br />
(Note that <code>\color[red]</code> can be abbreviated <code>\red</code>.)<br />
<br />
= Indices and sorting =<br />
<br />
Sort orders can be different because of changes to the sort order lists.<br />
<br />
= Images =<br />
<br />
The official way of placing image in in mkiv:<br />
<texcode><br />
\placefigure[middle,none]{}{...}<br />
</texcode><br />
<br />
mkii way was<br />
<texcode><br />
\placefigure[middle]{none}{...}<br />
</texcode><br />
<br />
= Logos =<br />
<br />
The logo commands (<cmd>definelogo</cmd> c.s.) do not exist in mkiv; use layers instead.<br />
<br />
= Itemizations =<br />
<br />
''Bare'' <cmd>item</cmd> paragraphs (without enclosing list) are not allowed.<br />
<br />
= Nomarking/Select =<br />
<br />
<cmd>nomarking</cmd> is currently broken and will likely be removed from mkiv; use <cmd>select</cmd> instead:<br />
<br />
<texcode><br />
\defineselector [caption] [max=2,n=2] % alternate {short}{long} caption<br />
<br />
\starttext<br />
<br />
\placefigure<br />
{\select{caption}<br />
{A cow}<br />
{This image represents a typical black and white milk cow.<br />
In many regions of the world, cows may look quite different.}<br />
}<br />
{\externalfigure[cow]}<br />
<br />
\setupselector [caption] [n=1]<br />
\completelistoffigures<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
= Table of Contents =<br />
<br />
If you want to modify [[Table of Contents|TOC]] you may find that <code>level</code> parameter has recently(02/2010) and probably for ever no effect in [[Mark IV]]. You may use {{cmd|placelist}}[chapter,section] instead of {{cmd|setupcombinedlist}}[content][level=2].<br />
<br />
= Grid typesetting =<br />
<br />
The implementation in MkIV is completely new, and various details have changed. The most important difference seems to be that the new grid by default is less tolerant for superscripts, but it can be made so by using {{cmd|setuplayout}}[grid=tolerant].<br />
<br />
= External figures =<br />
<br />
There was a change in the default path search for external figures, but I don't know the exact details off-hand.<br />
IIRC, the main problem is that texmf tree images are now found before local images. To change this ordering,<br />
use the <tt>location</tt> key to <cmd>setupexternalfigures</cmd>:<br />
<br />
<texcode><br />
\setupexternalfigures[location={local,global,default}]<br />
</texcode><br />
<br />
<tt>local</tt>: current directory + <tt>..</tt> + <tt>../..</tt><br />
<br />
<tt>global</tt>: paths set with <tt>directory=...</tt><br />
<br />
<tt>default</tt>: texmf tree<br />
<br />
= Frames =<br />
<br />
The macro <tt>\setuplocalframed</tt> is no longer defined in Mark IV (08.2010).<br />
You can use the <tt>\getparameters</tt> macro as adequate substitute.<br />
<br />
= Trialtypesetting =<br />
<br />
The macros for (de)activating trial typesetting (<tt>\trialtypesettingtrue</tt> and <tt>\trialtypesettingfalse</tt>) have been changed. They are no longer part of a <tt>\newif</tt> statement. The new names are <texcode>\settrialtypesetting</texcode> for activation and <texcode>\resettrialtypesetting</texcode> for deactivation.<br />
<br />
= Programming internals =<br />
<br />
== <tt>read*file</tt><br />
<br />
Commands like <tt>\readlocfile</tt> no longer default to a <tt>.tex</tt> extension, explicit file extensions are now required.<br />
<br />
= Sectioning =<br />
<br />
In MkIV, after <tt>\setuphead[section][placehead=no]</tt> there may still be some output on the page, because MkIV stores the reference target(s) to the section in an invisible box on the current page. Use <tt>\setuphead[section][placehead=hidden]</tt> if that interferes with the rest of your typesetting.</div>Zsdhttps://wiki.contextgarden.net/index.php?title=Command/defineitemgroup&diff=23045Command/defineitemgroup2016-03-13T15:53:05Z<p>Zsd: </p>
<hr />
<div>== Defining lists ==<br />
<br />
Defining {{cmd|startitemize}}-like ''itemgroups'' is accomplished through {{cmd|defineitemgroup}} and the corresponding setup. For historical reasons these have a non-standard, duplicate interface<br />
requiring some options to be specified as key-value setups, others as an argument list. For example:<br />
<br />
<texcode><br />
\defineitemgroup[myitems]<br />
\setupitemgroup [myitems] [each] [joinedup]<br />
\setupitemgroup [myitems] [each] [itemalign=flushright]<br />
</texcode><br />
<br />
The arguments include the:<br />
<br />
* item group name;<br />
* itemization level; and<br />
* list of horizontal and vertical whitespace controls.<br />
<br />
Parameters that concern whitespace (both vertical and horizontal) belong in the argument list: {{code|joinedup}}, {{code|packed}}, {{code|nowhite}}, and others.<br />
<br />
Further options are part of the setup, and can be combined:<br />
<br />
<texcode><br />
\setupitemgroup [myitems] [each] [joinedup] [itemalign=flushright]<br />
</texcode><br />
<br />
== Custom bullets ==<br />
<br />
Bullets are very flexible. They hook into the {{cmd|symbol}} mechanism.<br />
<br />
The macro generator here is {{cmd|definesymbol}}. Basically it allows for all valid Context code to appear inside the definition, including the list item counter. This counter can be accessed via {{cmd|currentitemnumber}}. To achieve the “item number in a box” effect we have to draw this<br />
number as the contents of the box like so:<br />
<br />
<texcode><br />
\definesymbol [instruction_symbol_numbered]<br />
[{\framed{\currentitemnumber}}]<br />
</texcode><br />
<br />
The {{cmd|framed}} must be adapted to the specific requirements.<br />
<br />
== Putting it together ==<br />
<br />
Below listing combines all the above into one working example.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
%% the bullet: a red square<br />
<br />
\defineframed [instruction_symbol_frame] [<br />
background=color,<br />
backgroundcolor=red,<br />
frame=off,<br />
width=1em,<br />
height=\framedparameter{width}, %% -> let height = width<br />
]<br />
<br />
%% bare bullet<br />
<br />
\definesymbol [instruction_symbol]<br />
[{\instruction_symbol_frame{\strut}}]<br />
<br />
%% same bullet, with item number inside<br />
<br />
\definesymbol [instruction_symbol_numbered]<br />
[{\instruction_symbol_frame{\currentitemnumber}}]<br />
<br />
%% define the “regular“ itemization with a red box as bullet indicator<br />
<br />
\defineitemgroup [RegularList]<br />
\setupitemgroup [RegularList] [each] [joinedup]<br />
\setupitemgroup [RegularList] [symbol=instruction_symbol]<br />
<br />
%% define the “Instructions” type itemization that includes the item<br />
%% number inside the box<br />
<br />
\defineitemgroup [Instructions]<br />
\setupitemgroup [Instructions] [each] [joinedup]<br />
\setupitemgroup [Instructions] [symbol=instruction_symbol_numbered]<br />
<br />
\protect<br />
<br />
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br />
%% demo<br />
<br />
\starttext<br />
Chemicals<br />
\startRegularList<br />
\startitem \input knuth \stopitem<br />
\startitem \input ward \stopitem<br />
\stopRegularList<br />
<br />
\blank [2*big]<br />
<br />
Instructions<br />
\startInstructions<br />
\startitem \input knuth \stopitem<br />
\startitem \input ward \stopitem<br />
\stopInstructions<br />
\stoptext<br />
</texcode></div>Zsdhttps://wiki.contextgarden.net/index.php?title=Unexpected_behavior&diff=23043Unexpected behavior2016-03-09T22:12:46Z<p>Zsd: filled in (my guess at) missing words</p>
<hr />
<div>If ConTeXt appears to behave in a counterintuitive way, chances are<br />
that it’s actually your intuitions that lack calibration.<br />
<br />
== Controlling Page Break Before Headings ==<br />
If you add the option <code>page=yes</code> to a heading setup, this<br />
will cause ConTeXt to break the page.<br />
Ordinarily this works as expected, unless, however, the heading<br />
immediately follows a previous section heading with no text in between.<br />
The rationale behind this is that consecutive headings are conceived of<br />
collectively as one single structural element.<br />
For example, the following code will generate only a single page<br />
break although the unit {{cmd|section}} appears twice.<br />
<br />
<texcode><br />
\setuphead[section][page=yes] %% toggle page breaking<br />
<br />
\starttext<br />
\chapter{foo} %% structural inhibits breaking<br />
\section{bar} \input knuth %% -> no break!<br />
\section{baz} \input dawkins %% -> break<br />
\stoptext<br />
</texcode><br />
<br />
In order to get the page break at the section regardless of surrounding<br />
structurals elements, you need to ''unset'' the heading parameter<br />
<code>continue</code> as well.<br />
[http://archive.contextgarden.net/message/20080107.115201.ca26c682.en.html]<br />
<br />
<texcode><br />
\setuphead[section][page=yes,continue=no]<br />
<br />
\starttext<br />
\chapter{foo}<br />
\section{bar} \input knuth %% -> break<br />
\section{baz} \input dawkins %% -> break<br />
\stoptext<br />
</texcode><br />
<br />
(For the curious, the explanation can be found in the definition of the<br />
macro {{cmd|strc_sectioning_handle_page_nop|link=no}} in {{src|strc-sec.mkiv}}).<br />
<br />
<br />
== Unsolicited Vertical Mode ==<br />
Some commands like {{cmd|framed}} cause line breaks to happen if used<br />
in vertical mode, e.g. at the beginning of a line.<br />
Example:<br />
<br />
<context source="yes"><br />
\starttext<br />
\framed{foo} bar.<br />
\stoptext<br />
</context><br />
<br />
The explanation according to the corresponding<br />
[http://wiki.contextgarden.net/FAQ#Why_is_there_a_line-break_in_the_output_after_some_commands.3F FAQ item]<br />
is that before the token <code>\frame</code> is encountered, TEX is<br />
in vertical mode.<br />
This state is ''preserved until after TEX finishes typesetting the<br />
<code>\framed</code> macro''.<br />
Consequently, horizontal mode (where paragraphs are made) is entered<br />
only at the tokens <code>bar</code>.<br />
<br />
To have the frame begin the paragraph instead, horizontal mode will<br />
have to be initiated explicitly.<br />
There are a couple macros for this purpose: the very basic<br />
{{cmd|leavevmode}} ({{src|syst-ini.mkiv}}; inserts an empty box, same<br />
as in the Plain format) and the more familiar {{cmd|dontleavehmode}}<br />
({{src|syst-aux.mkiv}}).<br />
Just use the chosen macro immediately before the <code>\framed</code> macro and<br />
everything should be fine:<br />
<br />
<context source="yes"><br />
\starttext<br />
\leavevmode \framed{foo} bar.\par<br />
\dontleavehmode \framed{foo} bar.<br />
\stoptext<br />
</context><br />
<br />
== Disappearing Crop Marks ==<br />
Crop marks, activated as <code>\setuplayout[marking=on]</code>, are a<br />
useful feature that Context supports out of the box.<br />
They have a peculiarity, though, which my make them useless in specific<br />
cases: They are, by definition, located ''outside the page dimension''.<br />
This means that they show up iff the paper size exceeds the page size.<br />
<br />
Thus if you need auxiliary lines for cutting but have the pages fit the<br />
paper size exactly, you can instead resort to enabling the '''page<br />
background frame'''.<br />
This example sums up the solutions posted by Wolfgang and Marco on<br />
[http://archive.contextgarden.net/message/20120605.202113.0989aa34.en.html<br />
the Context Mailing List].<br />
<texcode><br />
%% the paper size will be a multiple of the page sizes<br />
\setuppapersize [A6,landscape] [A3] <br />
\setuplayout [nx=2,ny=4]%, marking=on] <br />
%% enable the page frame<br />
\setupbackgrounds [page] [frame=on]<br />
%% some further display setups<br />
\setuppagenumbering [location=] <br />
\setupbackgrounds [page] [background=color, backgroundcolor=gray] <br />
\setupbodyfont [sans,58pt] <br />
%% testing ...<br />
\starttext <br />
\dorecurse{4} <br />
{\null\vfill\centerline\recurselevel\vfill\null\page} <br />
\stoptext<br />
</texcode><br />
<br />
== Left and Right ==<br />
When it comes to the justification of paragraphs, do not trust your<br />
intuitions about ''handedness''.<br />
This is a [[Right_and_left|FAQ item]].<br />
<br />
== Footnotes: The Difference between {{cmd|setupnotation}} and {{cmd|setupnote}} ==<br />
<br />
There is a bit of terminology mess concerning notes.<br />
<br />
<!-- I really loathe the wikitext table syntax. --><br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Instruction !! Goal<br />
|-<br />
| {{cmd|setupnotation}}<br />
| This command configures the '''note insert''', i.e. the textual content that will usually be placed at the bottom (with footnotes) or the end of the text (with endnotes). (The control sequence used to be <code>\setupnotedefinition</code>.)<br />
|-<br />
| {{cmd|setupnote}}<br />
| Configure the '''note environment''' where the inserts will be located. Inherits some parameters from {{cmd|framed}}.<br />
|-<br />
| <code>\setupnote[textstyle=,textcommand=]</code><br />
| Configure the '''note symbol''' as appears in the main text, where the note macro is called.<br />
|-<br />
| Plural forms {{cmd|setupnotes}}, {{cmd|setupnotations}}<br />
| These are synonyms for their singular forms.<br />
|-<br />
| {{cmd|setupfootnotes}}<br />
| This is equivalent to <code>\setupnote[footnote]</code>.<br />
|}<br />
<br />
''Summary'':<br />
to setup a blue note, you would first need to define and configure the<br />
insert via {{cmd|setupnotation}}:<br />
<texcode><br />
\definenote [bluenote] [footnote]<br />
\setupnotation [bluenote] [<br />
color=blue,<br />
style=bf,<br />
]<br />
<br />
\starttext foo\bluenote{bar} baz \stoptext<br />
</texcode><br />
<br />
Now adjust the container where the blue notes will reside at the bottom<br />
of the page ({{cmd|setupnote}}):<br />
<br />
<texcode><br />
\definenote [bluenote] [footnote]<br />
\setupnote [bluenote] [<br />
frame=on, %% frame containing all inserts<br />
framecolor=blue,<br />
background=screen,<br />
rulecolor=blue, %% the line above the inserts<br />
rulethickness=1pt, %% both the frame and line width<br />
]<br />
<br />
\starttext foo\bluenote{bar} baz \bluenote{xyzzy} \stoptext<br />
</texcode><br />
<br />
Finally, direct your attention to the note indicator, most commonly a<br />
number or a symbol.<br />
For precise control over the placement define a monadic macro and hook<br />
it into <code>textcommand</code>.<br />
<br />
<texcode><br />
\setupnote [bluenote] [<br />
textstyle=\tx\sans\bold\blue,<br />
textcommand=\myfootnotecommand,<br />
]<br />
\define[1]\myfootnotecommand{\rotate[rotation=42]{#1}}<br />
<br />
\starttext foo\bluenote{bar} baz \bluenote{xyzzy} \stoptext<br />
</texcode><br />
<br />
(For more definite answers concerning the ''notes'' mechanism, use the<br />
source, Luke: {{src|strc-not.mkvi}}.)<br />
<br />
<br />
== Float Insertion Issues ==<br />
<br />
Floating objects can be tricky.<br />
Deciding where they fit best is hard enough, actually getting them<br />
there may be a lot tougher.<br />
Inserting a float will force a line break where the object is<br />
referenced in the source code.<br />
Thus, very long paragraphs may not leave an opportunity to inject the<br />
float if they cover the entire page.<br />
[http://archive.contextgarden.net/message/20120405.103626.a1349c1c.en.html]<br />
<texcode><br />
\starttext<br />
Cows make<br />
\placefigure[top]{A genuine Dutch cow.}{\externalfigure[cow]}<br />
great pets.<br />
\stoptext<br />
</texcode><br />
In these cases the ''postponing mechanism'' offers a reliable way out<br />
({{cmd|startpostponing}}).<br />
It lets you specify an offset (in pages) by which the content of the<br />
postponing environment will be delayed.<br />
In order to place a floating object at the top of the ''n''th page from<br />
the location it is encountered, its argument has needs to be<br />
<code>[+n]</code>.<br />
(Absolute pages can be specified as simply <code>[n]</code>.)<br />
E.&nbsp;g. to put the foat on the following page:<br />
<texcode><br />
\starttext<br />
\startpostponing[+1]<br />
\placefigure[top]{A genuine Dutch cow.}{\externalfigure[cow.pdf]}<br />
\stoppostponing<br />
\input knuth<br />
\page<br />
Cows make great pets.<br />
\stoptext<br />
</texcode><br />
<br />
Another solution can be the less-known ''hangaround environment''<br />
({{cmd|starthangaround}}, cf.<br />
[[Using_Graphics#Flow_text_around_a_picture|Hangaround]]).<br />
It lets the text of a given paragraph (the content of the environment)<br />
flow around a box (the first argument).<br />
In contrast to real floats it does not place a caption.<br />
This poses a problem in MkIV as the new code will not allow placing<br />
captions arbitrarily.<br />
[[http://repo.or.cz/w/context.git/blob/refs/heads/origin:/tex/context/base/strc-flt.mkvi#l257]]<br />
(If you desparately need separate captions please send a feature<br />
request to one of the<br />
[[ConTeXt_Mailing_Lists#Mailing Lists]]).<br />
<br />
<context source="yes" mode="mkii"><br />
\starttext<br />
\input dawkins<br />
<br />
\starthangaround{<br />
\framed[align=right,frame=off,width=.3\textwidth]{<br />
\externalfigure [cow] [width=.3\textwidth]\crlf<br />
%% NB the fake caption works *only in mkii*<br />
\placefloatcaption<br />
[figure]<br />
[ref:acow]<br />
{A smiling Dutch cow.<br />
{\italic Bos primigenius taurus}}<br />
}<br />
}<br />
\input dawkins<br />
\stophangaround<br />
<br />
\input dawkins<br />
\stoptext<br />
</context><br />
<br />
= Syntax =<br />
== Assignments ==<br />
<br />
In the most common form of key-value type arguments, ConTeXt will<br />
accept trailing commas or even empty items. For example, the following<br />
code shows this tolerance for the command {{cmd|definehighlight}}.<br />
<br />
<texcode><br />
\definehighlight [dontmiss] [<br />
color=red,<br />
,, %% empty option: do nothing<br />
style=bold, %% trailing delimiter<br />
]<br />
</texcode><br />
<br />
This is the syntax accepted e.g. by the majority of setups and<br />
[[Commands_with_KeyVal_arguments|<code>\getparameters</code>]].<br />
(For the parser code cf. {{src|syst-aux.mkiv}}.)<br />
<br />
There are, however, exceptions to this rule. A known case where<br />
options are processed in a less tolerant fashion is<br />
{{cmd|setuplabeltext}}.<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067585.html]<br />
Thus the following snippet will not compile, forcing ConTeXt to fail<br />
with a cryptic <code>Argument of ...</code> error message.<br />
<texcode><br />
\setuplabeltext<br />
[Nomen=nomen,<br />
Est=est,<br />
Omen=est,] %% <= fails!<br />
\setuplabeltext [Nomen=nomen, Est=est, Omen=omen] %% <= works<br />
\starttext<br />
\labeltext{Nomen}<br />
\labeltext{Est}<br />
\labeltext{Omen}<br />
\stoptext<br />
</texcode><br />
<br />
(A similar exception concerning {{cmd|definepalet}} has been migrated<br />
to the standard argument model but may still show the earlier behavior<br />
in not so recent installations.<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067673.html])<br />
<br />
<!--<br />
== \usepath ==<br />
Hans announced this one can be expected to be unified in the near<br />
future.<br />
[http://archive.contextgarden.net/message/20110929.151806.3ad6fbdd.en.html]<br />
<br />
What’s the status of this?<br />
--><br />
<br />
== Treacherous Dimensions ==<br />
<br />
At some places dimension-lookalikes are expected but they do not behave<br />
exactly as in TEX per se because they are evaluated differently.<br />
A very common example is the command {{cmd|setupbodyfont}} that is<br />
possibly called, albeit implicitly, in every production document.<br />
Its argument, the ''font size'', although it may look like an ordinary<br />
dimension expression, will not have the same result if it has zeros<br />
prepended or decimal places are specified.<br />
<br />
Suppose you want to set the main font to a very large size:<br />
<br />
<texcode><br />
\setupbodyfont[42pt]<br />
\starttext foobar \stoptext<br />
</texcode><br />
<br />
this works out well as long as you do not mistake the expression<br />
''42pt'' to be a real dimension.<br />
<br />
In TEX dimensions (which are really just integers) are treated the same<br />
irrespective of leading or trailing zeros used in the variable<br />
assignment.<br />
Thus the following are all equivalent:<br />
<br />
<texcode><br />
\newdimen\fortytwo\fortytwo=42pt<br />
\newdimen\fortytoo\fortytoo=042pt<br />
\newdimen\fortytww\fortytww=42.00pt<br />
<br />
\starttext<br />
\the\fortytwo\ \ifnum\fortytwo=\fortytoo\m{\top}\else\m{\bot}\fi\par<br />
\the\fortytoo\ \ifnum\fortytwo=\fortytww\m{\top}\else\m{\bot}\fi\par<br />
\the\fortytww\ \ifnum\fortytoo=\fortytww\m{\top}\else\m{\bot}\fi\par<br />
\stoptext<br />
</texcode><br />
<br />
However, this does not hold for the Context commands<br />
{{cmd|setupbodyfont}} and {{cmd|switchtobodyfont}}.<br />
With the latter macros, only the ''pure-integer'' specification<br />
(<code>42pt</code>) can be used reliably, everything else, even though it<br />
denotates the same TEX dimension, will result in a warning:<br />
<br />
<pre><br />
fonts > bodyfont 42.0pt is defined (can better be done global)<br />
</pre><br />
<br />
Additionally, if the code in question relies on font switching a lot<br />
(e.&nbsp;g. Lua snippets that calculcate font sizes from floating point<br />
numbers), there will be a ''huge'' perfomance penalty because everytime<br />
a font switch occurs, the font will be reloaded entirely.<br />
The reason for this is that the process of defining a font for the main<br />
text is accompanied by a myriad of secondary definitions for different<br />
relative font sizes ({{cmd|tfx|link=no}}, {{cmd|tfa|link=no}}<br />
[[Font_Switching#Font_sizes|and the likes]]) and shapes &ndash; the<br />
creation of the ''body font environment''.<br />
If the “size” requested by {{cmd|setupbodyfont}} cannot be found in the<br />
internal table, this environment will be rebuilt on the spot.<br />
<br />
''It is also not possible to catch these cases by predefining the corresponding bodyfont environments''<br />
by placing {{cmd|definebodyfontenvironment}} statements in the preamble.<br />
So if you have, say:<br />
<br />
<texcode><br />
\definebodyfontenvironment[42.0pt]<br />
\definebodyfontenvironment[042pt]<br />
\definebodyfontenvironment[042.0pt]<br />
\starttext<br />
\setupbodyfont[42.0pt] foo bar<br />
\setupbodyfont[042pt] foo bar<br />
\setupbodyfont[042.0pt] foo bar<br />
\stoptext<br />
</texcode><br />
<br />
the warning and slowdown will occur regardless.<br />
The only real option is to serve {{cmd|setupbodyfont}} and the likes<br />
natural integers only.<br />
<br />
Alternatively you can always employ raw font definitions, if there<br />
isn’t any need for the environment in the first place:<br />
<texcode><br />
\starttext<br />
\definedfont[file:iwona-regular.otf at 42.0pt] foo bar<br />
\definedfont[file:iwona-regular.otf at 042pt] foo bar<br />
\definedfont[file:iwona-regular.otf at 042.0pt] foo bar<br />
\stoptext<br />
</texcode><br />
Here the dimensions are ''real''.<br />
<br />
For further information see<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067324.html this] and<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/066940.html this]<br />
thread on the mailing list.<br />
<br />
<br />
= Multipass =<br />
<br />
In some circumstances, portions of code are evaluated two or more<br />
times.<br />
This can be disruptive in contexts where the order of actions is<br />
important.<br />
<br />
== Trialtypesetting ==<br />
<br />
Often the size of elements must be calculated prior to determining the<br />
optimal placements.<br />
Probably the most common example are tables:<br />
In order to align cells correctly the dimensions of later parts of the<br />
document must already be determined before anything is typeset.<br />
The stage during which this takes place is called *trial typesetting*.<br />
<br />
The system mode ''trialtypesetting'' allows fine-grained control over<br />
what code should be executed during what stage.<br />
For instance, the naive definition of a macro that increments and<br />
prints a counter register will behave erratically in tables:<br />
<br />
<context source="yes" mode="mkiv"><br />
\def \inccount {%<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]%<br />
}<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
To bypass the extra evaluation, wrap the incrementation part in an<br />
<code>\iftrialtypesetting</code> conditional.<br />
<br />
<context source="yes" mode="mkiv"><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\fi<br />
\getnumber [somecount]%<br />
}<br />
<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
Note that annoying as it may appear, the trial typesetting phase is<br />
essential for certain features to work, so take extra care when<br />
omitting it.<br />
In the example above the number itself must be present as placeholder<br />
during the first pass even though it has not been updated at this<br />
point.<br />
<br />
<texcode><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]% <= wrong!<br />
\fi<br />
}<br />
</texcode><br />
<br />
<context mode="mkiv" source="no"><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]%<br />
\fi<br />
}<br />
<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
== Tables ==<br />
<br />
In addition to trial typesetting Context also knows a ''table'' state:<br />
<br />
<context mode="mkiv" source="yes"><br />
\def \tablecheck {\ifintable In table. \else Outside table. \fi}<br />
<br />
\starttext<br />
\tablecheck<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \tablecheck \eTD \bTD \tablecheck \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
\tablecheck %% decrement<br />
\stoptext<br />
</context><br />
<br />
== Metapost ==<br />
<br />
As with TeX, Metapost sometimes requires multiple passes,<br />
especially when processing text.<br />
In below snippet, the Metapost tracer reveals that the code is actually<br />
evaluated twice:<br />
<br />
<texcode><br />
\enabletrackers[metapost.showlog]<br />
\starttext<br />
\startMPcode<br />
show "This gets printed twice.";<br />
label (btex Some label text etex, (0,0));<br />
\stopMPcode<br />
\stoptext<br />
</texcode><br />
<br />
NB removing the <code>label</code> statement will result in the second<br />
pass being omitted.<br />
<br />
In [[Metafun]], the default Metapost format in Context, the booleans<br />
<code>mfun_first_run</code> and <code>mfun_trial_run</code> allow<br />
detecting the individual stages:<br />
<br />
<texcode><br />
\enabletrackers[metapost.showlog]<br />
\starttext<br />
\startMPcode<br />
if mfun_trial_run :<br />
show "This gets printed during the trial pass.";<br />
else :<br />
show "This gets printed during the final pass.";<br />
fi;<br />
label (btex Some label text etex, (0,0));<br />
\stopMPcode<br />
\stoptext<br />
</texcode></div>Zsd