https://wiki.contextgarden.net/api.php?action=feedcontributions&user=Marco&feedformat=atomWiki - User contributions [en]2024-03-29T16:04:05ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=File:layout.svg&diff=34278File:layout.svg2023-11-08T08:51:20Z<p>Marco: Marco uploaded a new version of File:layout.svg</p>
<hr />
<div>Diagram of various \setuplayout[] dimensions.</div>Marcohttps://wiki.contextgarden.net/index.php?title=File:layout-2.svg&diff=34277File:layout-2.svg2023-11-08T08:50:01Z<p>Marco: Marco uploaded a new version of File:layout-2.svg</p>
<hr />
<div>== Summary ==<br />
Diagram of \setuplayout[] dimensions</div>Marcohttps://wiki.contextgarden.net/index.php?title=File:layout-2.svg&diff=34276File:layout-2.svg2023-11-08T08:48:48Z<p>Marco: Marco uploaded a new version of File:layout-2.svg</p>
<hr />
<div>== Summary ==<br />
Diagram of \setuplayout[] dimensions</div>Marcohttps://wiki.contextgarden.net/index.php?title=File:layout-2.svg&diff=34275File:layout-2.svg2023-11-08T08:42:14Z<p>Marco: Marco uploaded a new version of File:layout-2.svg</p>
<hr />
<div>== Summary ==<br />
Diagram of \setuplayout[] dimensions</div>Marcohttps://wiki.contextgarden.net/index.php?title=File:layout-3.svg&diff=34274File:layout-3.svg2023-11-08T08:35:21Z<p>Marco: Diagram of \setuplayout[] dimensions</p>
<hr />
<div>== Summary ==<br />
Diagram of \setuplayout[] dimensions</div>Marcohttps://wiki.contextgarden.net/index.php?title=File:layout-2.svg&diff=34273File:layout-2.svg2023-11-08T08:32:51Z<p>Marco: Diagram of \setuplayout[] dimensions</p>
<hr />
<div>== Summary ==<br />
Diagram of \setuplayout[] dimensions</div>Marcohttps://wiki.contextgarden.net/index.php?title=Running_ConTeXt&diff=33333Running ConTeXt2021-12-26T13:40:18Z<p>Marco: Add description regarding --errors</p>
<hr />
<div>The [[First Document]] page provides a cursory introduction to typesetting document using ConTeXt. The [[Context]] page describes the command-line options in brief. This page provides additional information for command-line options.<br />
<br />
== --run ==<br />
<br />
Process one or more files; this is the default action and may be omitted.<br />
<br />
== --autopdf ==<br />
<br />
Reopen the generated PDF file in the system's default PDF file viewer after recompiling a document.<br />
<br />
== --purgeall ==<br />
<br />
Delete all build artifacts generated during compiling of a document, such as ''.tuc'' and ''.log'' files.<br />
<br />
== --path=list ==<br />
<br />
Provide a comma-separated list of paths for ConTeXt to search when processing. For example:<br />
<br />
context --path="$HOME/writing/common/styles,$HOME/writing/amazing-novel/styles"<br />
<br />
== --result ==<br />
<br />
Changes the output document file name. ConTeXt creates the output document file in the current working directory; this option cannot create or move the output document in a different directory. Instead, change the working directory before running ConTeXt and use the ''--path'' option to configure where ConTeXt searches for files to process.<br />
<br />
== --errors ==<br />
<br />
ConTeXt is sometimes quite liberal when it comes to non-syntactical errors in the source files. Missing fonts, missing characters in a font, missing references do not automatically abort a run or exit with a non-successful return value. To report possible issues, either compile with <code>--errors</code> or use<br />
<br />
<texcode><br />
\enabledirectives<br />
[logs.errors]<br />
</texcode><br />
<br />
in the source file. Example:<br />
<br />
<texcode><br />
\starttext<br />
%% missing figure<br />
\externalfigure [nonexistent]<br />
\stoptext<br />
</texcode><br />
<br />
Compiling with <code>context --noconsole --silent --nostatistics file.tex</code> would result in no output (as well as a successful return value). If, on the other hand, compiled with <code>context --noconsole --silent --nostatistics --errors file.tex</code> the output would be:<br />
<br />
<texcode><br />
error logging > start possible issues<br />
graphics > start missing figures<br />
graphics > foo<br />
graphics > stop missing figures<br />
error logging > stop possible issues<br />
</texcode><br />
<br />
The return value would still be zero (success), though. To have the return value reflect possible found issues, patterns can be used. Example:<br />
<br />
<texcode><br />
\enabledirectives<br />
[logs.errors=*]<br />
</texcode><br />
<br />
Alternatively the patterns can be provided as a compile switch <code>--errors='*'</code>. The quotes are required to prevent shell expansion. With these options, the <code>context</code> would return 1 (failure) if problems are found. <br />
<br />
Note that only some of the problems are reported, some of which might not be critical and other, possibly critical problems, are not detected.<br />
<br />
[[Category:Basics]]<br />
[[Category:Tools]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setuptolerance&diff=33318Command/setuptolerance2021-12-05T21:30:10Z<p>Marco: Add missing argument in example</p>
<hr />
<div><cd:commandgroup name="setuptolerance" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"><br />
<cd:shortdesc>The command <tt>\setuptolerance</tt> configures space stretching<br />
</cd:shortdesc><br />
<cd:variants><br />
<cd:command category="whitespace" file="spac-hor.mkiv" interfacedate="2020-06-19T13:41" interfacefile="i-tolerance.xml" level="style" name="setuptolerance" variantnumber="1"><br />
<cd:arguments><br />
<cd:keywords list="yes" ordinal="1"><br />
<cd:keywordsdoc></cd:keywordsdoc><br />
<cd:constant type="horizontal"></cd:constant><br />
<cd:constant type="vertical"></cd:constant><br />
<cd:constant type="verystrict">horizontal: <code>\tolerance 200</code><br />
vertical: <code>\def\bottomtolerance{0}</code></cd:constant><br />
<cd:constant type="strict">horizontal: <code>\tolerance 1500</code><br />
vertical: <code>\def\bottomtolerance{0.050}</code></cd:constant><br />
<cd:constant type="tolerant">horizontal: <code>\tolerance 3000</code><br />
vertical: <code>\def\bottomtolerance{0.075}</code></cd:constant><br />
<cd:constant type="verytolerant">horizontal: <code>\tolerance 4500</code><br />
vertical: <code>\def\bottomtolerance{0.100}</code></cd:constant><br />
<cd:constant type="space">horizontal: <code>\spaceskip 0.5em plus 0.25em minus 0.25em</code></cd:constant><br />
<cd:constant type="stretch">horizontal: <code>\emergencystretch\bodyfontsize</code></cd:constant><br />
</cd:keywords><br />
</cd:arguments><br />
</cd:command><br />
</cd:variants><br />
<cd:description>Set up how tolerant TeX should be of ‘ugly’ stretching of spaces. The more stretching you allow, the easier it is for TeX to choose a stretched-out underfull line instead of a margin-invading overfull line.<br />
<br />
Use <code>\setuptolerance[horizontal,...]</code> for interword spacing and <code>\setuptolerance[vertical,...]</code> for column stretching. Don't try to combine these two.<br />
<br />
The default orientation is ''horizontal'', so the following two are equivalent:<br />
<br />
<texcode><br />
\setuptolerance[horizontal,tolerant]<br />
% and<br />
\setuptolerance[tolerant]<br />
</texcode><br />
</cd:description><br />
<cd:examples><cd:example title=" Tolerance of framed texts">Framed texts don't inherit the global tolerance setting, but instead use their own tolerance as well:<br />
<br />
<texcode><br />
%% global tolerance<br />
\setuptolerance<br />
[tolerant]<br />
<br />
%% tolerance for framed texts<br />
\setupframedtext<br />
[align=verytolerant]<br />
</texcode></cd:example><cd:example title=" Tolerance of float captions">Float captions don't inherit the global tolerance setting, but instead use their own tolerance:<br />
<br />
<texcode><br />
%% global tolerance<br />
\setuptolerance<br />
[tolerant]<br />
<br />
%% tolerance for captions<br />
\setupcaption<br />
[figure, table]<br />
[align={middle, tolerant}]<br />
</texcode><br />
<br />
<tt>middle</tt> is required, otherwise the caption placement is changed from the default placement (middle).</cd:example></cd:examples><br />
<cd:notes></cd:notes><br />
<cd:seealso><br />
<cd:source file="spac-hor.mkiv" originator="system"></cd:source><br />
<cd:wikipage originator="system" page="Category:Whitespace"></cd:wikipage></cd:seealso><br />
</cd:commandgroup></div>Marcohttps://wiki.contextgarden.net/index.php?title=Command_old/setuptolerance&diff=33300Command old/setuptolerance2021-12-03T12:20:20Z<p>Marco: Add section about framed text tolerance</p>
<hr />
<div>{{Reference<br />
|name=setuptolerance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<br />
<syntax>setuptolerance</syntax><br />
<br />
== Description == <br />
<br />
Set up how tolerant TeX should be of ‘ugly’ stretching of spaces. The more stretching you allow, the easier it is for TeX to choose a stretched-out underfull line instead of a margin-invading overfull line.<br />
<br />
Use <code>\setuptolerance[horizontal,...]</code> for interword spacing and <code>\setuptolerance[vertical,...]</code> for column stretching. Don't try to combine these two.<br />
<br />
The default orientation is ''horizontal'', so the following two are equivalent:<br />
<br />
<texcode><br />
\setuptolerance[horizontal,tolerant]<br />
% and<br />
\setuptolerance[tolerant]<br />
</texcode><br />
<br />
In horizontal orientation the keywords have the following effect:<br />
<br />
{|<br />
|stretch:<br />
|make <tt>\emergencystretch</tt> equal to <tt>\bodyfontsize</tt> (i.e. 11pt), default is 0pt<br />
|-<br />
|space:<br />
|<tt>\spaceskip .5em plus .25em minus .25em</tt><br />
|-<br />
|verystrict:<br />
|<tt>\tolerance 200</tt><br />
|-<br />
|strict:<br />
|<tt>\tolerance 1500</tt><br />
|-<br />
|tolerant:<br />
|<tt>\tolerance 3000</tt><br />
|-<br />
|verytolerant:<br />
|<tt>\tolerance 4500</tt><br />
|}<br />
<br />
In ''vertical'' orientation the keywords define a factor ''bottomtolerance''<br />
which is only used(?) in columns. The factors are:<br />
<br />
{|<br />
|verystrict:<br />
|0<br />
|-<br />
|strict:<br />
|0.050<br />
|-<br />
|tolerant:<br />
|0.075<br />
|-<br />
|verytolerant:<br />
|0.100<br />
|}<br />
<br />
== Tolerance of float captions ==<br />
<br />
Float captions don't inherit the global tolerance setting, but instead use their own tolerance:<br />
<br />
<texcode><br />
%% global tolerance<br />
\setuptolerance<br />
[tolerant]<br />
<br />
%% tolerance for captions<br />
\setupcaption<br />
[align=tolerant]<br />
</texcode><br />
<br />
== Tolerance of framed texts ==<br />
<br />
Framed texts don't inherit the global tolerance setting, but instead use their own tolerance as well:<br />
<br />
<texcode><br />
%% global tolerance<br />
\setuptolerance<br />
[tolerant]<br />
<br />
%% tolerance for framed texts<br />
\setupframedtext<br />
[align=verytolerant]<br />
</texcode><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/Hyphenation|setuptolerance]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command_old/setuptolerance&diff=33299Command old/setuptolerance2021-12-03T12:13:37Z<p>Marco: Add section about float caption tolerance</p>
<hr />
<div>{{Reference<br />
|name=setuptolerance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<br />
<syntax>setuptolerance</syntax><br />
<br />
== Description == <br />
<br />
Set up how tolerant TeX should be of ‘ugly’ stretching of spaces. The more stretching you allow, the easier it is for TeX to choose a stretched-out underfull line instead of a margin-invading overfull line.<br />
<br />
Use <code>\setuptolerance[horizontal,...]</code> for interword spacing and <code>\setuptolerance[vertical,...]</code> for column stretching. Don't try to combine these two.<br />
<br />
The default orientation is ''horizontal'', so the following two are equivalent:<br />
<br />
<texcode><br />
\setuptolerance[horizontal,tolerant]<br />
% and<br />
\setuptolerance[tolerant]<br />
</texcode><br />
<br />
In horizontal orientation the keywords have the following effect:<br />
<br />
{|<br />
|stretch:<br />
|make <tt>\emergencystretch</tt> equal to <tt>\bodyfontsize</tt> (i.e. 11pt), default is 0pt<br />
|-<br />
|space:<br />
|<tt>\spaceskip .5em plus .25em minus .25em</tt><br />
|-<br />
|verystrict:<br />
|<tt>\tolerance 200</tt><br />
|-<br />
|strict:<br />
|<tt>\tolerance 1500</tt><br />
|-<br />
|tolerant:<br />
|<tt>\tolerance 3000</tt><br />
|-<br />
|verytolerant:<br />
|<tt>\tolerance 4500</tt><br />
|}<br />
<br />
In ''vertical'' orientation the keywords define a factor ''bottomtolerance''<br />
which is only used(?) in columns. The factors are:<br />
<br />
{|<br />
|verystrict:<br />
|0<br />
|-<br />
|strict:<br />
|0.050<br />
|-<br />
|tolerant:<br />
|0.075<br />
|-<br />
|verytolerant:<br />
|0.100<br />
|}<br />
<br />
== Tolerance of float captions ==<br />
<br />
Float captions don't inherit the global tolerance setting, but instead use their own tolerance:<br />
<br />
<texcode><br />
%% global tolerance<br />
\setuptolerance<br />
[tolerant]<br />
<br />
%% tolerance for captions<br />
\setupcaption<br />
[align=tolerant]<br />
</texcode><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/Hyphenation|setuptolerance]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Floating_Objects&diff=33249Floating Objects2021-11-28T15:11:27Z<p>Marco: Remove TEXpage from code snippets</p>
<hr />
<div>= Introduction =<br />
<br />
Floating Objects (floats) are placed (and numbered) automatically, with a configurable (and optional) caption. They are placed at an appropriate position determined by the TeX float placement algorithm. The algorithm has a number of options that can influence float placement.<br />
<br />
Most options in the manual (such as {{cmd|placeexternalfigure}}) are described using the generic {{cmd|placefloat}}. Additionally, {{cmd|placelistoffigures}} creates a list of the figures used in the document.<br />
<br />
Floats include "graphic", "figure", "table", and "intermezzo". Additional floats can be defined using {{cmd|definefloat}}.<br />
<br />
<texcode><br />
\placefloat[place][reference]{caption}{some float}<br />
</texcode><br />
<br />
'''place''' is one or several (comma separated) of:<br />
<table><br />
<tr bgcolor="#AAAAAA"><th>preference</th><th align="left">result</th></tr><br />
<tr bgcolor="#DDDDDD"><td>left</td><td>left of text</td></tr><br />
<tr><td>right</td><td>right of text</td></tr><br />
<tr bgcolor="#DDDDDD"><td>here</td><td>preferably here</td></tr><br />
<tr><td>top</td><td>at top of page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>bottom</td><td>at bottom of page</td></tr><br />
<tr><td>inleft</td><td>in left margin</td></tr><br />
<tr bgcolor="#DDDDDD"><td>inright</td><td>in right margin</td></tr><br />
<tr><td>inmargin</td><td>in the margin (left or right)</td></tr><br />
<tr bgcolor="#DDDDDD"><td>margin</td><td>in the margin (margin float)</td></tr><br />
<tr><td>page</td><td>on a new (empty) page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>opposite</td><td>on the left page</td></tr><br />
<tr><td>90</td><td>orientation (rotation angle), both caption and contents</td></tr><br />
<tr bgcolor="#DDDDDD"><td>always</td><td>precedence over stored floats</td></tr><br />
<tr><td>force</td><td>per se here</td></tr><br />
<tr bgcolor="#DDDDDD"><td>split</td><td>(For TABLES only) split tables</td></tr><br />
</table><br />
(table copied from the manual)<br />
<br />
{{cmd|placefigure}} and {{cmd|placetable}} also accept the same set of options, and allow to create floating figures and captions respectively.<br />
<br />
'''reference'''<br />
<br />
If you don't need to refer to your float, you can leave this parameter out.<br />
<br />
= Examples =<br />
I will explain the examples in terms of {{cmd|placefigure}} but the same set of options are also valid for other floats.<br />
<br />
* If you do not want a caption<br />
<br />
<texcode><br />
\placefigure[none] {} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
<br />
* If you do not want the figure to be numbered (but still want the caption)<br />
<br />
<texcode><br />
\placefigure [nonumber] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
* Suppose you want the figure to be placed on the right side of the page, a few lines into the paragraph, and want the rest of the paragraph to wrap around the figure<br />
<br />
<texcode><br />
\placefigure [right,2*line] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
or <br />
<br />
<texcode><br />
\placefigure [right,2*hang] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
This does not work correctly at a page boundary. The <tt>line</tt> option leaves the space above the figures empty, while the <tt>hang</tt> option also wraps texts above the figure.<br />
<br />
=Floats and columns=<br />
<br />
This special case is discussed [[Columns#Floats_and_other_limitations_of_columns|here]].<br />
<br />
=Floats on empty pages=<br />
<br />
There’s a way to switch off page headings at full page floats:<br />
<br />
<texcode><br />
\startplacefigure[title=Cow,location={page,high,header}]<br />
\externalfigure[cow.pdf]<br />
\stopplacefigure<br />
</texcode><br />
<br />
=Protruding Floats in Double-Sided Documents=<br />
<br />
If you have a double-sided document with wide outer margins then you might want your figures to protrude into the margin. In a double-sided document you need to tell ConTeXt to decide whether to make the figure protrude to the left or the right. This can be done as follows:<br />
<br />
<texcode><br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\placetextmarginfigure{\externalfigure[figurename]}<br />
</texcode><br />
<br />
The following code gives a full example that can be pasted into live ConTeXt:<br />
<br />
<texcode><br />
\setuppagenumbering [alternative=doublesided]<br />
\setuplayout[location=middle,backspace=2pc, width=20pc]<br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\starttext<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\stoptext<br />
</texcode><br />
<br />
=Landscape Floats in a Portrait Document=<br />
<br />
Wide tables, for example, can be turned and most likely will need to be put on a separate page.<br />
<texcode><br />
\startplacetable [location={page,90},title=Table caption]<br />
\bTABLE [textwidth=\textheight]<br />
put a wide table here...<br />
\eTABLE<br />
\stopplacetable<br />
</texcode><br />
Both the table caption and the contents will be rotated, but not the page header and footer which remain "upright". Notice that one must set the TABLE textwidth to {{cmd|textheight}} in order for the table macros to fit properly.<br />
<br />
= Floats and section headings =<br />
<br />
By default, section headings don't wrap “around” floating objects. Instead, they will be moved down as far as needed to appear below the float. This behaviour can be controlled using the <tt>aligntitle</tt> option of the {{cmd|setupheads}} or {{cmd|setuphead}} commands.<br />
<br />
= Captions =<br />
<br />
To change the style of figure(table) captions, use {{cmd|setupcaptions}}.<br />
<br />
To use a different (e.g. abbreviated) caption in the list of floats, you can do:<br />
<br />
<texcode><br />
\startplacefigure[title={A rather long caption},list={A short caption}]<br />
This is the content of the actual figure<br />
\stopplacefigure<br />
</texcode><br />
<br />
In MkII this was possible by:<br />
<br />
<texcode><br />
\defineselector[caption][max=2,n=2]<br />
\starttext<br />
\setupselector[caption][n=1]<br />
\completelistoffigures<br />
\setupselector[caption][n=2]<br />
\placefigure[][]<br />
{\select{caption}<br />
{Short caption for list}<br />
{A rather longer caption which will appear below the figure itself}}<br />
{This is the content of the actual figure}<br />
\stoptext<br />
</texcode><br />
<br />
= Float Combinations =<br />
<br />
If you want to place floats besides each other or in a regular matrix,<br />
each with its own number and caption, you need a float combination:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum] %% sample images<br />
<br />
\startplacefigure [location=none] % disable numbering of outer float<br />
\startfloatcombination [nx=2, ny=1] % two columns, one row<br />
\startplacefigure [title=Left]<br />
\externalfigure [dummy]<br />
\stopplacefigure<br />
\startplacefigure [title=Right]<br />
\externalfigure [dummy]<br />
\stopplacefigure<br />
\stopfloatcombination<br />
\stopplacefigure<br />
</context><br />
<br />
If you want only one number for the whole thing, you may use a regular combination within a float:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum] %% sample images<br />
<br />
\startplacefigure [title=My combination]<br />
\startcombination [nx=2, ny=1]<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption Left \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption Right \stopcaption<br />
\stopcombination<br />
\stopplacefigure<br />
</context><br />
<br />
<br />
See also {{cmd|startcombination}}, {{cmd|startfloatcombination}} and [[Combinations]].<br />
<br />
= Subfloats =<br />
Subfloatnumbering creates subfigures sharing a mutual figure prefix and an<br />
individual subfigure designator (e.g. figure 1a), figure 1b, etc.). The command {{cmd|startsubfloatnumbering}} is used for this.<br />
<br />
<context source=yes><br />
\useMPlibrary [dum] %% sample images<br />
<br />
\startsubfloatnumbering<br />
\startplacefigure [title=Alpha]<br />
\externalfigure<br />
\stopplacefigure<br />
<br />
\startplacefigure [title=Beta]<br />
\externalfigure<br />
\stopplacefigure<br />
\stopsubfloatnumbering<br />
</context><br />
<br />
Subfloats can also be used with floatcombinations:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum] %% sample images<br />
<br />
\startplacefigure [location=none]<br />
\startsubfloatnumbering<br />
\startfloatcombination [nx=2, ny=1]<br />
\startplacefigure [title=Left, reference=fig:left] \externalfigure \stopplacefigure<br />
\startplacefigure [title=Right, reference=fig:right] \externalfigure \stopplacefigure<br />
\stopfloatcombination<br />
\stopsubfloatnumbering<br />
\stopplacefigure<br />
<br />
See \in{figure}[fig:left] and \in{figure}[fig:right].<br />
</context><br />
<br />
<br />
See also {{cmd|startcombination}}, {{cmd|startfloatcombination}}, [[Combinations]] and {{cmd|startsubfloatcombination}}.<br />
<br />
= Flushing floats =<br />
<br />
The command {{cmd|placefloats}} outputs all pending floats.<br />
<br />
[[Category:Basics]]<br />
[[Category:Layout]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Floating_Objects&diff=33248Floating Objects2021-11-28T15:10:18Z<p>Marco: Remove TEXpage from code snippets</p>
<hr />
<div>= Introduction =<br />
<br />
Floating Objects (floats) are placed (and numbered) automatically, with a configurable (and optional) caption. They are placed at an appropriate position determined by the TeX float placement algorithm. The algorithm has a number of options that can influence float placement.<br />
<br />
Most options in the manual (such as {{cmd|placeexternalfigure}}) are described using the generic {{cmd|placefloat}}. Additionally, {{cmd|placelistoffigures}} creates a list of the figures used in the document.<br />
<br />
Floats include "graphic", "figure", "table", and "intermezzo". Additional floats can be defined using {{cmd|definefloat}}.<br />
<br />
<texcode><br />
\placefloat[place][reference]{caption}{some float}<br />
</texcode><br />
<br />
'''place''' is one or several (comma separated) of:<br />
<table><br />
<tr bgcolor="#AAAAAA"><th>preference</th><th align="left">result</th></tr><br />
<tr bgcolor="#DDDDDD"><td>left</td><td>left of text</td></tr><br />
<tr><td>right</td><td>right of text</td></tr><br />
<tr bgcolor="#DDDDDD"><td>here</td><td>preferably here</td></tr><br />
<tr><td>top</td><td>at top of page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>bottom</td><td>at bottom of page</td></tr><br />
<tr><td>inleft</td><td>in left margin</td></tr><br />
<tr bgcolor="#DDDDDD"><td>inright</td><td>in right margin</td></tr><br />
<tr><td>inmargin</td><td>in the margin (left or right)</td></tr><br />
<tr bgcolor="#DDDDDD"><td>margin</td><td>in the margin (margin float)</td></tr><br />
<tr><td>page</td><td>on a new (empty) page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>opposite</td><td>on the left page</td></tr><br />
<tr><td>90</td><td>orientation (rotation angle), both caption and contents</td></tr><br />
<tr bgcolor="#DDDDDD"><td>always</td><td>precedence over stored floats</td></tr><br />
<tr><td>force</td><td>per se here</td></tr><br />
<tr bgcolor="#DDDDDD"><td>split</td><td>(For TABLES only) split tables</td></tr><br />
</table><br />
(table copied from the manual)<br />
<br />
{{cmd|placefigure}} and {{cmd|placetable}} also accept the same set of options, and allow to create floating figures and captions respectively.<br />
<br />
'''reference'''<br />
<br />
If you don't need to refer to your float, you can leave this parameter out.<br />
<br />
= Examples =<br />
I will explain the examples in terms of {{cmd|placefigure}} but the same set of options are also valid for other floats.<br />
<br />
* If you do not want a caption<br />
<br />
<texcode><br />
\placefigure[none] {} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
<br />
* If you do not want the figure to be numbered (but still want the caption)<br />
<br />
<texcode><br />
\placefigure [nonumber] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
* Suppose you want the figure to be placed on the right side of the page, a few lines into the paragraph, and want the rest of the paragraph to wrap around the figure<br />
<br />
<texcode><br />
\placefigure [right,2*line] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
or <br />
<br />
<texcode><br />
\placefigure [right,2*hang] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
This does not work correctly at a page boundary. The <tt>line</tt> option leaves the space above the figures empty, while the <tt>hang</tt> option also wraps texts above the figure.<br />
<br />
=Floats and columns=<br />
<br />
This special case is discussed [[Columns#Floats_and_other_limitations_of_columns|here]].<br />
<br />
=Floats on empty pages=<br />
<br />
There’s a way to switch off page headings at full page floats:<br />
<br />
<texcode><br />
\startplacefigure[title=Cow,location={page,high,header}]<br />
\externalfigure[cow.pdf]<br />
\stopplacefigure<br />
</texcode><br />
<br />
=Protruding Floats in Double-Sided Documents=<br />
<br />
If you have a double-sided document with wide outer margins then you might want your figures to protrude into the margin. In a double-sided document you need to tell ConTeXt to decide whether to make the figure protrude to the left or the right. This can be done as follows:<br />
<br />
<texcode><br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\placetextmarginfigure{\externalfigure[figurename]}<br />
</texcode><br />
<br />
The following code gives a full example that can be pasted into live ConTeXt:<br />
<br />
<texcode><br />
\setuppagenumbering [alternative=doublesided]<br />
\setuplayout[location=middle,backspace=2pc, width=20pc]<br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\starttext<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\stoptext<br />
</texcode><br />
<br />
=Landscape Floats in a Portrait Document=<br />
<br />
Wide tables, for example, can be turned and most likely will need to be put on a separate page.<br />
<texcode><br />
\startplacetable [location={page,90},title=Table caption]<br />
\bTABLE [textwidth=\textheight]<br />
put a wide table here...<br />
\eTABLE<br />
\stopplacetable<br />
</texcode><br />
Both the table caption and the contents will be rotated, but not the page header and footer which remain "upright". Notice that one must set the TABLE textwidth to {{cmd|textheight}} in order for the table macros to fit properly.<br />
<br />
= Floats and section headings =<br />
<br />
By default, section headings don't wrap “around” floating objects. Instead, they will be moved down as far as needed to appear below the float. This behaviour can be controlled using the <tt>aligntitle</tt> option of the {{cmd|setupheads}} or {{cmd|setuphead}} commands.<br />
<br />
= Captions =<br />
<br />
To change the style of figure(table) captions, use {{cmd|setupcaptions}}.<br />
<br />
To use a different (e.g. abbreviated) caption in the list of floats, you can do:<br />
<br />
<texcode><br />
\startplacefigure[title={A rather long caption},list={A short caption}]<br />
This is the content of the actual figure<br />
\stopplacefigure<br />
</texcode><br />
<br />
In MkII this was possible by:<br />
<br />
<texcode><br />
\defineselector[caption][max=2,n=2]<br />
\starttext<br />
\setupselector[caption][n=1]<br />
\completelistoffigures<br />
\setupselector[caption][n=2]<br />
\placefigure[][]<br />
{\select{caption}<br />
{Short caption for list}<br />
{A rather longer caption which will appear below the figure itself}}<br />
{This is the content of the actual figure}<br />
\stoptext<br />
</texcode><br />
<br />
= Float Combinations =<br />
<br />
If you want to place floats besides each other or in a regular matrix,<br />
each with its own number and caption, you need a float combination:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum] %% sample images<br />
<br />
\startplacefigure [location=none] % disable numbering of outer float<br />
\startfloatcombination [nx=2, ny=1] % two columns, one row<br />
\startplacefigure [title=Left]<br />
\externalfigure [dummy]<br />
\stopplacefigure<br />
\startplacefigure [title=Right]<br />
\externalfigure [dummy]<br />
\stopplacefigure<br />
\stopfloatcombination<br />
\stopplacefigure<br />
</context><br />
<br />
If you want only one number for the whole thing, you may use a regular combination within a float:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum] %% sample images<br />
<br />
\startplacefigure [title=My combination]<br />
\startcombination [nx=2, ny=1]<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption Left \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption Right \stopcaption<br />
\stopcombination<br />
\stopplacefigure<br />
</context><br />
<br />
<br />
See also {{cmd|startcombination}}, {{cmd|startfloatcombination}} and [[Combinations]].<br />
<br />
= Subfloats =<br />
Subfloatnumbering creates subfigures sharing a mutual figure prefix and an<br />
individual subfigure designator (e.g. figure 1a), figure 1b, etc.). The command {{cmd|startsubfloatnumbering}} is used for this.<br />
<br />
<context source=yes><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
\startTEXpage [offset=5mm]<br />
<br />
\startsubfloatnumbering<br />
\startplacefigure [title=Alpha]<br />
\externalfigure<br />
\stopplacefigure<br />
<br />
\startplacefigure [title=Beta]<br />
\externalfigure<br />
\stopplacefigure<br />
\stopsubfloatnumbering<br />
<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
Subfloats can also be used with floatcombinations:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
\startTEXpage [offset=5mm]<br />
<br />
\startplacefigure [location=none]<br />
\startsubfloatnumbering<br />
\startfloatcombination [nx=2, ny=1]<br />
\startplacefigure [title=Left, reference=fig:left] \externalfigure \stopplacefigure<br />
\startplacefigure [title=Right, reference=fig:right] \externalfigure \stopplacefigure<br />
\stopfloatcombination<br />
\stopsubfloatnumbering<br />
\stopplacefigure<br />
<br />
See \in{figure}[fig:left] and \in{figure}[fig:right].<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
See also {{cmd|startcombination}}, {{cmd|startfloatcombination}}, [[Combinations]] and {{cmd|startsubfloatcombination}}.<br />
<br />
= Flushing floats =<br />
<br />
The command {{cmd|placefloats}} outputs all pending floats.<br />
<br />
[[Category:Basics]]<br />
[[Category:Layout]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Combinations&diff=33247Combinations2021-11-28T15:08:45Z<p>Marco: Add section about floatcombinations</p>
<hr />
<div>Combinations are ConTeXt's way to align several pictures (preferrably at same size):<br />
<br />
== Combinations ==<br />
<br />
<texcode><br />
\startcombination[x*y] %% x=columns, y=rows<br />
{something}{caption} ...<br />
...<br />
\stopcombination<br />
</texcode><br />
<br />
or using the newer interface:<br />
<br />
<texcode><br />
\startcombination [nx=3, ny=2] %% 3 columns, 2 rows<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\stopcombination<br />
<br />
</texcode><br />
<br />
means:<br />
<br />
You define, how much figures in columns * rows you'd like to align.<br />
<br />
You must provide one "figure something" (e.g. an {{cmd|externalfigure}}) and a caption for every "cell".<br />
<br />
The sample, from the manual, shows how to define a caption for the whole group and use it as float (see [[Floating Objects]]):<br />
<br />
<context source=yes><br />
\useMPlibrary [dum] %% sample images<br />
<br />
\startplacefigure [title=An example of a combination]<br />
\startcombination [nx=3, ny=2]<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption a \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption b \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption c \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption d \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption e \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption f \stopcaption<br />
\stopcombination<br />
\stopplacefigure<br />
</context><br />
<br />
== Floatcombinations ==<br />
<br />
When combination contain floats, the command {{cmd|startfloatcombination}} is used. Here an example using float combinations as well as subfloatnumbering that creates subfigures sharing a mutual figure prefix and an individual subfigure designator (e.g. figure 1a), figure 1b, etc.).<br />
<br />
<context source=yes><br />
\useMPlibrary [dum] %% sample images<br />
<br />
\startplacefigure [location=none]<br />
\startsubfloatnumbering<br />
\startfloatcombination [nx=2, ny=1]<br />
\startplacefigure [title=Left, reference=fig:left] \externalfigure \stopplacefigure<br />
\startplacefigure [title=Right, reference=fig:right] \externalfigure \stopplacefigure<br />
\stopfloatcombination<br />
\stopsubfloatnumbering<br />
\stopplacefigure<br />
<br />
See \in{figure}[fig:left] and \in{figure}[fig:right].<br />
</context><br />
<br />
== Setup ==<br />
<br />
There is {{cmd|setupcombinations}} command.<br />
<br />
== Referencing ==<br />
<br />
To reference a subfigure you can provide the subfigure's caption as a second parameter to the {{cmd|in}} command.<br />
<br />
To reference the subfigure with the caption d you would write:<br />
<br />
<texcode><br />
\in{figure}{d}[fig:combinations]<br />
</texcode><br />
<br />
This would produce something like 'figure 2.4d'. The content of the second parameter simply gets appended to the end of the figure's reference-number, thus the example above would still work even if the caption would be 'd) An awesome subfigure'.<br />
<br />
== See also ==<br />
[[Floating_Objects#Subfloats]], {{cmd|startfloatcombination}}, {{cmd|startsubfloatnumbering}}<br />
<br />
[[Category:Graphics]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Combinations&diff=33246Combinations2021-11-28T15:03:41Z<p>Marco: Update code syntax</p>
<hr />
<div>Combinations are ConTeXt's way to align several pictures (preferrably at same size):<br />
<br />
<texcode><br />
\startcombination[x*y] %% x=columns, y=rows<br />
{something}{caption} ...<br />
...<br />
\stopcombination<br />
</texcode><br />
<br />
or using the newer interface:<br />
<br />
<texcode><br />
\startcombination [nx=3, ny=2] %% 3 columns, 2 rows<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\startcontent something \stopcontent<br />
\startcaption caption \stopcaption<br />
\stopcombination<br />
<br />
</texcode><br />
<br />
means:<br />
<br />
You define, how much figures in columns * rows you'd like to align.<br />
<br />
You must provide one "figure something" (e.g. an {{cmd|externalfigure}}) and a caption for every "cell".<br />
<br />
The sample, from the manual, shows how to define a caption for the whole group and use it as float (see [[Floating Objects]]):<br />
<br />
<context source=yes><br />
\useMPlibrary [dum] %% sample images<br />
<br />
\startplacefigure [title=An example of a combination]<br />
\startcombination [nx=3, ny=2]<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption a \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption b \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption c \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption d \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption e \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption f \stopcaption<br />
\stopcombination<br />
\stopplacefigure<br />
</context><br />
<br />
== Setup ==<br />
<br />
There is {{cmd|setupcombinations}} command.<br />
<br />
== Referencing ==<br />
<br />
To reference a subfigure you can provide the subfigure's caption as a second parameter to the {{cmd|in}} command.<br />
<br />
To reference the subfigure with the caption d you would write:<br />
<br />
<texcode><br />
\in{figure}{d}[fig:combinations]<br />
</texcode><br />
<br />
This would produce something like 'figure 2.4d'. The content of the second parameter simply gets appended to the end of the figure's reference-number, thus the example above would still work even if the caption would be 'd) An awesome subfigure'.<br />
<br />
== See also ==<br />
[[Floating_Objects#Subfloats]], {{cmd|startfloatcombination}}, {{cmd|startsubfloatnumbering}}<br />
<br />
[[Category:Graphics]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Floating_Objects&diff=33245Floating Objects2021-11-28T14:50:09Z<p>Marco: Add section about subfloats</p>
<hr />
<div>= Introduction =<br />
<br />
Floating Objects (floats) are placed (and numbered) automatically, with a configurable (and optional) caption. They are placed at an appropriate position determined by the TeX float placement algorithm. The algorithm has a number of options that can influence float placement.<br />
<br />
Most options in the manual (such as {{cmd|placeexternalfigure}}) are described using the generic {{cmd|placefloat}}. Additionally, {{cmd|placelistoffigures}} creates a list of the figures used in the document.<br />
<br />
Floats include "graphic", "figure", "table", and "intermezzo". Additional floats can be defined using {{cmd|definefloat}}.<br />
<br />
<texcode><br />
\placefloat[place][reference]{caption}{some float}<br />
</texcode><br />
<br />
'''place''' is one or several (comma separated) of:<br />
<table><br />
<tr bgcolor="#AAAAAA"><th>preference</th><th align="left">result</th></tr><br />
<tr bgcolor="#DDDDDD"><td>left</td><td>left of text</td></tr><br />
<tr><td>right</td><td>right of text</td></tr><br />
<tr bgcolor="#DDDDDD"><td>here</td><td>preferably here</td></tr><br />
<tr><td>top</td><td>at top of page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>bottom</td><td>at bottom of page</td></tr><br />
<tr><td>inleft</td><td>in left margin</td></tr><br />
<tr bgcolor="#DDDDDD"><td>inright</td><td>in right margin</td></tr><br />
<tr><td>inmargin</td><td>in the margin (left or right)</td></tr><br />
<tr bgcolor="#DDDDDD"><td>margin</td><td>in the margin (margin float)</td></tr><br />
<tr><td>page</td><td>on a new (empty) page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>opposite</td><td>on the left page</td></tr><br />
<tr><td>90</td><td>orientation (rotation angle), both caption and contents</td></tr><br />
<tr bgcolor="#DDDDDD"><td>always</td><td>precedence over stored floats</td></tr><br />
<tr><td>force</td><td>per se here</td></tr><br />
<tr bgcolor="#DDDDDD"><td>split</td><td>(For TABLES only) split tables</td></tr><br />
</table><br />
(table copied from the manual)<br />
<br />
{{cmd|placefigure}} and {{cmd|placetable}} also accept the same set of options, and allow to create floating figures and captions respectively.<br />
<br />
'''reference'''<br />
<br />
If you don't need to refer to your float, you can leave this parameter out.<br />
<br />
= Examples =<br />
I will explain the examples in terms of {{cmd|placefigure}} but the same set of options are also valid for other floats.<br />
<br />
* If you do not want a caption<br />
<br />
<texcode><br />
\placefigure[none] {} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
<br />
* If you do not want the figure to be numbered (but still want the caption)<br />
<br />
<texcode><br />
\placefigure [nonumber] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
* Suppose you want the figure to be placed on the right side of the page, a few lines into the paragraph, and want the rest of the paragraph to wrap around the figure<br />
<br />
<texcode><br />
\placefigure [right,2*line] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
or <br />
<br />
<texcode><br />
\placefigure [right,2*hang] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
This does not work correctly at a page boundary. The <tt>line</tt> option leaves the space above the figures empty, while the <tt>hang</tt> option also wraps texts above the figure.<br />
<br />
=Floats and columns=<br />
<br />
This special case is discussed [[Columns#Floats_and_other_limitations_of_columns|here]].<br />
<br />
=Floats on empty pages=<br />
<br />
There’s a way to switch off page headings at full page floats:<br />
<br />
<texcode><br />
\startplacefigure[title=Cow,location={page,high,header}]<br />
\externalfigure[cow.pdf]<br />
\stopplacefigure<br />
</texcode><br />
<br />
=Protruding Floats in Double-Sided Documents=<br />
<br />
If you have a double-sided document with wide outer margins then you might want your figures to protrude into the margin. In a double-sided document you need to tell ConTeXt to decide whether to make the figure protrude to the left or the right. This can be done as follows:<br />
<br />
<texcode><br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\placetextmarginfigure{\externalfigure[figurename]}<br />
</texcode><br />
<br />
The following code gives a full example that can be pasted into live ConTeXt:<br />
<br />
<texcode><br />
\setuppagenumbering [alternative=doublesided]<br />
\setuplayout[location=middle,backspace=2pc, width=20pc]<br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\starttext<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\stoptext<br />
</texcode><br />
<br />
=Landscape Floats in a Portrait Document=<br />
<br />
Wide tables, for example, can be turned and most likely will need to be put on a separate page.<br />
<texcode><br />
\startplacetable [location={page,90},title=Table caption]<br />
\bTABLE [textwidth=\textheight]<br />
put a wide table here...<br />
\eTABLE<br />
\stopplacetable<br />
</texcode><br />
Both the table caption and the contents will be rotated, but not the page header and footer which remain "upright". Notice that one must set the TABLE textwidth to {{cmd|textheight}} in order for the table macros to fit properly.<br />
<br />
= Floats and section headings =<br />
<br />
By default, section headings don't wrap “around” floating objects. Instead, they will be moved down as far as needed to appear below the float. This behaviour can be controlled using the <tt>aligntitle</tt> option of the {{cmd|setupheads}} or {{cmd|setuphead}} commands.<br />
<br />
= Captions =<br />
<br />
To change the style of figure(table) captions, use {{cmd|setupcaptions}}.<br />
<br />
To use a different (e.g. abbreviated) caption in the list of floats, you can do:<br />
<br />
<texcode><br />
\startplacefigure[title={A rather long caption},list={A short caption}]<br />
This is the content of the actual figure<br />
\stopplacefigure<br />
</texcode><br />
<br />
In MkII this was possible by:<br />
<br />
<texcode><br />
\defineselector[caption][max=2,n=2]<br />
\starttext<br />
\setupselector[caption][n=1]<br />
\completelistoffigures<br />
\setupselector[caption][n=2]<br />
\placefigure[][]<br />
{\select{caption}<br />
{Short caption for list}<br />
{A rather longer caption which will appear below the figure itself}}<br />
{This is the content of the actual figure}<br />
\stoptext<br />
</texcode><br />
<br />
= Float Combinations =<br />
<br />
If you want to place floats besides each other or in a regular matrix,<br />
each with its own number and caption, you need a float combination:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
<br />
\startTEXpage [offset=5mm]<br />
<br />
\startplacefigure [location=none] % disable numbering of outer float<br />
\startfloatcombination [nx=2, ny=1] % two columns, one row<br />
\startplacefigure [title=Left]<br />
\externalfigure [dummy]<br />
\stopplacefigure<br />
\startplacefigure [title=Right]<br />
\externalfigure [dummy]<br />
\stopplacefigure<br />
\stopfloatcombination<br />
\stopplacefigure<br />
<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
If you want only one number for the whole thing, you may use a regular combination within a float:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
\startTEXpage [offset=5mm]<br />
<br />
\startplacefigure [title=My combination]<br />
\startcombination [nx=2, ny=1]<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption Left \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption Right \stopcaption<br />
\stopcombination<br />
\stopplacefigure<br />
<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
See also {{cmd|startcombination}}, {{cmd|startfloatcombination}} and [[Combinations]].<br />
<br />
= Subfloats =<br />
Subfloatnumbering creates subfigures sharing a mutual figure prefix and an<br />
individual subfigure designator (e.g. figure 1a), figure 1b, etc.). The command {{cmd|startsubfloatnumbering}} is used for this.<br />
<br />
<context source=yes><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
\startTEXpage [offset=5mm]<br />
<br />
\startsubfloatnumbering<br />
\startplacefigure [title=Alpha]<br />
\externalfigure<br />
\stopplacefigure<br />
<br />
\startplacefigure [title=Beta]<br />
\externalfigure<br />
\stopplacefigure<br />
\stopsubfloatnumbering<br />
<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
Subfloats can also be used with floatcombinations:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
\startTEXpage [offset=5mm]<br />
<br />
\startplacefigure [location=none]<br />
\startsubfloatnumbering<br />
\startfloatcombination [nx=2, ny=1]<br />
\startplacefigure [title=Left, reference=fig:left] \externalfigure \stopplacefigure<br />
\startplacefigure [title=Right, reference=fig:right] \externalfigure \stopplacefigure<br />
\stopfloatcombination<br />
\stopsubfloatnumbering<br />
\stopplacefigure<br />
<br />
See \in{figure}[fig:left] and \in{figure}[fig:right].<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
See also {{cmd|startcombination}}, {{cmd|startfloatcombination}}, [[Combinations]] and {{cmd|startsubfloatcombination}}.<br />
<br />
= Flushing floats =<br />
<br />
The command {{cmd|placefloats}} outputs all pending floats.<br />
<br />
[[Category:Basics]]<br />
[[Category:Layout]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Floating_Objects&diff=33244Floating Objects2021-11-28T14:42:18Z<p>Marco: Add link to Combinations</p>
<hr />
<div>= Introduction =<br />
<br />
Floating Objects (floats) are placed (and numbered) automatically, with a configurable (and optional) caption. They are placed at an appropriate position determined by the TeX float placement algorithm. The algorithm has a number of options that can influence float placement.<br />
<br />
Most options in the manual (such as {{cmd|placeexternalfigure}}) are described using the generic {{cmd|placefloat}}. Additionally, {{cmd|placelistoffigures}} creates a list of the figures used in the document.<br />
<br />
Floats include "graphic", "figure", "table", and "intermezzo". Additional floats can be defined using {{cmd|definefloat}}.<br />
<br />
<texcode><br />
\placefloat[place][reference]{caption}{some float}<br />
</texcode><br />
<br />
'''place''' is one or several (comma separated) of:<br />
<table><br />
<tr bgcolor="#AAAAAA"><th>preference</th><th align="left">result</th></tr><br />
<tr bgcolor="#DDDDDD"><td>left</td><td>left of text</td></tr><br />
<tr><td>right</td><td>right of text</td></tr><br />
<tr bgcolor="#DDDDDD"><td>here</td><td>preferably here</td></tr><br />
<tr><td>top</td><td>at top of page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>bottom</td><td>at bottom of page</td></tr><br />
<tr><td>inleft</td><td>in left margin</td></tr><br />
<tr bgcolor="#DDDDDD"><td>inright</td><td>in right margin</td></tr><br />
<tr><td>inmargin</td><td>in the margin (left or right)</td></tr><br />
<tr bgcolor="#DDDDDD"><td>margin</td><td>in the margin (margin float)</td></tr><br />
<tr><td>page</td><td>on a new (empty) page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>opposite</td><td>on the left page</td></tr><br />
<tr><td>90</td><td>orientation (rotation angle), both caption and contents</td></tr><br />
<tr bgcolor="#DDDDDD"><td>always</td><td>precedence over stored floats</td></tr><br />
<tr><td>force</td><td>per se here</td></tr><br />
<tr bgcolor="#DDDDDD"><td>split</td><td>(For TABLES only) split tables</td></tr><br />
</table><br />
(table copied from the manual)<br />
<br />
{{cmd|placefigure}} and {{cmd|placetable}} also accept the same set of options, and allow to create floating figures and captions respectively.<br />
<br />
'''reference'''<br />
<br />
If you don't need to refer to your float, you can leave this parameter out.<br />
<br />
= Examples =<br />
I will explain the examples in terms of {{cmd|placefigure}} but the same set of options are also valid for other floats.<br />
<br />
* If you do not want a caption<br />
<br />
<texcode><br />
\placefigure[none] {} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
<br />
* If you do not want the figure to be numbered (but still want the caption)<br />
<br />
<texcode><br />
\placefigure [nonumber] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
* Suppose you want the figure to be placed on the right side of the page, a few lines into the paragraph, and want the rest of the paragraph to wrap around the figure<br />
<br />
<texcode><br />
\placefigure [right,2*line] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
or <br />
<br />
<texcode><br />
\placefigure [right,2*hang] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
This does not work correctly at a page boundary. The <tt>line</tt> option leaves the space above the figures empty, while the <tt>hang</tt> option also wraps texts above the figure.<br />
<br />
=Floats and columns=<br />
<br />
This special case is discussed [[Columns#Floats_and_other_limitations_of_columns|here]].<br />
<br />
=Floats on empty pages=<br />
<br />
There’s a way to switch off page headings at full page floats:<br />
<br />
<texcode><br />
\startplacefigure[title=Cow,location={page,high,header}]<br />
\externalfigure[cow.pdf]<br />
\stopplacefigure<br />
</texcode><br />
<br />
=Protruding Floats in Double-Sided Documents=<br />
<br />
If you have a double-sided document with wide outer margins then you might want your figures to protrude into the margin. In a double-sided document you need to tell ConTeXt to decide whether to make the figure protrude to the left or the right. This can be done as follows:<br />
<br />
<texcode><br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\placetextmarginfigure{\externalfigure[figurename]}<br />
</texcode><br />
<br />
The following code gives a full example that can be pasted into live ConTeXt:<br />
<br />
<texcode><br />
\setuppagenumbering [alternative=doublesided]<br />
\setuplayout[location=middle,backspace=2pc, width=20pc]<br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\starttext<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\stoptext<br />
</texcode><br />
<br />
=Landscape Floats in a Portrait Document=<br />
<br />
Wide tables, for example, can be turned and most likely will need to be put on a separate page.<br />
<texcode><br />
\startplacetable [location={page,90},title=Table caption]<br />
\bTABLE [textwidth=\textheight]<br />
put a wide table here...<br />
\eTABLE<br />
\stopplacetable<br />
</texcode><br />
Both the table caption and the contents will be rotated, but not the page header and footer which remain "upright". Notice that one must set the TABLE textwidth to {{cmd|textheight}} in order for the table macros to fit properly.<br />
<br />
= Floats and section headings =<br />
<br />
By default, section headings don't wrap “around” floating objects. Instead, they will be moved down as far as needed to appear below the float. This behaviour can be controlled using the <tt>aligntitle</tt> option of the {{cmd|setupheads}} or {{cmd|setuphead}} commands.<br />
<br />
= Captions =<br />
<br />
To change the style of figure(table) captions, use {{cmd|setupcaptions}}.<br />
<br />
To use a different (e.g. abbreviated) caption in the list of floats, you can do:<br />
<br />
<texcode><br />
\startplacefigure[title={A rather long caption},list={A short caption}]<br />
This is the content of the actual figure<br />
\stopplacefigure<br />
</texcode><br />
<br />
In MkII this was possible by:<br />
<br />
<texcode><br />
\defineselector[caption][max=2,n=2]<br />
\starttext<br />
\setupselector[caption][n=1]<br />
\completelistoffigures<br />
\setupselector[caption][n=2]<br />
\placefigure[][]<br />
{\select{caption}<br />
{Short caption for list}<br />
{A rather longer caption which will appear below the figure itself}}<br />
{This is the content of the actual figure}<br />
\stoptext<br />
</texcode><br />
<br />
= Float Combinations =<br />
<br />
If you want to place floats besides each other or in a regular matrix,<br />
each with its own number and caption, you need a float combination:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
<br />
\startTEXpage [offset=5mm]<br />
<br />
\startplacefigure [location=none] % disable numbering of outer float<br />
\startfloatcombination [nx=2, ny=1] % two columns, one row<br />
\startplacefigure [title=Left]<br />
\externalfigure [dummy]<br />
\stopplacefigure<br />
\startplacefigure [title=Right]<br />
\externalfigure [dummy]<br />
\stopplacefigure<br />
\stopfloatcombination<br />
\stopplacefigure<br />
<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
If you want only one number for the whole thing, you may use a regular combination within a float:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
\startTEXpage [offset=5mm]<br />
<br />
\startplacefigure [title=My combination]<br />
\startcombination [nx=2, ny=1]<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption Left \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption Right \stopcaption<br />
\stopcombination<br />
\stopplacefigure<br />
<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
See also {{cmd|startcombination}}, {{cmd|startfloatcombination}}, [[Combinations]] and {{cmd|startsubfloatcombination}}.<br />
<br />
= Flushing floats =<br />
<br />
The command {{cmd|placefloats}} outputs all pending floats.<br />
<br />
[[Category:Basics]]<br />
[[Category:Layout]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Floating_Objects&diff=33243Floating Objects2021-11-28T14:37:16Z<p>Marco: Update code syntax</p>
<hr />
<div>= Introduction =<br />
<br />
Floating Objects (floats) are placed (and numbered) automatically, with a configurable (and optional) caption. They are placed at an appropriate position determined by the TeX float placement algorithm. The algorithm has a number of options that can influence float placement.<br />
<br />
Most options in the manual (such as {{cmd|placeexternalfigure}}) are described using the generic {{cmd|placefloat}}. Additionally, {{cmd|placelistoffigures}} creates a list of the figures used in the document.<br />
<br />
Floats include "graphic", "figure", "table", and "intermezzo". Additional floats can be defined using {{cmd|definefloat}}.<br />
<br />
<texcode><br />
\placefloat[place][reference]{caption}{some float}<br />
</texcode><br />
<br />
'''place''' is one or several (comma separated) of:<br />
<table><br />
<tr bgcolor="#AAAAAA"><th>preference</th><th align="left">result</th></tr><br />
<tr bgcolor="#DDDDDD"><td>left</td><td>left of text</td></tr><br />
<tr><td>right</td><td>right of text</td></tr><br />
<tr bgcolor="#DDDDDD"><td>here</td><td>preferably here</td></tr><br />
<tr><td>top</td><td>at top of page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>bottom</td><td>at bottom of page</td></tr><br />
<tr><td>inleft</td><td>in left margin</td></tr><br />
<tr bgcolor="#DDDDDD"><td>inright</td><td>in right margin</td></tr><br />
<tr><td>inmargin</td><td>in the margin (left or right)</td></tr><br />
<tr bgcolor="#DDDDDD"><td>margin</td><td>in the margin (margin float)</td></tr><br />
<tr><td>page</td><td>on a new (empty) page</td></tr><br />
<tr bgcolor="#DDDDDD"><td>opposite</td><td>on the left page</td></tr><br />
<tr><td>90</td><td>orientation (rotation angle), both caption and contents</td></tr><br />
<tr bgcolor="#DDDDDD"><td>always</td><td>precedence over stored floats</td></tr><br />
<tr><td>force</td><td>per se here</td></tr><br />
<tr bgcolor="#DDDDDD"><td>split</td><td>(For TABLES only) split tables</td></tr><br />
</table><br />
(table copied from the manual)<br />
<br />
{{cmd|placefigure}} and {{cmd|placetable}} also accept the same set of options, and allow to create floating figures and captions respectively.<br />
<br />
'''reference'''<br />
<br />
If you don't need to refer to your float, you can leave this parameter out.<br />
<br />
= Examples =<br />
I will explain the examples in terms of {{cmd|placefigure}} but the same set of options are also valid for other floats.<br />
<br />
* If you do not want a caption<br />
<br />
<texcode><br />
\placefigure[none] {} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
<br />
* If you do not want the figure to be numbered (but still want the caption)<br />
<br />
<texcode><br />
\placefigure [nonumber] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
* Suppose you want the figure to be placed on the right side of the page, a few lines into the paragraph, and want the rest of the paragraph to wrap around the figure<br />
<br />
<texcode><br />
\placefigure [right,2*line] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
or <br />
<br />
<texcode><br />
\placefigure [right,2*hang] {caption} {\externalfigure[figurename]}<br />
</texcode><br />
<br />
This does not work correctly at a page boundary. The <tt>line</tt> option leaves the space above the figures empty, while the <tt>hang</tt> option also wraps texts above the figure.<br />
<br />
=Floats and columns=<br />
<br />
This special case is discussed [[Columns#Floats_and_other_limitations_of_columns|here]].<br />
<br />
=Floats on empty pages=<br />
<br />
There’s a way to switch off page headings at full page floats:<br />
<br />
<texcode><br />
\startplacefigure[title=Cow,location={page,high,header}]<br />
\externalfigure[cow.pdf]<br />
\stopplacefigure<br />
</texcode><br />
<br />
=Protruding Floats in Double-Sided Documents=<br />
<br />
If you have a double-sided document with wide outer margins then you might want your figures to protrude into the margin. In a double-sided document you need to tell ConTeXt to decide whether to make the figure protrude to the left or the right. This can be done as follows:<br />
<br />
<texcode><br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\placetextmarginfigure{\externalfigure[figurename]}<br />
</texcode><br />
<br />
The following code gives a full example that can be pasted into live ConTeXt:<br />
<br />
<texcode><br />
\setuppagenumbering [alternative=doublesided]<br />
\setuplayout[location=middle,backspace=2pc, width=20pc]<br />
\definefloat[textmarginfigure][textmarginfigures]<br />
\setupfloat[textmarginfigure][location=inner]<br />
\starttext<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\placetextmarginfigure[here]{}{\externalfigure[figurename][width=30pc]}<br />
\input knuth<br />
\stoptext<br />
</texcode><br />
<br />
=Landscape Floats in a Portrait Document=<br />
<br />
Wide tables, for example, can be turned and most likely will need to be put on a separate page.<br />
<texcode><br />
\startplacetable [location={page,90},title=Table caption]<br />
\bTABLE [textwidth=\textheight]<br />
put a wide table here...<br />
\eTABLE<br />
\stopplacetable<br />
</texcode><br />
Both the table caption and the contents will be rotated, but not the page header and footer which remain "upright". Notice that one must set the TABLE textwidth to {{cmd|textheight}} in order for the table macros to fit properly.<br />
<br />
= Floats and section headings =<br />
<br />
By default, section headings don't wrap “around” floating objects. Instead, they will be moved down as far as needed to appear below the float. This behaviour can be controlled using the <tt>aligntitle</tt> option of the {{cmd|setupheads}} or {{cmd|setuphead}} commands.<br />
<br />
= Captions =<br />
<br />
To change the style of figure(table) captions, use {{cmd|setupcaptions}}.<br />
<br />
To use a different (e.g. abbreviated) caption in the list of floats, you can do:<br />
<br />
<texcode><br />
\startplacefigure[title={A rather long caption},list={A short caption}]<br />
This is the content of the actual figure<br />
\stopplacefigure<br />
</texcode><br />
<br />
In MkII this was possible by:<br />
<br />
<texcode><br />
\defineselector[caption][max=2,n=2]<br />
\starttext<br />
\setupselector[caption][n=1]<br />
\completelistoffigures<br />
\setupselector[caption][n=2]<br />
\placefigure[][]<br />
{\select{caption}<br />
{Short caption for list}<br />
{A rather longer caption which will appear below the figure itself}}<br />
{This is the content of the actual figure}<br />
\stoptext<br />
</texcode><br />
<br />
= Float Combinations =<br />
<br />
If you want to place floats besides each other or in a regular matrix,<br />
each with its own number and caption, you need a float combination:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
<br />
\startTEXpage [offset=5mm]<br />
<br />
\startplacefigure [location=none] % disable numbering of outer float<br />
\startfloatcombination [nx=2, ny=1] % two columns, one row<br />
\startplacefigure [title=Left]<br />
\externalfigure [dummy]<br />
\stopplacefigure<br />
\startplacefigure [title=Right]<br />
\externalfigure [dummy]<br />
\stopplacefigure<br />
\stopfloatcombination<br />
\stopplacefigure<br />
<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
If you want only one number for the whole thing, you may use a regular combination within a float:<br />
<br />
<context source=yes><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
\startTEXpage [offset=5mm]<br />
<br />
\startplacefigure [title=My combination]<br />
\startcombination [nx=2, ny=1]<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption Left \stopcaption<br />
\startcontent \externalfigure [dummy] \stopcontent<br />
\startcaption Right \stopcaption<br />
\stopcombination<br />
\stopplacefigure<br />
<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
See also {{cmd|startcombination}}, {{cmd|startfloatcombination}} and {{cmd|startsubfloatcombination}}.<br />
<br />
= Flushing floats =<br />
<br />
The command {{cmd|placefloats}} outputs all pending floats.<br />
<br />
[[Category:Basics]]<br />
[[Category:Layout]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/startfloatcombination&diff=33242Command/startfloatcombination2021-11-28T13:56:55Z<p>Marco: Initial version</p>
<hr />
<div><cd:commandgroup name="floatcombination" type="environment" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"><br />
<cd:shortdesc>A number of float objects arranged in a matrix.</cd:shortdesc><br />
<cd:variants><br />
<cd:command category="tables" file="pack-com.mkiv" interfacedate="2020-07-14T09:24" interfacefile="i-combination.xml" keywords="float" level="document" name="floatcombination" type="environment" variantnumber="1"><br />
<cd:arguments><br />
<cd:assignments list="yes" optional="yes" ordinal="1"><br />
<cd:assignmentsdoc></cd:assignmentsdoc><br />
<cd:inherit name="setupcombination"></cd:inherit><br />
</cd:assignments><br />
</cd:arguments><br />
</cd:command><br />
<cd:command category="tables" file="pack-com.mkiv" interfacedate="2020-07-14T09:24" interfacefile="i-combination.xml" keywords="float" level="document" name="floatcombination" type="environment" variant="matrix" variantnumber="2"><br />
<cd:arguments><br />
<cd:keywords optional="yes" ordinal="1"><br />
<cd:keywordsdoc></cd:keywordsdoc><br />
<cd:constant type="cd:matrix"></cd:constant><br />
<cd:constant type="cd:name"></cd:constant><br />
</cd:keywords><br />
</cd:arguments><br />
</cd:command><br />
</cd:variants><br />
<cd:description>A floatcombination is a number of float objects arranged in a matrix, with an optional caption below each object. It is used for nested floats.</cd:description><br />
<cd:examples><cd:example title="A simple float combination"><texcode><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
<br />
\startplacefigure [location=none]<br />
\startfloatcombination [nx=2, ny=1]<br />
\startplacefigure [title=Left, reference=fig:left] \externalfigure \stopplacefigure<br />
\startplacefigure [title=Right, reference=fig:right] \externalfigure \stopplacefigure<br />
\stopfloatcombination<br />
\stopplacefigure<br />
<br />
See \in{figure}[fig:left] and \in{figure}[fig:right].<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\useMPlibrary [dum]<br />
<br />
\starttext<br />
<br />
\startTEXpage [offset=5mm]<br />
\startplacefigure [location=none]<br />
\startfloatcombination [nx=2, ny=1]<br />
\startplacefigure [title=Left, reference=fig:left] \externalfigure \stopplacefigure<br />
\startplacefigure [title=Right, reference=fig:right] \externalfigure \stopplacefigure<br />
\stopfloatcombination<br />
\stopplacefigure<br />
<br />
See \in{figure}[fig:left] and \in{figure}[fig:right].<br />
\stopTEXpage<br />
<br />
\stoptext<br />
</context></cd:example></cd:examples><br />
<cd:notes></cd:notes><br />
<cd:seealso><br />
<cd:commandref name="definecombination" originator="system"></cd:commandref><br />
<cd:commandref name="setupcombination" originator="system"></cd:commandref><br />
<cd:source file="pack-com.mkiv" originator="system"></cd:source><br />
<cd:wikipage originator="system" page="Category:Tables"></cd:wikipage><br />
<cd:wikipage originator="system" page="Keywords:Float"></cd:wikipage><br />
<cd:wikipage page="Combinations"></cd:wikipage><br />
<cd:wikipage page="Floating_Objects"></cd:wikipage><br />
<cd:commandref name="startsubfloatnumbering"></cd:commandref></cd:seealso><br />
</cd:commandgroup></div>Marcohttps://wiki.contextgarden.net/index.php?title=Titles&diff=32314Titles2021-01-07T10:27:22Z<p>Marco: Change \definestructureresetset to \defineresetset</p>
<hr />
<div>==Default==<br />
<br />
Titles define the structure of your document. Decide yourself, how deep you want to nest them:<br />
<br />
{| class=wikitable<br />
! Numbered !! Unnumbered<br />
|- <br />
| {{cmd|part}} || &#151;<br />
|-<br />
| {{cmd|chapter}} || {{cmd|title}}<br />
|-<br />
| {{cmd|section}} || {{cmd|subject}}<br />
|-<br />
| {{cmd|subsection}} || {{cmd|subsubject}}<br />
|-<br />
| {{cmd|subsubsection}} || {{cmd|subsubsubject}}<br />
|-<br />
| ... || ...<br />
|}<br />
<br />
The unnumbered versions don't appear in a table of contents! To change that, see the section on [[#Unnumbered_titles_in_table_of_contents|Unnumbered titles in the table of contents]].<br />
<br />
Also note that in the front matter of the document, all titles are unnumbered by default. The titles from the 'numbered' category still show up in the table of contents, though, and the titles from the 'unnumbered' category still don't.<br />
<br />
===Referencing Titles===<br />
<br />
Every heading command can take an optional parameter as reference:<br />
<br />
<texcode><br />
\title[hasselt-by-night]{Hasselt by night}<br />
</texcode><br />
<br />
The bracket pair is optional and used for internal [[References]]. If you want<br />
to refer to this header you type for example<br />
<br />
<texcode><br />
\at{page}[hasselt-by-night].<br />
</texcode><br />
<br />
See {{cmd|at}}.<br />
<br />
Note that reference labels are limited to ASCII characters in traditional TeX.<br />
This limitation has been removed in ConTeXt mkiv.<br />
<br />
==New MkIV Sectioning==<br />
<br />
ConTeXt MkIV adds several new commands which supersede the older {{cmd|chapter}}, {{cmd|section}} etc. The new commands are more verbose, but also more flexible, and allow better support for tagged-PDF, XML and ePUB output.<br />
<br />
{| class=wikitable<br />
! Traditional !! New<br />
|-<br />
| {{cmd|part}} || {{cmd|startpart}}<br />
|- <br />
| {{cmd|chapter}} || {{cmd|startchapter}}<br />
|-<br />
| {{cmd|section}} || {{cmd|startsection}}<br />
|-<br />
| {{cmd|subsection}} || {{cmd|startsubsection}}<br />
|-<br />
| {{cmd|subsubsection}} || {{cmd|startsubsubsection}}<br />
|-<br />
| {{cmd|title}} || {{cmd|starttitle}}<br />
|-<br />
| {{cmd|subject}} || {{cmd|startsubject}}<br />
|-<br />
| ... || ...<br />
|}<br />
<br />
Each of these start-commands has a corresponding stop-command which should be used at the end of the section. For example:<br />
<br />
<context mode=mkiv source=yes text=produces><br />
% mode=mkiv<br />
\setuppapersize[A5]<br />
<br />
\section[sec:old]{Old Section}<br />
<br />
This is an old-style \ConTeXt\ section.<br />
<br />
\startsection<br />
[<br />
title={New Section},<br />
reference=sec:new,<br />
]<br />
<br />
This is a new-style section.<br />
\stopsection<br />
</context><br />
<br />
The following keys are available for the start-commands:<br />
<br />
{| class=wikitable<br />
! Key !! Description<br />
|-<br />
| reference= || The reference key for cross-referencing (with {{cmd|at}}, {{cmd|in}} etc.)<br />
|-<br />
| title= || The title of the section<br />
|-<br />
| list= || The title to show in the table of contents, if different<br />
|-<br />
| bookmark= || The title to show in the PDF bookmarks, if different<br />
|-<br />
| marking= || The title to use in the section marking, if different<br />
|-<br />
| label= || ?<br />
|}<br />
<br />
It is also possible to set per-section variables, and retrieve them with the {{cmd|structureuservariable}} command:<br />
<br />
<context mode=mkiv source=yes text=produces><br />
% mode=mkiv<br />
\setuppapersize[A5]<br />
<br />
\startchapter[title={Foo Bar}][foo=bar]<br />
<br />
foo is \quote{\structureuservariable{foo}}<br />
<br />
\stopchapter<br />
<br />
</context><br />
<br />
==Titling Style==<br />
<br />
see {{cmd|setuphead}} and some enhanced samples below.<br />
<br />
A FAQ is, how to get a line under the pageheader:<br />
<br />
<texcode><br />
\setupheader[after=\hrule]<br />
</texcode><br />
<br />
To make the section numbers appear as characters, do<br />
<br />
<texcode><br />
\setupsection[section-3][bodypartconversion=Character]<br />
</texcode><br />
<br />
The <code>section-3</code> corresponds to <code>section</code>. Similarly,<br />
<code>section-1</code> corresponds to <code>part</code>, <code>section-2</code><br />
corresponds to <code>chapter</code> and so on.<br />
<br />
==Titling Alignment==<br />
<br />
Titles should often be left aligned without hyphenation. Try this:<br />
<br />
<texcode><br />
\setuphead[chapter][align={flushleft, nothyphenated, verytolerant}]<br />
</texcode><br />
<br />
==Using colors in chapters and sections==<br />
<br />
If you want you may have colors on your document's chapters or sections.<br />
To do that you should use {{cmd|setuphead}}. Take a look at the following<br />
example:<br />
<br />
<texcode><br />
\setupcolors[state=start] % Important. You won't have colors without it.<br />
<br />
\setuphead[chapter][header=empty] % Chapter pages won't have headers<br />
<br />
\setupheadertexts[][chapter] % The header will be the chapter's name<br />
<br />
\starttext<br />
<br />
\completecontent<br />
<br />
\chapter{Black chapter 1}<br />
<br />
\setuphead[section][color=darkcyan] % This is how you change your chapter's color.<br />
<br />
\section{Dark cyan section 1.1}<br />
<br />
\page<br />
Test.<br />
<br />
\setuphead[chapter][color=darkgreen]<br />
<br />
\chapter{Dark green chapter}<br />
<br />
\page<br />
Test.<br />
<br />
\setuphead[chapter][color=red]<br />
<br />
\chapter{Red chapter}<br />
<br />
\page<br />
Test.<br />
<br />
\stoptext <br />
</texcode><br />
<br />
==Your Own Titling Levels==<br />
<br />
Of course you can define your own titling commands and probably must adapt the default settings.<br />
<br />
<texcode><br />
\definehead[myheader][section]<br />
<br />
\setuphead<br />
[myheader]<br />
[numberstyle=bold,<br />
textstyle=cap,<br />
before=\hairline\blank,<br />
after=\nowhitespace\hairline]<br />
<br />
\myheader[hasselt-ref]{Hasselt makes headlines}<br />
</texcode><br />
<br />
A new header {{cmd|myheader}} is defined and it inherits the properties<br />
of {{cmd|section}} (title, subject, whatever). You can ''define'' several<br />
headers at once!<br />
<br />
==Formatting Titles with {{cmd|setuphead}}==<br />
<br />
The following parameters to {{cmd|setuphead}} change the style of<br />
the heading. <br />
<br />
{| class=wikitable<br />
|-<br />
! Text !! Number<br />
|-<br />
| textstyle<br />
| numberstyle<br />
|-<br />
| textcommand<br />
| numbercommand<br />
|-<br />
| deeptextcommand<br />
| deepnumbercommand<br />
|-<br />
|}<br />
<br />
Quite obviously, the number commands work on the chapter/section/etc. number,<br />
their text counterparts change the text itself. However, there are differences<br />
between <tt>style</tt>, <tt>command</tt> and <tt>deepcommand</tt>.<br />
<br />
The <tt>style</tt> variants accept a style (<tt>bold</tt>, <tt>cap</tt>, etc.)<br />
or a font switch ({{cmd|em}}, {{cmd|tfx}}, etc). <tt>textstyle</tt> prepends<br />
the text with the associated style. <tt>textcommand</tt> is a command name which<br />
is given the text (with all markup) as a parameter. <tt>deeptextcommand</tt> is<br />
similar to <tt>textcommand</tt> but it acts only on the text (not on the markup).<br />
<br />
So, if we have {{cmd|title|2={A story}}}, the different parameters have the following results:<br />
<br />
{|<br />
|- <br />
| textstyle=\em<br />
| =><br />
| \em A story<br />
|- <br />
| textstyle=\em, textcommand=\uppercase<br />
| =><br />
| \uppercase{\em A story}<br />
| =><br />
| \em A STORY<br />
|- <br />
| textstyle=\em, deeptextcommand=\uppercase<br />
| =><br />
| \em\uppercase{A story}<br />
| =><br />
| \em A STORY<br />
|-<br />
|}<br />
<br />
What is the difference between <tt>textcommand</tt> and <tt>deeptextcommand</tt>,<br />
then? With this example there is very little difference, as <tt>uppercase</tt><br />
knows how to handle markup. Sometimes this is not the case. For example, an almost<br />
similar command <tt>WORD</tt> is not compatible with <tt>textcommand</tt>, because<br />
it wreaks havoc with markup:<br />
<br />
{| <br />
|-<br />
| textstyle=\em, textcommand=\WORD<br />
| =><br />
| \WORD{\em A story}<br />
| =><br />
| \EM A STORY<br />
|-<br />
| textstyle=\em, deeptextcommand=\WORD<br />
| =><br />
| \em\WORD{A story}<br />
| =><br />
| \em A STORY<br />
|-<br />
|}<br />
<br />
In this case using <tt>deeptextcommand</tt> is the correct solution for capitalizing<br />
headers. (Using {{cmd|uppercase}} works in this specific case, but only if you stick<br />
to Latin 1 or Anglo-Saxon characters. Other languages will suffer from lowercase accented<br />
characters, like CAFé.)<br />
<br />
Use {{cmd|setuphead}}<tt>[part][conversion=Romannumerals]</tt>, for example, to employ an<br />
alternative numbering scheme.<br />
<br />
=== Truly empty pagebreak before chapters ===<br />
<br />
Using {{cmd|setuppagenumbering|2=[alternative=doublesided]}} makes the chapters start<br />
on the right page. However, the blank page is not truly empty, it contains headers and<br />
footers. To get truly empty pages, use the following<br />
<br />
<texcode><br />
\definepagebreak<br />
[mychapterpagebreak]<br />
[yes,header,right]<br />
%[yes,header,left]<br />
%[yes,header,footer,right]<br />
<br />
\setuphead<br />
[chapter]<br />
[page=mychapterpagebreak]<br />
%[page=Mychapterpagebreak,header=empty,footer=empty]<br />
<br />
%\setupsectionblock[frontpart][page=chapter]<br />
%\setupsectionblock[bodypart][page=chapter]<br />
%\setupsectionblock[backpart][page=chapter]<br />
%\setupsectionblock[appendix][page=chapter]<br />
<br />
\setuppagenumbering[alternative=doublesided,location={header,margin}]<br />
\setupheadertexts[{My special headertext}]<br />
\setupfootertexts[This is a text in the footer]<br />
%\setupbackgrounds[header][text][bottomframe=on]<br />
<br />
\starttext<br />
\chapter{testA} \dorecurse{10}{\input tufte }<br />
\chapter{testB} \dorecurse{10}{\input tufte }<br />
\chapter{testC} \dorecurse{10}{\input tufte }<br />
\stoptext<br />
</texcode><br />
<br />
'''Explanation''' (provided by Willi Egger on the mailing list)<br />
<br />
* You define a new pagebreak rule. It has the name <code>mychapterpagebreak</code>. The options set read as: <code>pagebreak=yes</code>, placeheader, use a right page.<br />
* You set options for the header of type chapter and use for the option page the afore defined new pagebreak.<br />
* You might want to experiment with the commented lines and see what happens. For example, the {{cmd|setupsectionblock}} commands will give a truly blank page (if needed) after the specified {{code|1=stop*part}} command.<br />
<br />
==== When using front, body, back matters and appendices ====<br />
<br />
As Wolfgang explained on the mailing list, when using {{code|1=*frontmatter}}, {{code|1=*bodymatter}}, {{code|1=*backmatter}} and {{code|1=*appendices}}, you need to remove the page they create to get the page before a new chapter or part with no headers and footers.<br />
<br />
<texcode><br />
\setupsectionblock[frontpart][page=]<br />
\setupsectionblock[bodypart] [page=]<br />
\setupsectionblock[backpart] [page=]<br />
\setupsectionblock[appendix] [page=]<br />
\definepagebreak[firstpagebreak][yes,header,footer,right]<br />
\setuphead[chapter][page=firstpagebreak]<br />
\setuppagenumbering[alternative=doublesided]<br />
\starttext<br />
\startfrontmatter<br />
\chapter{front}<br />
\stopfrontmatter<br />
\startbodymatter<br />
\chapter{body}<br />
\stopbodymatter<br />
\startappendices<br />
\chapter{appendix}<br />
\stopappendices<br />
\startbackmatter<br />
\chapter{back}<br />
\stopbackmatter<br />
\stoptext<br />
</texcode><br />
== Independent Section Numbering ==<br />
<br />
If you want section numbering to be independent of chapter numbering, use<br />
<br />
<texcode><br />
\setuphead [chapter][resetnumber=no]<br />
\setupsection[section][previousnumber=no]<br />
</texcode><br />
<br />
This is handled differently in mkiv (where "resetnumber=no" is silently ignored):<br />
<br />
<texcode><br />
\defineresetset[default][1,1,0][1] % reset part, chapter, but not section<br />
\setuphead[sectionresetset=default]<br />
</texcode><br />
<br />
==Unnumbered titles in table of contents==<br />
<br />
Sometimes one wants an unnumbered chapter, say introduction, the following might do that trick:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\definehead [intro] [chapter]<br />
\setuphead [intro] [number=no]<br />
<br />
\definecombinedlist [content][intro,chapter,section]<br />
\setuplist [intro] [headnumber=no]<br />
<br />
\starttext<br />
\completecontent<br />
\startfrontmatter<br />
\intro{No number}<br />
\stopfrontmatter<br />
<br />
\startbodymatter<br />
\chapter{Has number}<br />
\stopbodymatter<br />
\stoptext<br />
</context><br />
<br />
Note that just putting the introduction in the frontmatter already did the trick for me (on a recent MkIV).<br />
<br />
An alternative approach: <br />
<texcode><br />
\setuphead[title][<br />
incrementnumber=yes, % keep an internal title counter+list<br />
number=no] % don't display the counter<br />
<br />
% Manually specify the composition of the section and subsection<br />
% numbers, so subsection 1.1 in the second title won't appear as<br />
% Subsection 2.1.1<br />
\setuphead[section][sectionsegments=section]<br />
\setuphead[subsection][sectionsegments=section:subsection] <br />
<br />
% Redefine the toc list to include titles<br />
\definecombinedlist[content][title, section]<br />
</texcode><br />
<br />
== Complete Section Numbering ==<br />
<br />
You might have documents in which your sections don’t follow the structure, such as in:<br />
<br />
<texcode><br />
\section{A}<br />
%\subsection{B}<br />
\subsubsection{C}<br />
</texcode><br />
<br />
In that case, you would get <code>1 A</code> <code>1 C</code>. To enable complete section numbering, you would need in this case (using a beta after 2017.08.07 11:30):<br />
<br />
<texcode><br />
\setuphead[subsection][criterium=all]<br />
</texcode><br />
<br />
==Your Own Title Styles==<br />
<br />
Sometimes the possibilities of {{cmd|setuphead}} aren't enough. You can define<br />
your own styling commands, as shown in the following examples.<br />
<br />
===Start the title in the margin===<br />
<br />
This very simple example shows how to start a title within the margin, rather than at the text's edge<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\setuphead[chapter][alternative=margin]<br />
<br />
\chapter{Sample chapter}<br />
<br />
Number is in margin, not at text edge.<br />
</context><br />
<br />
===Chapter titles in new line===<br />
To have the chapter title simply in a new line a new command needs to be defined that takes care of this. It needs to be wrapped in {{cmd|framed}}.<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\setuplabeltext [en] [chapter=Chapter~]<br />
\define[2]\MyChapter<br />
{\framed[frame=off,width=broad,align=flushleft]{#1\\#2}}<br />
\setuphead [chapter] [command=\MyChapter]<br />
\chapter{Foo Bar}<br />
</context><br />
<br />
===Expanded chapter titles===<br />
<br />
This example illustrates expanded chapter titles.<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\define[2]\MyChapterCommand%<br />
{\framed[frame=off,bottomframe=on,topframe=on]<br />
{\vbox{\headtext{chapter} #1\blank#2}}}<br />
<br />
\setuphead[chapter][command=\MyChapterCommand, style={\ss\bfa}]<br />
\setupheadtext[chapter=Chapter]<br />
<br />
\chapter{My First Chapter}<br />
</context><br />
<br />
===Exercise numbers===<br />
<br />
For a textbook, suppose that you collect the exercises in a section at the end<br />
of each chapter, with each exercise a subsection having a short title, and the<br />
exercises should be numbered only by the subsection (not 1.6.7 for example,<br />
just 7). The usage:<br />
<br />
<texcode><br />
\section{Exercises}<br />
<br />
\exercise{Batteries}<br />
What is the cost of energy from a 9V battery? From a wall socket (the mains)?<br />
</texcode><br />
<br />
The setup code:<br />
<texcode><br />
\definehead[exercise][subsection]<br />
<br />
\setuphead<br />
[exercise]<br />
[style=italic, <br />
numbercommand={\determineheadnumber[subsection]\currentheadnumber\gobbleoneargument}]<br />
</texcode><br />
<br />
===A complex graphical element under the chapter title===<br />
<br />
<context source=yes><br />
\setuppapersize[A6]<br />
\setupcolors[state=start]<br />
\startuseMPgraphic{HeaderDeco}<br />
numeric w, h, repeats;<br />
path p[];<br />
w := OverlayWidth ; h := OverlayHeight ;<br />
repeats := abs(TextWidth/BodyFontSize);<br />
p[1] := unitsquare xscaled w yscaled h ;<br />
draw p[1] withcolor white;<br />
p[2] := fullcircle scaled BodyFontSize;<br />
p[3] := fullcircle scaled .25BodyFontSize;<br />
draw p[2] shifted (.5BodyFontSize,0);<br />
for i = 1 upto repeats:<br />
if odd i :<br />
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
else :<br />
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);<br />
fi;<br />
endfor;<br />
\stopuseMPgraphic<br />
<br />
\setuphead[chapter][command=\Myheader]<br />
\setupheadtext<br />
[chapter=Chapitre]<br />
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]<br />
<br />
\define[2]\Myheader{%<br />
\framedtext<br />
[width= \overlaywidth,<br />
height=6\bodyfontsize,<br />
background={foreground,HeaderDeco},<br />
offset=0pt,<br />
strut=no,<br />
frame=off,<br />
align=middle]{%<br />
\headtext{chapter} #1<br />
\blank[small]<br />
#2}}<br />
<br />
\starttext<br />
\chapter{Here we go!}<br />
\stoptext<br />
</context><br />
<br />
===Title page with special background===<br />
<br />
If you want the title page of every chapter to have a special background (different from the background of normal pages), here's a very effective trick that Hans has provided on the mailing list. In addition, this will give every chapter its own color scheme (Mkiv only, hence won't compile on contextgarden): <br />
<br />
<context source=yes><br />
\startMPinclusions<br />
numeric MyTitlePageDone[] ;<br />
\stopMPinclusions<br />
<br />
\startuseMPgraphic{background:normal}<br />
StartPage ;<br />
fill (topboundary Page -- cycle) enlarged(0,5mm) <br />
shifted (0,-5mm) withcolor blue ;<br />
StopPage ;<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay<br />
[background:normal]<br />
[\useMPgraphic{background:normal}]<br />
<br />
\startuseMPgraphic{background:title}<br />
if unknown MyTitlePageDone.\namedstructureuservariable{chapter}{mycolor} :<br />
StartPage ;<br />
fill ((topboundary Page --cycle) enlarged(0,5mm)) shifted (0,-20mm)<br />
withcolor \MPcolor{color:title:\namedstructureuservariable{chapter}{mycolor}} ;<br />
StopPage ;<br />
MyTitlePageDone.\namedstructureuservariable{chapter}{mycolor} := 1 ;<br />
fi ;<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay<br />
[background:title]<br />
[\useMPgraphic{background:title}]<br />
<br />
\setupbackgrounds<br />
[page]<br />
[background={background:normal,background:title}]<br />
<br />
\definecolor [color:title:one] [red]<br />
\definecolor [color:title:two] [blue]<br />
<br />
\starttext<br />
<br />
\startchapter[title=One][mycolor=one] \input tufte \page \input knuth \stopchapter<br />
\startchapter[title=Two][mycolor=two] \input tufte \page \input knuth \stopchapter<br />
<br />
\stoptext<br />
<br />
</context><br />
<br />
===Titles in margin===<br />
<br />
It is sometimes wanted to place the title of a section/subject etc in the margin next to the section text (instead of above it).<br />
This is achieved by the following setup:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\setuphead<br />
[subject]<br />
[alternative=text,distance=0pt,command=\MyHead,style=\sc]<br />
<br />
\define[2]\MyHead{\inmargin{#1 #2}}<br />
<br />
\starttext<br />
<br />
\subject{First Subject}<br />
\input weisman<br />
<br />
\subject{Second Subject}<br />
\input ward<br />
<br />
\stoptext<br />
</context><br />
<br />
See [http://www.ntg.nl/pipermail/ntg-context/2003/002053.html the mailing list thread] for more on this.<br />
<br />
===Headings numbered independent of chapters or other headings===<br />
<br />
If you want a heading that gets numbered without resetting at new sections or chapters (for example, for problems whose numbers increment throughout a book), here is a solution due to Hans [http://archive.contextgarden.net/message/20030415.153451.374310d8.en.html on the mailing list]:<br />
<br />
<texcode><br />
% use a lower level head<br />
<br />
\definehead<br />
[Problem]<br />
[subsubsubsection]<br />
<br />
% cleaned up<br />
<br />
\setuphead<br />
[Problem]<br />
[style=\ss\bf,<br />
color=red,<br />
before=\blank]<br />
<br />
% use a label text<br />
<br />
\setuplabeltext<br />
[Problem=Problem ]<br />
<br />
% use your own numbers<br />
<br />
\setuphead<br />
[Problem]<br />
[ownnumber=yes]<br />
<br />
% increment and feed<br />
<br />
\newcounter\ProblemNumber<br />
<br />
\def\problem#1%<br />
{\doglobal\increment\ProblemNumber<br />
\Problem{\ProblemNumber}{#1}}<br />
<br />
% nicer here<br />
<br />
\setuplist<br />
[Problem]<br />
[alternative=c,<br />
criterium=all,<br />
width=2em,<br />
interaction=all]<br />
<br />
% the test<br />
<br />
\starttext<br />
<br />
List of Problems<br />
<br />
\blank[big] \placelist[Problem] \blank[big]<br />
<br />
\section{Tufte}<br />
<br />
\input tufte<br />
<br />
\problem{First problem}<br />
<br />
The first problem description.<br />
<br />
\section{Another Tufte}<br />
<br />
\input tufte<br />
<br />
\problem{Second problem}<br />
<br />
Second problem description.<br />
<br />
\stoptext<br />
</texcode><br />
<br />
===Chapter headers===<br />
<br />
This is an example of chapter headings with an enlarged shadow behind them, based on [http://archive.contextgarden.net/message/20041020.100630.d531bb1d.en.html 20/10/2004 a solution by Hans].<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\useencoding[ffr]<br />
\mainlanguage[fr]<br />
<br />
\setupcolors[state=start]<br />
<br />
\definefont[BigFontOne][Regular sa 3] %RegularSlanted sa 3(ori)%Sans sa 3:don't work (pb accents)<br />
\definefont[BigFontTwo][RegularBold sa 2] %%RegularSlanted<br />
<br />
\definecolor[BigColorOne][r=.86,g=.850,b=.54]<br />
\definecolor[BigColorTwo][r=.43,g=.425,b=.27]<br />
<br />
\setuphead<br />
[chapter]<br />
[textcommand=\MyChapterText,<br />
color=BigColorTwo,<br />
style=\BigFontTwo]<br />
<br />
\def\MyChapterText#1{\rlap{\BigFontOne\BigColorOne#1}\kern15pt#1}<br />
<br />
\starttext<br />
<br />
\chapter[chap:ques]{Question}<br />
<br />
\stoptext<br />
</context><br />
<br />
===Figures in Headings===<br />
<br />
This example shows how to completely replace the chapter text and number by an image:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\setupexternalfigures[location=default] % needed only for the wiki to the find the figure<br />
<br />
\useexternalfigure[section-1][cow][width=5cm,height=1cm]<br />
\useexternalfigure[section-2][mill.png][width=5cm,height=1cm]<br />
<br />
\setuphead<br />
[section]<br />
[command=\MySectionCommand]<br />
\setuphead<br />
[subsection]<br />
[command=]<br />
<br />
\define[2]\MySectionCommand%<br />
{\externalfigure[section-\currentheadnumber]}<br />
<br />
\starttext<br />
<br />
\section{One}<br />
\subsection{First subsection of Section One}<br />
\section{Two}<br />
<br />
\stoptext<br />
</context><br />
<br />
There are a few snags though. MkII "forgets" to put the chapter in the<br />
TOC. So you have to set the <tt>deeptextcommand</tt> and<br />
<tt>deepnumbercommand</tt> separately instead (thus retaining the<br />
command that puts the chapter in the TOC), rather than setting the<br />
overall <tt>command</tt>, if you need a complete TOC.<br />
<br />
<texcode><br />
\setuphead<br />
[chapter]<br />
[deeptextcommand=\MyChapterTextCommand,<br />
deepnumbercommand=\gobbleoneargument] % hide chapter number<br />
<br />
\def\MyChapterTextCommand#1%<br />
{\externalfigure[chapter-\currentheadnumber][height=5cm]}<br />
</texcode><br />
<br />
[http://archive.contextgarden.net/message/20050519.215526.df7c5cd1.html]<br />
<br />
Users of MkIV can safely rely on <tt>command</tt> and don't have to bother with the <tt>deep...command</tt> variants. However, {{cmd|currentheadnumber}} does not seem to return anything but 0. Thus, the following code is required to define <tt>\MyChapterCommand</tt> when using MkIV:<br />
<br />
<texcode><br />
\def\MyChapterCommand#1#2%<br />
{\externalfigure[chapter-\namedheadnumber{chapter}][height=5cm]}<br />
</texcode><br />
<br />
[http://archive.contextgarden.net/message/20100817.102859.206d858e.en.html]<br />
<br />
===Chapter head with absolute positioning of following text===<br />
<br />
No matter how many lines the chapter head runs to, the text will always start, e.g. 4cm below the top of the heading:<br />
<br />
<context source=yes><br />
\setuppapersize[A6][A6]<br />
\setupbodyfont[8pt]<br />
\def\MyChapterCommand#1#2%<br />
{\vbox to 4cm\bgroup<br />
{#1\hskip.75em #2}<br />
\vss<br />
\egroup}<br />
\setuphead[chapter][header=nomarking, command=\MyChapterCommand]<br />
\starttext<br />
\chapter{test} \input tufte<br />
\stoptext<br />
</context><br />
<br />
===Section head with underlining to width of last line===<br />
<br />
A style called for section headings to be followed by a rule which extends only the width of the text. More tricky was the need to make sure that if the text ran onto another line, it was the length of the ''last'' line that was to be followed. <br />
<br />
Hans came up with this cleverness, showing two alternate ways of doing it:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
% ---- First solution ----<br />
<br />
\def\FirstSolution#1#2%<br />
{\vbox\bgroup<br />
\setbox0\hbox{#1}<br />
\hsize.4\textwidth<br />
\beginshapebox#2\endshapebox<br />
\gdef\SetLastLineWidth{\xdef\LastLineWidth{\the\wd\scratchbox}}%<br />
\reshapebox<br />
{\setbox\scratchbox\hbox{\unhbox\shapebox}%<br />
\SetLastLineWidth<br />
\globallet\SetLastLineWidth\relax<br />
\box\scratchbox}%<br />
\scratchdimen\dimexpr\wd0+.25em+\LastLineWidth\relax<br />
% \setbox2\ruledvbox {\innerflushshapebox} <br />
% why is correction needed<br />
\setbox2\vbox {\vskip-\lineskip\innerflushshapebox}<br />
\setbox0\vbox to \ht2{\box0}<br />
\hbox{\box0\hskip.25em\box2}<br />
\offinterlineskip<br />
\vskip.25ex<br />
\blackrule[width=\scratchdimen,height=1pt]<br />
\egroup}<br />
<br />
% ---- Second solution ----<br />
<br />
\doglobal\newcounter\NextLinePos<br />
<br />
\def\SecondSolution#1#2%<br />
{\vbox\bgroup<br />
\hsize.4\textwidth<br />
\doglobal\increment\NextLinePos<br />
\setbox\scratchbox\hbox{#1}<br />
\hbox{\vtop{\copy\scratchbox}\hskip.25em\vtop{#2}}%<br />
\offinterlineskip<br />
\scratchdimen\dimexpr\wd\scratchbox+.25em+<br />
\MPx{e:npl:\NextLinePos}-\MPx{b:npl:\NextLinePos}\relax<br />
\vskip.25ex<br />
\blackrule[width=\scratchdimen,height=1pt]<br />
\egroup}<br />
<br />
\def\DoSecondSolution#1%<br />
{\bpos{npl:\NextLinePos}#1\epos{npl:\NextLinePos}}<br />
<br />
% ---- Trying it out solution ----<br />
<br />
% \showstruts<br />
<br />
\starttext<br />
\setuphead[section][command=\FirstSolution]<br />
\section{is this nice or not}<br />
\section{is this nice or not nice, that's the question}<br />
<br />
\setuphead[section][command=\SecondSolution,deeptextcommand=\DoSecondSolution]<br />
\section{is this nice or not}<br />
\section{is this nice or not nice, that's the question}<br />
\stoptext<br />
</context><br />
<br />
As if that wasn't enough, Taco pointed out that {{cmd|lastlinewidth}}<br />
is the easy route to finding the width of the last line. Use something like:<br />
<br />
<texcode><br />
\optimizedisplayspacingtrue\setlastlinewidth % core-mat macro<br />
\global\advance\lastlinewidth-\hangindent\par % adjust<br />
\blackrule[width=\lastlinewidth,height=1pt]<br />
</texcode><br />
<br />
=== Flushing section head data without typesetting them in the text ===<br />
<br />
The following is probably a very special case. Hoever suppose you need to place section information like the title e.g. in the topspace area. You want that the section is still displayed in the TOC, but you do not want that at the spot where {{cmd|startsection|2=[title=...,list=...]}} resides there is any trace of it. The command to be used to hide the section title is:<br />
<br />
<texcode><br />
\setuphead<br />
[section]<br />
[placehead=hidden] <br />
</texcode><br />
<br />
Be aware that with this setting indeed the section title is not shown and no white space is inserted. However in this way also the list entry for the TOC is gone. What you can do in such cases is to use the following command in connection with the above mentioned setting:<br />
<br />
<texcode><br />
\setuptexttexts[{\placerawheaddata[section]} <br />
</texcode><br />
<br />
What happens is that the information in the {{cmd|startsection|2=[title=...,list=...]}} command is passed to the texttexts, which are flushed at every page. In order to see when it is flushed you might place e.g. !!! in front of the {{cmd|placerawheaddata|2=[section]}}.<br />
<br />
The result is a complete TOC without any trace of the section heading in the text.<br />
<br />
'''Test:'''<br />
<br />
<texcode><br />
\setuphead<br />
[section]<br />
[placehead=hidden,<br />
page=yes]<br />
<br />
\setuphead<br />
[subsection]<br />
[placehead=yes,<br />
page=yes,<br />
continue=yes,<br />
style=\it]<br />
<br />
\setuptexttexts[{\placerawheaddata[section]}]<br />
<br />
\starttext<br />
<br />
\placelist[section,subsection] \page<br />
<br />
\startsection[title=First section]<br />
<br />
\startsubsection[title=First subsection]<br />
Lorem ipsum \dots<br />
\stopsubsection<br />
<br />
\startsubsection[title=second subsection]<br />
Lorem ipsum \dots<br />
\stopsubsection<br />
<br />
\stopsection<br />
<br />
\startsection[title=Second section]<br />
<br />
\startsubsection[title=First subsection]<br />
Lorem ipsum \dots<br />
\stopsubsection<br />
<br />
\stopsection<br />
<br />
\stoptext<br />
</texcode> <br />
<br />
===Section head without chapter number ===<br />
<br />
If you only want the section number (in mark IV) in the section title you add<br />
<br />
<br />
<br />
<texcode><br />
\setuphead[section][sectionsegments=section]<br />
\starttext<br />
\chapter{Eric}<br />
\section{Foo 1}<br />
\subsection{Bar one}<br />
\section{Foo 2}<br />
\stoptext<br />
</texcode><br />
<br />
But as once you changed one you have to change the lower ones.<br />
So you have to add the definition of sectionsegments in subsection, subsubsection, ...<br />
<br />
<texcode><br />
\setuphead[section][sectionsegments=section]<br />
\setuphead[subsection][sectionsegments=section:subsection]<br />
\setuphead[subsubsection][sectionsegments=section:subsubsection]<br />
<br />
\starttext<br />
\chapter{Eric}<br />
\section{Foo 1}<br />
\subsection{Bar one}<br />
\subsubsection{Barbar one }<br />
\subsubsection{Barbar two}<br />
\subsection{Bar two}<br />
\subsubsection{Barbar one}<br />
\subsubsection{Barbar two}<br />
\section{Foo 2}<br />
\subsection{Bar one}<br />
\subsubsection{Barbar one}<br />
\subsubsection{Barbar two}<br />
\stoptext<br />
</texcode><br />
<br />
It's not written here but you can also change the conversion of the numbering with <br />
<br />
<texcode><br />
\definestructureconversionset[mySet][A,R,n,n,a,r][n] <br />
\setuphead[chapter,section,subsection,subsubsection,subsubsubsection][sectionconversionset=mySet]<br />
</texcode><br />
<br />
The parameters in definestructureconversionset are<br />
<br />
the set name<br />
<br />
the codes for conversion (one for each level)<br />
<br />
the default conversion for the missing level<br />
<br />
You can find the conversions codes at [http://wiki.contextgarden.net/Conversions]<br />
<br />
===Editing Bold Math in Section Titles===<br />
<br />
When a section title is formatted in boldface text, this doesn't automatically typeset embedded math in bold. This is probably a good thing, as many math fonts do not include all characters in boldface, and often authors use boldface to distinguish between different meanings (for instance, scalar and vector variables). However, in some cases, it <i>is</i> desirable to format the math in the section titles in boldface.<br />
<br />
Here a very simple example:<br />
<texcode><br />
\definetypeface[boldmath][mm][boldmath][latin-modern][default]<br />
\setuphead[section][style=\boldmath\rm\bfa]<br />
\starttext<br />
\section{Bold $a^2+b^2=c^2$ {\em bla}}<br />
text: not bold $a^2+b^2=c^2$ {\em bla}<br />
\stoptext<br />
</texcode><br />
<br />
<context><br />
\definetypeface[boldmath][mm][boldmath][latin-modern][default]<br />
\setuphead[section][style=\boldmath\rm\bfa]<br />
\starttext<br />
\section{Bold $a^2+b^2=c^2$ {\em bla}}<br />
text: not bold $a^2+b^2=c^2$ {\em bla}<br />
\stoptext<br />
</context><br />
<br />
[[Category:Basics]]<br />
[[Category:Fonts]]<br />
[[Category:Graphics]]<br />
[[Category:Math]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/_starttabulate&diff=31162Command/ starttabulate2020-08-29T20:28:26Z<p>Marco: Replace tilde with \unit command and fix typo</p>
<hr />
<div><cd:commandgroup generated="yes" name="tabulate" type="environment" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"><br />
<cd:shortdesc><!-- a short command summary goes here --><br />
The instances of <tt>\start<i>tabulate</i> ... \stop<i>tabulate</i></tt> are used for special tabulated material.<br />
</cd:shortdesc><br />
<cd:sequence><br />
<cd:instance value="tabulate"></cd:instance><br />
</cd:sequence><br />
<cd:instances><br />
<cd:constant value="legend"></cd:constant><br />
<cd:constant value="fact"></cd:constant><br />
</cd:instances><br />
<cd:variants><br />
<cd:command category="tables" file="tabl-tbl.mkiv" generated="yes" interfacedate="2020-07-14T09:24" interfacefile="i-tabulation.xml" level="document" name="tabulate" type="environment" variant="instance" variantnumber="1"><br />
<cd:arguments><br />
<cd:keywords 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" optional="yes" ordinal="2"><br />
<cd:assignmentsdoc></cd:assignmentsdoc><br />
<cd:inherit name="setuptabulate"></cd:inherit><br />
</cd:assignments><br />
</cd:arguments><br />
</cd:command><br />
</cd:variants><br />
<cd:description></cd:description><br />
<cd:examples><cd:example title="Legends"><context source="yes"><br />
\startlegend<br />
\leg Lemma\\Symbol\\Word\\<br />
\leg Dilemma\\Prince\\Foo bar baz\\<br />
\stoplegend<br />
</context><br />
<br />
</cd:example><cd:example title="Facts">Complementary to legends is a command that displays facts in a consistent way when<br />
formulae are used for calculations.<br />
<br />
<context source="yes"><br />
\startfact<br />
\fact velocity \\ v \\ \unit{10 m/s} \\<br />
\fact acceleration \\ a \\ \unit{-3 m/s^2} \\<br />
\fact time \\ t \\ \unit{3 s} \\<br />
\stopfact<br />
</context><br />
<br />
The two last columns are in mathematical mode, the last column displays text in the<br />
normal font.<br />
</cd:example></cd:examples><br />
<cd:notes></cd:notes><br />
<cd:seealso><br />
<cd:commandref name="definetabulate" originator="system"></cd:commandref><br />
<cd:commandref name="setuptabulate" originator="system"></cd:commandref><br />
<cd:source file="tabl-tbl.mkiv" originator="system"></cd:source><br />
<cd:wikipage originator="system" page="Category:Tables"></cd:wikipage><br />
<cd:wikipage page="Tabulate"></cd:wikipage></cd:seealso><br />
</cd:commandgroup></div>Marcohttps://wiki.contextgarden.net/index.php?title=ConTeXt_Standalone&diff=22270ConTeXt Standalone2014-01-17T00:04:06Z<p>Marco: Add zip to list of depenencies</p>
<hr />
<div>The '''ConTeXt suite''' is a complete, up-to-date ConTeXt distribution that can be upgraded efficiently. It can also be used in parallel with existing TeX installations such as MikTeX, TeXLive, and so forth. The suite does not include LaTeX packages and binaries.<br />
<br />
Sometimes ConTeXt beta releases have issues. The ConTeXt suite allows you to test the latest ConTeXt release without worrying whether upgrading will corrupt a critical project. Multiple ConTeXt suite installations are possible. This allows, for example, a stable version and a beta version to run in parallel on the same computer.<br />
<br />
ConTeXt is also included in TeXlive. The ConTeXt suite is updated continuously, whereas ConTeXt in TeXlive is updated less often. In particular, <code>luatex</code> and <code>metapost</code> are under active development and their binaries are updated frequently. ConTeXt follows these developments, indeed often drives development. As the binaries included in the TeXlive distribution are only updated yearly, ConTeXt on TeXlive will necessarily be less current than the ConTeXt suite. (ConTeXt on TeXlive can be kept somewhat more current using the http://tlcontrib.metatex.org repository.) The ConTeXt suite is self-contained and can happily coexist alongside another installed TeX distribution.<br />
<br />
{{TOClimit|limit=1}}<br />
<br />
= General Information =<br />
<br />
== Supported platforms ==<br />
<br />
{| style="border:1px solid #DDDDDD;"<br />
|- align="left" <br />
! Platform<br />
! Short name<br />
! Binaries by<br />
! Notes<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Windows<br />
| mswin<br />
| Akira Kakuto ([http://w32tex.org W32TeX])<br />
|<br />
|- align="left"<br />
! Linux<br />
| linux<br />
| Hans Hagen, Mojca Miklavec, Alan Braslau<br />
| compiled with glibc 2.3.6<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Linux, 64-bit<br />
| linux-64<br />
| Alan Braslau<br />
|<br />
|- align="left"<br />
! Linux, PowerPC<br />
| linux-ppc<br />
| Piotr Kopszak<br />
|<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Linux, Arm (low end.)<br />
| linux-armel<br />
| Boris Veytsman<br />
| in progress<br />
|- align="left"<br />
! Mac OS X, Intel (32-bit)<br />
| osx-intel<br />
| Richard Koch, Mojca Miklavec<br />
|<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Mac OS X, Intel (64-bit)<br />
| osx-64<br />
| Richard Koch, Mojca Miklavec<br />
|<br />
|- align="left"<br />
! Mac OS X, PowerPC<br />
| osx-ppc<br />
| Richard Koch, Mojca Miklavec<br />
|<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Mac OS X, Universal Binaries<br />
| osx-universal<br />
| Richard Koch, Mojca Miklavec<br />
|<br />
|- align="left"<br />
! FreeBSD<br />
| freebsd<br />
| Alan Braslau<br />
|<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! FreeBSD, 64-bit<br />
| freebsd-amd64<br />
| Alan Braslau<br />
| <br />
|- align="left"<br />
! kFreeBSD<br />
| kfreebsd-i386<br />
| Alan Braslau<br />
| FreeBSD + glibc (Debian)<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! kFreeBSD, 64-bit<br />
| kfreebsd-amd64<br />
| Alan Braslau<br />
| FreeBSD + glibc (Debian)<br />
|- align="left"<br />
! Solaris, Intel<br />
| solaris-intel<br />
| Marco Patzer<br />
|<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Solaris, Sparc<br />
| solaris-sparc<br />
| Mojca Miklavec<br />
| Solaris 10 on [http://www.opencsw.org/about/ OpenCSW]<br />
|}<br />
<br />
We need volunteers for providing binaries for other platforms. If you want to support a platform, please write to [[ConTeXt Mailing Lists]]<br />
<br />
== Dependencies ==<br />
* [http://www.ruby-lang.org Ruby] 1.8 or newer (used for MKII)<br />
* Rsync (The windows binary of rsync is distributed within the suite)<br />
<br />
<br />
The following programs are not required for running ConTeXt, but their installation adds additional functionality.<br />
<br />
* ghostscript : for converting PostScript images to PDF<br />
* graphicsmagick : for converting GIF and TIFF images<br />
* inkscape : for converting SVG and compressed SVG<br />
* pstoedit : for converting PostScript to MetaPost outlines<br />
* zint : for providing barcodes<br />
* curl : for including remote content<br />
* zip or 7zip : for EPUB generation<br />
<br />
== Disc space required ==<br />
ConTeXt macro files are small (less than 10MB), but the suite comes with various free fonts which considerably increase the size of the distribution to around 200MB).<br />
<br />
== Standalone ==<br />
<br />
* [[ConTeXt Standalone/FAQ|Standalone/FAQ]] <br />
* [[ConTeXt Standalone/Structure|Standalone/Structure]] <br />
* [[ConTeXt Standalone/Implementation|Standalone/Implementation]]<br />
* [[ConTeXt Standalone/TODO|Standalone/TODO]] <br />
* [[ConTeXt Standalone/Contents|Standalone/Contents]] <br />
* [[ConTeXt Standalone/TeX Live|Standalone/TeX Live]]<br />
* Browse the [http://minimals.contextgarden.net installation tree]<br />
<br />
<br />
<br />
= Unix-like platforms (Linux/MacOS X/FreeBSD/Solaris) =<br />
<br />
For Mac installation see also [http://wiki.contextgarden.net/Mac_Installation Mac installation page].<br />
<br />
== Single user installation ==<br />
<br />
Select a folder where you want to install ConTeXt. We recommend that you can use your <code>$HOME/context</code> directory. Create this folder. Then download <br />
[http://minimals.contextgarden.net/setup/first-setup.sh first-setup.sh] and place it in <code>$HOME/context</code> directory. Open a terminal, then:<br />
<br />
cd context<br />
<br />
Then make <code>first-setup.sh</code> executable and run it to download the whole distribution and make formats:<br />
<br />
chmod +x first-setup.sh<br />
sh ./first-setup.sh<br />
<br />
This takes a long time, so go have a coffee.<br />
<br />
By default, the suite installs ConTeXt beta. If you want the stable version of ConTeXt, you can use<br />
<br />
sh ./first-setup.sh --context=current<br />
<br />
By default, the suite does ''not'' install modules and other third party content. If you want the modules (and have the bandwidth), you can use<br />
<br />
sh ./first-setup.sh --modules=all<br />
<br />
Installing mkiv only reduces the size of the installation (including all the modules) from about 270 to 200MB . Use<br />
<br />
sh ./first-setup.sh --modules=all --engine=luatex<br />
<br />
== System-wide installation ==<br />
<br />
A system wide installation is only recommended for users who are comfortable with the command line. Only the location of installing ConTeXt is different for a system wide installation.<br />
<br />
* on Linux you can use <code>/opt/context</code><br />
* on MacOS X you can use <code>/Applications/ConTeXt</code><br />
<br />
Note that, at present, while ''using'' MkIV, you need to have write permissions<ref>Actually, you only need write permission for <code>$TEXMFCACHE</code>.</ref> in the installation directory.<ref>This effectively means that only one user will be able to generate the formats</ref> So, if you are installing the suite in <code>/opt/context</code> or <code>/Applications/ConTeXt</code>, run<br />
<br />
<pre>chown `whoami` -R /opt/context</pre><br />
<br />
or <br />
<br />
<pre>chown `whoami` -R /Applications/ConTeXt</pre><br />
<br />
(<code>whoami</code> outputs your user name; you can type that directly, of course. The backticks substitute the output of the <code>whoami</code> command as an argument to <code>chown</code>.)<br />
<br />
In order to install the suite, open a terminal, go to the installation directory and download [http://minimals.contextgarden.net/setup/first-setup.sh first-setup.sh]:<br />
<br />
$ rsync -av rsync://contextgarden.net/minimals/setup/first-setup.sh .<br />
<br />
Then run that script to download the whole distribution and make formats:<br />
<br />
sh ./first-setup.sh<br />
<br />
This takes a long time, so go have a coffee.<br />
<br />
By default, the suite installs ConTeXt beta. If you want the stable version of ConTeXt, you can use<br />
<br />
sh ./first-setup.sh --context=current<br />
<br />
By default, the suite does ''not'' install modules and other third party content. If you want the modules (and have the bandwidth), you can use<br />
<br />
sh ./first-setup.sh --modules=all<br />
<br />
===Cache===<br />
<br />
Change the cache directory so ConTeXt can create temporary files as follows:<br />
<br />
mkdir -p /var/cache/context/texmf-cache<br />
chmod 777 /var/cache/context/texmf-cache<br />
<br />
Change the value of `TEXMFCACHE` in `./tex/texmf/web2c/texmfcnf.lua` to:<br />
<br />
/var/cache/context/texmf-cache<br />
<br />
===Font Directory===<br />
<br />
Add the OSOFONTDIR into ./tex/setuptex. Go to under the line:<br />
<br />
# TODO: we could set OSFONTDIR on Mac for example<br />
<br />
(if you don't have the line above, go to the end of the file) and add there:<br />
<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
<br />
For more information: [[Fonts in LuaTeX]]<br />
<br />
==Arch Linux==<br />
There’s a [http://aur.archlinux.org/packages.php?ID=30398 PKGBUILD] in<br />
the AUR, provided by Aditya [https://github.com/adityam/context-pkgbuild].<br />
Install it using your favorite AUR frontend, e.g.<br />
<br />
<pre><br />
yaourt -S context-minimals-git<br />
</pre><br />
<br />
This will get you a fresh, up-to-date Context tree in<br />
<tt>/opt/context-minimals</tt>.<br />
<br />
== The funtoo way ==<br />
<br />
If you are using [http://funtoo.org funtoo] there are ebuilds that will make an installation as easy as installing any other package from portage. Take a look at the [[ConTeXt Standalone Funtoo]] Howto. This might also work for [http://www.gentoo.org gentoo], but is untested right now.<br />
<br />
== Proxy settings ==<br />
<br />
The installation script uses <code>rsync</code> to fetch the required files. So, if you are behind a proxy server, you need to tell the details to rsync. The easiest way to set this is to set <code>RSYNC_PROXY</code> variable in the terminal or your startup script (<code>.bashrc</code> or the corresponding file for your shell). Replace username, password, proxyhost and proxyport with the correct information<br />
<br />
export RSYNC_PROXY=username:password@proxyhost:proxyport<br />
<br />
Sometimes, when behind a firewall, port 873 may be closed for outgoing TCP connections. If port 22 is open for ssh connections, a trick that can be used is to connect to a computer located somewhere outside of the firewall and to tunnel port 873 (using the program <code>nc</code>).<br />
<br />
export RSYNC_CONNECT_PROG='ssh tunnelhost nc %H 873'<br />
<br />
where <code>tunnelhost</code> is the machine outside of the firewall on which you have <code>ssh</code> access. Of course, this machine must have <code>nc</code> and port 873 open for outgoing TCP connections.<br />
<br />
== Usage ==<br />
<br />
ConTeXt suite works in a non-interfering manner because it does not put anything in your <code>$PATH</code> and does not set any system variables. This in turn means that in order to use it, you need to do some initialization. An intialization script called <code>setuptex</code> is provided in <code>installation-dir/tex/</code>. <br />
<br />
If you run context from a terminal, source <code>setuptex</code> like so:<br />
<br />
source /installation-dir/tex/setuptex<br />
<br />
== Exclusive usage ==<br />
<br />
The above method means that you always have to type <code>source /installation-dir/tex/setuptex</code> in a terminal before you can use typeset. If you always use ConTeXt suite and never use LaTeX or plain TeX provided by another TeX distribution, you can add the above intialization line to the startup script of your shell. For bash, this means <code>$HOME/.bashrc</code>; for zsh, this means <code>$HOME/.zshrc</code>; for (t)csh, this means <code>$HOME/.cshrc</code> or <code>$HOME/.tcshrc</code>. Then, <code>setuptex</code> will always be sourced in your terminal. <br />
<br />
== Integrating with an editor ==<br />
<br />
If you run ConTeXt from an editor, you need to source {{code|setuptex}} in a terminal and then open your editor from the same terminal. <br />
<br />
Depending on how your editor initializes, you may still need to source {{code|setuptex}} in order to run ConTeXt directly from your editor. In theory, it is sufficient to add {{code|/installation-dir/tex/texmf-<platform>/bin}} to your {{code|$PATH}} in order to use the suite. You can try to add this to the paths that your editor searches.<br />
<br />
For information about configuring [http://smultron.sourceforge.net/ Smultron] and [http://www.uoregon.edu/~koch/texshop/obtaining.html TeXShop] (which are popular TeX editors on Mac) see [[ConTeXt Standalone/Mac Installation]]. For a list of text editors with ConTeXt integration, see the article on [[Text Editors|text editors]].<br />
<br />
== Updating ==<br />
<br />
For updating the ConTeXt suite, <br />
first update <code>first-setup.sh</code>, then run it. You could<br />
also create an alias or a little script “ctx-update”<br />
with the following example contents:<br />
<pre><br />
cd /opt/context<br />
rsync -ptv rsync://contextgarden.net/minimals/setup/first-setup.sh .<br />
./first-setup.sh --modules=all<br />
</pre><br />
<br />
== Uninstalling ==<br />
<br />
ConTeXt suite does not touch anything outside its installation folder. So to uninstall it, you can simply remove the installation folder.<br />
<br />
== Remaking formats ==<br />
<br />
Normally, the update script should create the formats for you. If for some reason you need to recreate the formats, you can do the following:<br />
<br />
* For making MKII format.<br />
<br />
mktexlsr<br />
texexec --make --all <br />
<br />
* For making XeTeX format<br />
<br />
mktexlsr<br />
texexec --make --xtx --all <br />
<br />
* For making MKIV format<br />
<br />
mtxrun --selfupdate<br />
mtxrun --generate<br />
luatools --generate<br />
context --make<br />
<br />
= Windows =<br />
<br />
If you want to use ConTeXt suite alongside MikTeX/TeXLive (needed if you also run LaTeX), follow the command-line installation method. <br />
<br />
== Installation ==<br />
<br />
=== Command line method ===<br />
Download [http://minimals.contextgarden.net/setup/context-setup-mswin.zip context-setup-mswin.zip] or [http://minimals.contextgarden.net/setup/context-setup-win64.zip context-setup-win64.zip], and unzip to a directory where you want to install ConTeXt. It is recommended that you choose a directory that does not have a space in its full path. Then open <code>cmd.exe</code>, go to the installation directory and run<br />
<br />
first-setup.bat<br />
<br />
This takes a long time, so go have a coffee. <br />
<br />
By default, the suite installs ConTeXt beta. If you want the stable version of ConTeXt, you can use <br />
<br />
first-setup.bat --context=current<br />
<br />
By default, the suite does ''not'' install modules and other third party content. If you want the modules (and have the bandwidth), you can use<br />
<br />
first-setup.bat --modules=all<br />
<br />
<br />
If the above installation instructions don't seem to answer your questions, see page [[Windows_Installation:_ConTeXt_Suite_with_SciTe| Windows Installation: ConTeXt Suite with SciTe]] for more detailed information.<br />
<br />
<br />
== Proxy settings ==<br />
<br />
The installation script uses <code>rsync</code> to fetch the required files. So, if you are behind a proxy server, you need to tell the details to rsync. The easiest way to set this is to set <code>RSYNC_PROXY</code> variable in the terminal as (replace username, password, proxyhost and proxyport with the correct information)<br />
<br />
set RSYNC_PROXY=username:password@proxyhost:proxyport<br />
<br />
or set the variable permanently as a Windows environment variable.<br />
<br />
Sometimes, when behind a firewall, port 873 may be closed for outgoing TCP connections. If port 22 is open for ssh connections, a trick that can be used is to connect to a computer located somewhere outside of the firewall and to tunnel port 873 (using the program <code>nc</code>).<br />
<br />
export RSYNC_CONNECT_PROG='ssh tunnelhost nc %H 873'<br />
<br />
where <code>tunnelhost</code> is the machine outside of the firewall on which you have <code>ssh</code> access. Of course, this machine must have <code>nc</code> and port 873 open for outgoing TCP connections.<br />
<br />
== Usage ==<br />
<br />
Before running ConTeXt, you need to run <code>setuptex.bat</code> which is provided in <code>installation-dir\tex\</code>. This can be done by typing<br />
<br />
installation-dir\tex\setuptex.bat<br />
<br />
on cmd.exe before you run ConTeXt. To avoid always having to type this, you can create a shortcut to cmd.exe and edit the command line to read (assuming you installed the suite in <code>C:\Programs</code>; otherwise replace <code>C:\Programs\</code> with your installation directory)<br />
<br />
C:\WINDOWS\System32\cmd.exe /k C:\Programs\context\tex\setuptex.bat<br />
<br />
This starts up a new command shell with the environment pre-loaded. Within the new shell you can just type <code>context</code> to run ConTeXt. E.g.<br />
<br />
C:\> context --version<br />
<br />
to check that you are running the version you think you're running.<br />
<br />
=== Use ConTeXt with Cygwin ===<br />
After installing the ConTeXt suite, you can run it under Cygwin. With Cygwin, you may use gmake and other Unix tools for your automated workflow.<br />
<br />
# Run <code>setuptex.bat</code> in DOS command prompt<br />
# In the same DOS prompt, enter Cygwin by running <code>cygwin.bat</code> (in your Cygwin installation directory)<br />
# Under Cygwin prompt, run <code> context.cmd test.tex </code>. Note that the <code>.cmd</code> extension is needed under Cygwin.<br />
<br />
== Updating ==<br />
<br />
If you used the command line method, just run <code>first-setup.bat</code> again to update the suite. If you have third party modules installed, you should use<br />
first-setup.bat --keep<br />
to upgrade. See [[ConTeXt_Standalone#Installing_third_party_modules| Installing third party modules]] for details.<br />
<br />
<br />
== Uninstallation ==<br />
<br />
If you used the command-line installer, you can just delete the installation directory to uninstall the suite.<br />
<br />
<br />
== Troubleshooting ==<br />
<br />
* rsync sometimes has problems with paths with uppercase letters (like <code>c:\Temp</code> or <code>C:\Documents and Settings</code>). Installing into all-lowercase paths without spaces sometimes helps.<br />
* Directory-name length may also have an effect, due to Windows's 8.3 filename conventions. An indicator is if running "texexec --lua" on a file produces missing-file warnings containing Windows-created 8-character directory names, such as "C:\CONTEX~1\tex", where your ConTeXt directory is really "C:\context_minimals\tex". Be conservative and choose a short name like "C:\ctm\tex". Also, this may even work when an 8-character-or-less directory name like "C:\ctexmin\tex" doesn't.<br />
* If you're behind firewall and rsync times out, you need to open port 873 for outgoing TCP connections.<br />
* If you update luaTeX occasionally you may get something like <br />
<br />
<code>engine mismatch (luv: This is LuaTeX, Version beta-<version>-<date1> (TeX Live 2013/dev)(rev <number1>) <> bin: This is LuaTeX, Version beta-<version>-<date1> (TeX Live 2012/W32TeX)(rev <number2>)), forcing remake</code><br />
<br />
In which case your format will be remade every time you compile a file. In /texmf-mswin make sure that luatex.exe and texlua.exe have the same date; then also delete luatex.dll. This usually solves the problem.<br />
<br />
= Installing third party modules =<br />
<br />
The ConTeXt suite only comes with Taco's [[Bibliography|t-bib]] module. If you want to install [http://modules.contextgarden.net/ a new module], say Wolfgang's [[Letter|t-letter]] module, you can use<br />
first-setup.sh --modules="t-letter"<br />
<br />
If you want to install more than one extra module, you can separate them by commas. So, to install the t-letter and t-mathsets module, do<br />
sh ./first-setup.sh --modules="t-letter,t-mathsets"<br />
<br />
If you want to install all extra modules at once, do<br />
sh ./first-setup.sh --modules=all<br />
<br />
= Reverting to an older installation =<br />
<br />
If, for some reason, you want to revert to an older installation, you can do that by<br />
<br />
sh ./first-setup.sh --context=date<br />
<br />
where <code>date</code> is the date of one of the stable releases of ConTeXt. The complete list of old releases that are available is [http://minimals.contextgarden.net/current/context/ here].<br />
<br />
<br />
= Moving the installation tree around = <br />
<br />
According to this post, http://archive.contextgarden.net/message/20101129.144331.d721372f.en.html it's safe to move the installation tree across directory or machines (say you don't have broadband access). You just have to clean and regenerate the cache (./tex/texmf-cache/luatex-cache) with <br />
mtxrun --generate<br />
<br />
= Notes =<br />
<references/><br />
<br />
{{Installation navbox}}<br />
{{Getting started navbox}}<br />
[[Category:Installation]]<br />
[[Category:Standalone]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=MetaPost&diff=22042MetaPost2013-08-29T21:16:24Z<p>Marco: Add “Text in MetaPost” section</p>
<hr />
<div>< [[Math]], [[MetaFun]], [[Graphics]]<br />
<br />
MetaPost is a graphical programming language, based on Donald Knuth's MetaFont. Normally MP graphics are converted to PostScript and used with dvips, but ConTeXt can use it directly with PDF (see the<br />
[http://www.pragma-ade.com/general/sources/mptopdf.pdf MP to PDF] manual).<br />
<br />
MetaPost is ConTeXt's native graphics language. [[MetaFun]] is a MetaPost module by Hans Hagen that adds a lot of extra features; it is enabled by default, so one could say that MetaFun is ConTeXt's default dialect of MetaPost.<br />
<br />
== Documentation & Tutorials ==<br />
* [http://www.tug.org/docs/metapost/mpman.pdf A User's Manual for MetaPost] <!-- http://cm.bell-labs.com/who/hobby/cstr_162.pdf has its pages reversed --><br />
* [http://remote.science.uva.nl/~heck/Courses/mptut.pdf Learning METAPOST by doing] ([http://maps.aanhet.net/maps/pdf/32_14.pdf this] and [http://maps.aanhet.net/maps/pdf/32_15.pdf this link] are not working)<br />
* [http://www.tug.org/pracjourn/2006-4/henderson/henderson.pdf A Beginner's Guide to METAPOST for Creating High-Quality Graphics] by Troy Henderson<br />
* [[manual:metafun-s.pdf|MetaFun]]<br />
* [http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html Lots of examples]<br />
* [[Color in MetaPost]] describes how to get color mixtures, TeX colors, and transparent effects in MetaPost graphics.<br />
* [http://wiki.contextgarden.net/MetaPost_in_ConTeXt MetaPost in ConTeXt]<br />
<br />
== Using MetaPost in ConTeXt ==<br />
<br />
With {{cmd|startuseMPgraphic}}, you define a piece of graphics code that is processed anew every time the graphic is placed with {{cmd|useMPgraphic}}. Further commands are described at [[MetaPost in ConTeXt]].<br />
<br />
<context source=yes><br />
\def\mycolor{.625red}<br />
<br />
\startuseMPgraphic{name}<br />
fill fullcircle scaled 20pt withcolor \mycolor;<br />
\stopuseMPgraphic<br />
<br />
red: \useMPgraphic{name}<br />
<br />
\def\mycolor{.625blue}<br />
blue: \useMPgraphic{name}<br />
</context><br />
<br />
== Different Packages, Extensions & Applications of Metapost ==<br />
* [http://www.ctan.org/tex-archive/graphics/metaplot/ MetaPlot] - graph drawing<br />
* [http://www.ctan.org/tex-archive/graphics/metapost/contrib/macros/metaobj/ MetaObj] - object-oriented drawing, see also the page about [[MetaObj and Labels]]<br />
<br />
* [http://stud4.tuwien.ac.at/~e0225855/finomaton/finomaton.html finomaton] - drawing finite state automata<br />
* [http://www-math.univ-poitiers.fr/~phan/statsmac.html statsmac] - metapost macros for statistics graphs<br />
* [http://metauml.sourceforge.net/ MetaUML] - MetaPost library for typesetting UML diagrams<br />
* [http://vigna.dsi.unimi.it/metagraph/ METAGRAPH] - drawing (un)directed graphs<br />
<br />
=== 3D support ===<br />
* [http://matagalatlante.org/nobre/featpost/doc/featexamples.html FeatPost]<br />
* [http://www.gnu.org/software/3dldf/LDF.html 3DLDF]<br />
* [http://www-math.univ-poitiers.fr/~phan/m3Dplain.html m3D]<br />
<br />
{{todo|needs major review}}<br />
<br />
== MetaPost relatives ==<br />
=== Font Creation ===<br />
* [[MetaType1]], see [http://www.ctan.org/tex-archive/fonts/utilities/metatype1/ CTAN]<br />
<br />
=== 3D drawing ===<br />
* [http://asymptote.sourceforge.net/ Asymptote] - inspired by MetaPost & fully generalizes MetaPost path construction algorithms to three-dimensions<br />
<br />
== Testing plain MetaPost ==<br />
To test whether MetaPost is installed on your system, create a file called {{code|test.mp}}:<br />
<br />
beginfig(1)<br />
draw fullcircle scaled 3cm ;<br />
endfig ;<br />
end ;<br />
<br />
* apply MetaPost on the testfile<br />
<br />
mp test.mp<br />
or<br />
mpost test.mp<br />
<br />
* that should create a postscript file test.1<br />
* open test.1 with a postscript viewer like Ghostview, Okular, … You should see a circle.<br />
<br />
== Testing MetaPost embedded in ConTeXt ==<br />
<br />
If MetaPost is installed on your system and working correctly, you can <br />
<br />
\starttext<br />
\startMPcode<br />
draw fullcircle scaled 3cm;<br />
\stopMPcode<br />
\stoptext<br />
<br />
* for mkii you need to have write18 support enabled and run<br />
texexec --pdf test.tex<br />
<br />
* for mkiv run<br />
context test.tex<br />
<br />
* that should create a pdf file test.pdf<br />
* open test.pdf with a pdf viewer like Adobe Acrobat, Okular... You should see a circle.<br />
<br />
== Text in MetaPost ==<br />
<br />
Text that is typeset using `textext` or `btex … etex` adapts to the body font. However, when `label("Foo", pair)` or `"Foo" infont defaultfont` is used, which is not the recommended way, the text is typeset using the font `MetafunDefault`, which can be changed if desired. Example:<br />
<br />
<context mode="mkiv" source="yes" text="Gives:"><br />
\starttext<br />
\startMPcode<br />
label("Foo", origin);<br />
draw textext("Bar") yshifted -LineHeight;<br />
\stopMPcode<br />
<br />
\definefontsynonym<br />
[MetafunDefault]<br />
[Bold*default]<br />
<br />
\switchtobodyfont [pagella, 18pt]<br />
<br />
\startMPcode<br />
label("Foo", origin);<br />
draw textext("Foo") yshifted -LineHeight;<br />
\stopMPcode<br />
\stoptext<br />
</context><br />
<br />
The recommended way to typeset text is to use the `textext` macro and change the font using {{cmd |setupMPinstance}}.<br />
<br />
== Other Links ==<br />
<br />
* Metapost home page: http://tug.org/metapost<br />
* John Hobby's page: http://cm.bell-labs.com/who/hobby/MetaPost.html<br />
* Current development: http://foundry.supelec.fr/projects/metapost/<br />
* http://melusine.eu.org/syracuse/metapost/<br />
<br />
[[Category:Graphics]]<br />
[[Category:Metapost]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=starttexdefinition&diff=22041starttexdefinition2013-08-26T23:10:34Z<p>Marco: Create page</p>
<hr />
<div>{{Reference<br />
|name=starttexdefinition<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\starttexdefinition<br />
<span class="first" style="color:red;"> ... </span><span class="second"> ... </span><span class="third"> ... </span><span class="fourth" >command</span><span class="fifth" > ... </span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">...</td><br />
<td>global (optional)</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">...</td><br />
<td>unexpanded (optional)</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">...</td><br />
<td>expanded (optional)</td><br />
</tr><br />
<tr valign="top" class="fifth"><br />
<td class="cmd">...</td><br />
<td>#arguments</td><br />
</tr><br />
</table><br />
<br />
<br />
== Description ==<br />
<br />
The {{code|starttexdefinition}} uses the {{code|start…stop}} syntax to define<br />
new control sequences. They directly map to the brace-delimited definitions.<br />
It's also possible to define commands that take arguments. Both, the numbered<br />
syntax and the MkVI name-syntax are supported. To use MkVI syntax, save the<br />
file as {{code|file.mkvi}} or place the line <tt>%% macros=mkvi</tt> at the<br />
beginning of the document. The command features several modifier sequences,<br />
which are demonstrated in the following examples.<br />
<br />
== Example ==<br />
<br />
<texcode><br />
%% \def\command{…}<br />
\starttexdefinition command<br />
…<br />
\stoptexdefinition<br />
<br />
%% \def\command#1#2{…}<br />
\starttexdefinition command #1 #2<br />
…<br />
\stoptexdefinition<br />
<br />
%% \def\command#name#options{…}<br />
\starttexdefinition command #name #options<br />
…<br />
\stoptexdefinition<br />
<br />
%% \unexpanded\def\command#name#options{…}<br />
\starttexdefinition unexpanded command #name #options<br />
…<br />
\stoptexdefinition<br />
<br />
%% \gdef\command{…}<br />
\starttexdefinition global command<br />
…<br />
\stoptexdefinition<br />
<br />
%% \unexpanded\gdef\command{…}<br />
\starttexdefinition global unexpanded command<br />
…<br />
\stoptexdefinition<br />
<br />
%% \unexpanded\edef\command#arg{…}<br />
\starttexdefinition global unexpanded command #arg<br />
…<br />
\stoptexdefinition<br />
<br />
%% \unexpanded\xdef\command#arg{…}<br />
\starttexdefinition global unexpanded expanded command #arg<br />
…<br />
\stoptexdefinition<br />
</texcode><br />
<br />
== Pitfalls ==<br />
<br />
The order in which the modifier sequences {{code|global}}, {{code|unexpanded}}<br />
and {{code|expanded}} appear matters. One difference between traditional<br />
definitions and the start-stop environment is that spaces are ignored in the<br />
{{code|texdefinition}} environment, so line endings don't have to be littered<br />
with percent signs and the definitions tend to be more readable. This is<br />
usually what is desired when writing macros. However, it has to be taken into<br />
account when encapsulating Lua code.<br />
<br />
<texcode><br />
%% no problems here<br />
\def\somecommand<br />
{\startluacode<br />
if true then<br />
else<br />
end<br />
\stopluacode}<br />
<br />
\somecommand<br />
<br />
%% this will fail<br />
\starttexdefinition somecommand<br />
\startluacode<br />
if true then<br />
else<br />
end<br />
\stopluacode<br />
\stoptexdefinition<br />
<br />
\somecommand<br />
</texcode><br />
<br />
The above {{code|texdefinition}} example will fail, since the line endings,<br />
which normally result in a space are ignored and the spaces collapsed, so Lua<br />
receives {{code|if true thenelseend}}, which is not valid. The solution is to<br />
add a space and place a percent sign, which will not be removed in that case.<br />
<br />
<texcode><br />
%% this works<br />
\starttexdefinition somecommand<br />
\startluacode<br />
if true then %%<br />
else %%<br />
end<br />
\stopluacode<br />
\stoptexdefinition<br />
<br />
\somecommand<br />
</texcode><br />
<br />
== See also ==<br />
* {{tex|def}}<br />
* {{cmd|define}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Internals|starttexdefinition]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Table_of_Contents&diff=21392Table of Contents2013-01-24T09:27:56Z<p>Marco: Add link</p>
<hr />
<div>== Using Table of Contents ==<br />
<br />
To get the default table of contents use:<br />
<texcode><br />
\completecontent % with title<br />
\placecontent % without title<br />
</texcode><br />
<br />
<br />
One important quirk. If you do not start the document with {{cmd|completecontent}}, but use it later –for example after the introduction–, you should use:<br />
<texcode><br />
\completecontent[criterium=all]<br />
</texcode><br />
<br />
<br />
When {{cmd|completecontent}} is at the end of the document you can use:<br />
<texcode><br />
\completecontent[criterium=previous]<br />
</texcode><br />
<br />
== Modifying the default Table of Contents ==<br />
<br />
The default head that \completecontent places can be altered with<br />
{{cmd|setupheadtext|[content=All my contents]}}.<br />
<br />
You can customize the appearance, number of shown levels and other attributes of predefined TOC. <span style="color:red; font-weight: bold;">Please note that the <code>level</code> parameter has recently (02/2010) no effect in [[Mark IV]]</span>, you may use {{cmd|placelist|[chapter,section]}} (optionally adding {{cmd|title|{Contents}}} before) instead of {{cmd|setupcombinedlist|[content][level=2]}}.<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\setupcolors[state=start]<br />
<br />
% A new ToC title<br />
\setupheadtext[content=All my contents]<br />
<br />
% turn off numbering of some levels<br />
\setuphead[subsection][number=no]<br />
\setuphead[subsubsection][number=no]<br />
<br />
% TOC<br />
% level=4, \subsubsubsections are not listed in TOC<br />
% alternative=c, space to the page number is filled with dots<br />
\setupcombinedlist[content][level=4, alternative=c,]<br />
<br />
%\setuplist[chapter][width=5mm, style=bold]<br />
\setuplist[section][width=10mm, style=bold]<br />
\setuplist[subsection][width=20mm]<br />
<br />
% pagestyle=normal for changing the appearance of pagenumber<br />
\setuplist[subsubsection][width=20mm, style=slanted, pagestyle=normal]<br />
<br />
\starttext<br />
<br />
\startcolor[darkgreen]<br />
\completecontent<br />
\stopcolor<br />
\page[yes]<br />
<br />
\section{First section}<br />
\subsection{First subsection}<br />
\subsubsection{First subsubsection}<br />
\subsubsubsection{First subsubsubsection}<br />
\section{Second section}<br />
\subsection{Second subsection}<br />
\subsubsection{Second subsubsection}<br />
\subsubsubsection{Second subsubsubsection}<br />
\stoptext<br />
</context><br />
<br />
== Page Numbering in Table of Contents ==<br />
<br />
If you have a special page numbering style it won't automatically be reflected in the table of contents. You need to set the parameters of the table of contents separately. For example, <br />
<br />
<texcode><br />
\starttext<br />
\startfrontmatter<br />
\placecombinedlist[MyContentsList]<br />
\stopfrontmatter<br />
\startbodymatter<br />
\setuppagenumbering[way=bychapter, left=A, chapternumber=yes, numberseparator=/]<br />
...<br />
\stopbodymatter<br />
</texcode><br />
<br />
will give you pagenumbering such as A1/1, A1/2 etc. on the pages in the bodymatter. In the table of contents, however, these will show up as 1-1, 1-2 etc. The ToC needs to be formatted separately. <br />
<br />
To get a prefix to the page numbering (like "A"), use<br />
<br />
<texcode><br />
\def\ChapterPrefix#1{A#1}<br />
\setuplist[chapter][pagecommand=\ChapterPrefix]<br />
</texcode><br />
<br />
To get the numberseparator working, you need to know that the ToC will use the separator that is active ''at the time the ToC is output''. So you need to set it immediately before you call the ToC command, e.g.<br />
<br />
<texcode><br />
\setuppagenumbering[numberseparator=/]<br />
\placecombinedlist[MyContentsList]<br />
</texcode><br />
<br />
<span style="color:red; font-weight: bold;">The above method does not work in MkIV (not anymore at least).</span> Hence the code below illustrates how to get it working under MkIV. It should be noted that MkIV and MkII are incompatible with respect to this feature.<br />
<br />
As an example, consider that the frontmatter uses roman numerals and bodymatter remains unchanged. To reflect the romannumerals of the front matter in the TOC,<br />
<br />
<texcode><br />
\definestructureconversionset[frontpart:pagenumber][][romannumerals]<br />
\definestructureconversionset[bodypart:pagenumber] [][numbers]<br />
<br />
\setuplist[chapter][pageconversionset=pagenumber]<br />
<br />
\startsectionblockenvironment[frontpart]<br />
\setupuserpagenumber[numberconversion=romannumerals]<br />
\setuppagenumber[number=1]<br />
\stopsectionblockenvironment<br />
<br />
\startsectionblockenvironment[bodypart]<br />
\setuppagenumber[number=1]<br />
\stopsectionblockenvironment<br />
</texcode><br />
<br />
== Forced page break in a TOC ==<br />
<br />
To add a manual/forced page break in a table of contents, you first have to define it. This puts the break before the given heading.<br />
<br />
<texcode><br />
\definelistextra[page][before=\page]<br />
</texcode><br />
<br />
Then, when you place your TOC, you have to call for the extras and define the spot for the break:<br />
<br />
<texcode><br />
\placecontent[extras={6=page}] %puts break before Chapter 6 list item<br />
</texcode><br />
<br />
<br />
Solution given by Hans on the mailing list on September 29, 2010, and applies to MKIV (at least).<br />
<br />
== Dots in section numbers ==<br />
<br />
Last Number Dot in Table of Contents (e.g. 2.1.3.): see [[Dotted_number_in_caption]].<br />
<br />
If you want to avoid a dot if there's no number, try this solution (by Wolfgang Schuster as of 2008-04-29):<br />
<texcode><br />
\setuplist<br />
[chapter,section,...]<br />
[numbercommand=\DotAfterNumber]<br />
<br />
\def\DotAfterNumber#1{\doiftext{#1}{#1.}}<br />
</texcode><br />
<br />
== Author in ToC ==<br />
see setup for author/title/subtitle titling and author in ToC in [[Proceedings_style]].<br />
<br />
You can write "everything" to the ToC or an other list (see below) using {{cmd|writetolist}}.<br />
<br />
== Several ToC's in different languages ==<br />
If you want to have two tables of contents in your document, one in a native<br />
language and the other, for example, in english. This is how to do it:<br />
<br />
<texcode><br />
\mainlanguage[de]<br />
<br />
\starttext<br />
<br />
\completecontent<br />
<br />
%\start\language[en]<br />
\start\mainlanguage[en]<br />
\completecontent<br />
\stop<br />
<br />
\chapter{\translate[en=Chapter One,de=Kapitel Eins]}<br />
<br />
\chapter{\translate[en=Chapter Two,de=Kapitel Zwei]}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== Creating other "Table of ..." ==<br />
<br />
Generally all "Table (List) of ..." are defined with {{cmd|definelist}} and {{cmd|setuplist}}.<br />
You can "collect" several section levels in one list using {{cmd|definecombinedlist}}, that's even explained in "ConTeXt, an excursion" (see [[Official_ConTeXt_Documentation]]).<br />
<br />
To have some parts of your title texts ''not'' appear in the table of contents, use {{cmd|nolist}} and have a look at [http://www.pragma-ade.com/general/magazines/mag-0001.pdf mag-0001.pdf].<br />
<br />
<br />
== How the table of contents is generated by ConTeXt ==<br />
(from Tobias Burnus [http://archive.contextgarden.net/message/20060809.162652.8f517267.en.html on the mailinglist])<br />
<br />
The mechanism is a follows:<br />
<br />
# TeX is run and chapter names with pagenumbers etc. are saved into <jobname>.tui.<br />
# TeXutil is run and sorts some entries in *.tui and writes *.tuo<br />
# TeX is run again, reads .tuo and uses that data to produce the table of contents etc. (and produces a new .tui) As this changes the page numbers (for longer table of contents), TeXutil and TeX are re-run again.<br />
<br />
In principle TeXExec should do this automatically.<br />
<br />
== Tables of contents (and other lists) via project structures ==<br />
<br />
As of November 25, 2011, ConTeXt [[Mark IV]] supports the generation of lists via [[Project structure]]. Thus, given a product (possibly within some project), and given two or more components in that product with its own sections (chapters, sections, etc) or floats (figures, tables, etc); then each component can have its own list of contents independent of the other. This is done by setting ''criterium=component''. For example, create three files, one product and two components (slightly modified version of a sample posted by Hans):<br />
<br />
<texcode><br />
\startproduct example-1-product<br />
<br />
\definecombinedlist[summary][chapter]<br />
\setupcombinedlist[summary][criterium=component]<br />
<br />
\component example-1-component-a<br />
\component example-1-component-b<br />
<br />
\stopproduct <br />
<br />
\startcomponent example-1-component-a<br />
<br />
\starttitle[title=Contents]<br />
\placesummary<br />
\stoptitle<br />
<br />
\startchapter[title=Ward]<br />
\input ward<br />
\stopchapter<br />
<br />
\stopcomponent <br />
<br />
\startcomponent example-1-component-b<br />
\setupheadnumber[chapter][-1]<br />
<br />
\starttitle[title=Contents]<br />
\placesummary<br />
\stoptitle<br />
<br />
\startchapter[title=Zapf]<br />
\input zapf<br />
\stopchapter<br />
<br />
\stopcomponent <br />
</texcode><br />
<br />
Processing the component file will give you a separate table of contents for each component.<br />
<br />
== Alternating filler dots ==<br />
<br />
The following code was provided by Wolfgang on the mailing list (http://www.ntg.nl/pipermail/ntg-context/2013/071144.html). It produces alternating dots like in Knuths' TeXbook and MetaFont book. The {{cmd|definefiller}} command requires ConTeXt version 2013.01.13 or newer.<br />
<br />
<texcode><br />
\definefiller<br />
[pavel-0]<br />
[alternative=symbol,<br />
method=global,<br />
width=1em,<br />
leftmargin=.5em,<br />
rightmargin=.5em,<br />
symbol=\clap{.}]<br />
<br />
\definefiller<br />
[pavel-1]<br />
[pavel-0]<br />
[align=left]<br />
<br />
\definefiller<br />
[pavel-2]<br />
[pavel-0]<br />
[align=middle]<br />
<br />
\newconditional\PavelState<br />
<br />
\define\PavelFiller<br />
{\ifconditional\PavelState<br />
\global\setfalse\PavelState<br />
\filler[pavel-1]%%<br />
\else<br />
\global\settrue\PavelState<br />
\filler[pavel-2]%%<br />
\fi}<br />
<br />
\setuplistalternative<br />
[c]<br />
[filler=\PavelFiller]<br />
<br />
\starttext<br />
\completecontent [alternative=c]<br />
\dorecurse{10}{\expanded{\chapter{Chapter \recurselevel}}}<br />
\stoptext<br />
</texcode></div>Marcohttps://wiki.contextgarden.net/index.php?title=Table_of_Contents&diff=21391Table of Contents2013-01-24T09:24:57Z<p>Marco: Add section about alternating filler dots</p>
<hr />
<div>== Using Table of Contents ==<br />
<br />
To get the default table of contents use:<br />
<texcode><br />
\completecontent % with title<br />
\placecontent % without title<br />
</texcode><br />
<br />
<br />
One important quirk. If you do not start the document with {{cmd|completecontent}}, but use it later –for example after the introduction–, you should use:<br />
<texcode><br />
\completecontent[criterium=all]<br />
</texcode><br />
<br />
<br />
When {{cmd|completecontent}} is at the end of the document you can use:<br />
<texcode><br />
\completecontent[criterium=previous]<br />
</texcode><br />
<br />
== Modifying the default Table of Contents ==<br />
<br />
The default head that \completecontent places can be altered with<br />
{{cmd|setupheadtext|[content=All my contents]}}.<br />
<br />
You can customize the appearance, number of shown levels and other attributes of predefined TOC. <span style="color:red; font-weight: bold;">Please note that the <code>level</code> parameter has recently (02/2010) no effect in [[Mark IV]]</span>, you may use {{cmd|placelist|[chapter,section]}} (optionally adding {{cmd|title|{Contents}}} before) instead of {{cmd|setupcombinedlist|[content][level=2]}}.<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\setupcolors[state=start]<br />
<br />
% A new ToC title<br />
\setupheadtext[content=All my contents]<br />
<br />
% turn off numbering of some levels<br />
\setuphead[subsection][number=no]<br />
\setuphead[subsubsection][number=no]<br />
<br />
% TOC<br />
% level=4, \subsubsubsections are not listed in TOC<br />
% alternative=c, space to the page number is filled with dots<br />
\setupcombinedlist[content][level=4, alternative=c,]<br />
<br />
%\setuplist[chapter][width=5mm, style=bold]<br />
\setuplist[section][width=10mm, style=bold]<br />
\setuplist[subsection][width=20mm]<br />
<br />
% pagestyle=normal for changing the appearance of pagenumber<br />
\setuplist[subsubsection][width=20mm, style=slanted, pagestyle=normal]<br />
<br />
\starttext<br />
<br />
\startcolor[darkgreen]<br />
\completecontent<br />
\stopcolor<br />
\page[yes]<br />
<br />
\section{First section}<br />
\subsection{First subsection}<br />
\subsubsection{First subsubsection}<br />
\subsubsubsection{First subsubsubsection}<br />
\section{Second section}<br />
\subsection{Second subsection}<br />
\subsubsection{Second subsubsection}<br />
\subsubsubsection{Second subsubsubsection}<br />
\stoptext<br />
</context><br />
<br />
== Page Numbering in Table of Contents ==<br />
<br />
If you have a special page numbering style it won't automatically be reflected in the table of contents. You need to set the parameters of the table of contents separately. For example, <br />
<br />
<texcode><br />
\starttext<br />
\startfrontmatter<br />
\placecombinedlist[MyContentsList]<br />
\stopfrontmatter<br />
\startbodymatter<br />
\setuppagenumbering[way=bychapter, left=A, chapternumber=yes, numberseparator=/]<br />
...<br />
\stopbodymatter<br />
</texcode><br />
<br />
will give you pagenumbering such as A1/1, A1/2 etc. on the pages in the bodymatter. In the table of contents, however, these will show up as 1-1, 1-2 etc. The ToC needs to be formatted separately. <br />
<br />
To get a prefix to the page numbering (like "A"), use<br />
<br />
<texcode><br />
\def\ChapterPrefix#1{A#1}<br />
\setuplist[chapter][pagecommand=\ChapterPrefix]<br />
</texcode><br />
<br />
To get the numberseparator working, you need to know that the ToC will use the separator that is active ''at the time the ToC is output''. So you need to set it immediately before you call the ToC command, e.g.<br />
<br />
<texcode><br />
\setuppagenumbering[numberseparator=/]<br />
\placecombinedlist[MyContentsList]<br />
</texcode><br />
<br />
<span style="color:red; font-weight: bold;">The above method does not work in MkIV (not anymore at least).</span> Hence the code below illustrates how to get it working under MkIV. It should be noted that MkIV and MkII are incompatible with respect to this feature.<br />
<br />
As an example, consider that the frontmatter uses roman numerals and bodymatter remains unchanged. To reflect the romannumerals of the front matter in the TOC,<br />
<br />
<texcode><br />
\definestructureconversionset[frontpart:pagenumber][][romannumerals]<br />
\definestructureconversionset[bodypart:pagenumber] [][numbers]<br />
<br />
\setuplist[chapter][pageconversionset=pagenumber]<br />
<br />
\startsectionblockenvironment[frontpart]<br />
\setupuserpagenumber[numberconversion=romannumerals]<br />
\setuppagenumber[number=1]<br />
\stopsectionblockenvironment<br />
<br />
\startsectionblockenvironment[bodypart]<br />
\setuppagenumber[number=1]<br />
\stopsectionblockenvironment<br />
</texcode><br />
<br />
== Forced page break in a TOC ==<br />
<br />
To add a manual/forced page break in a table of contents, you first have to define it. This puts the break before the given heading.<br />
<br />
<texcode><br />
\definelistextra[page][before=\page]<br />
</texcode><br />
<br />
Then, when you place your TOC, you have to call for the extras and define the spot for the break:<br />
<br />
<texcode><br />
\placecontent[extras={6=page}] %puts break before Chapter 6 list item<br />
</texcode><br />
<br />
<br />
Solution given by Hans on the mailing list on September 29, 2010, and applies to MKIV (at least).<br />
<br />
== Dots in section numbers ==<br />
<br />
Last Number Dot in Table of Contents (e.g. 2.1.3.): see [[Dotted_number_in_caption]].<br />
<br />
If you want to avoid a dot if there's no number, try this solution (by Wolfgang Schuster as of 2008-04-29):<br />
<texcode><br />
\setuplist<br />
[chapter,section,...]<br />
[numbercommand=\DotAfterNumber]<br />
<br />
\def\DotAfterNumber#1{\doiftext{#1}{#1.}}<br />
</texcode><br />
<br />
== Author in ToC ==<br />
see setup for author/title/subtitle titling and author in ToC in [[Proceedings_style]].<br />
<br />
You can write "everything" to the ToC or an other list (see below) using {{cmd|writetolist}}.<br />
<br />
== Several ToC's in different languages ==<br />
If you want to have two tables of contents in your document, one in a native<br />
language and the other, for example, in english. This is how to do it:<br />
<br />
<texcode><br />
\mainlanguage[de]<br />
<br />
\starttext<br />
<br />
\completecontent<br />
<br />
%\start\language[en]<br />
\start\mainlanguage[en]<br />
\completecontent<br />
\stop<br />
<br />
\chapter{\translate[en=Chapter One,de=Kapitel Eins]}<br />
<br />
\chapter{\translate[en=Chapter Two,de=Kapitel Zwei]}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== Creating other "Table of ..." ==<br />
<br />
Generally all "Table (List) of ..." are defined with {{cmd|definelist}} and {{cmd|setuplist}}.<br />
You can "collect" several section levels in one list using {{cmd|definecombinedlist}}, that's even explained in "ConTeXt, an excursion" (see [[Official_ConTeXt_Documentation]]).<br />
<br />
To have some parts of your title texts ''not'' appear in the table of contents, use {{cmd|nolist}} and have a look at [http://www.pragma-ade.com/general/magazines/mag-0001.pdf mag-0001.pdf].<br />
<br />
<br />
== How the table of contents is generated by ConTeXt ==<br />
(from Tobias Burnus [http://archive.contextgarden.net/message/20060809.162652.8f517267.en.html on the mailinglist])<br />
<br />
The mechanism is a follows:<br />
<br />
# TeX is run and chapter names with pagenumbers etc. are saved into <jobname>.tui.<br />
# TeXutil is run and sorts some entries in *.tui and writes *.tuo<br />
# TeX is run again, reads .tuo and uses that data to produce the table of contents etc. (and produces a new .tui) As this changes the page numbers (for longer table of contents), TeXutil and TeX are re-run again.<br />
<br />
In principle TeXExec should do this automatically.<br />
<br />
== Tables of contents (and other lists) via project structures ==<br />
<br />
As of November 25, 2011, ConTeXt [[Mark IV]] supports the generation of lists via [[Project structure]]. Thus, given a product (possibly within some project), and given two or more components in that product with its own sections (chapters, sections, etc) or floats (figures, tables, etc); then each component can have its own list of contents independent of the other. This is done by setting ''criterium=component''. For example, create three files, one product and two components (slightly modified version of a sample posted by Hans):<br />
<br />
<texcode><br />
\startproduct example-1-product<br />
<br />
\definecombinedlist[summary][chapter]<br />
\setupcombinedlist[summary][criterium=component]<br />
<br />
\component example-1-component-a<br />
\component example-1-component-b<br />
<br />
\stopproduct <br />
<br />
\startcomponent example-1-component-a<br />
<br />
\starttitle[title=Contents]<br />
\placesummary<br />
\stoptitle<br />
<br />
\startchapter[title=Ward]<br />
\input ward<br />
\stopchapter<br />
<br />
\stopcomponent <br />
<br />
\startcomponent example-1-component-b<br />
\setupheadnumber[chapter][-1]<br />
<br />
\starttitle[title=Contents]<br />
\placesummary<br />
\stoptitle<br />
<br />
\startchapter[title=Zapf]<br />
\input zapf<br />
\stopchapter<br />
<br />
\stopcomponent <br />
</texcode><br />
<br />
Processing the component file will give you a separate table of contents for each component.<br />
<br />
== Alternating filler dots ==<br />
<br />
The following code was provided by Wolfgang on the mailing list. It produces alternating dots like in Knuths' TeXbook and MetaFont book. The {{cmd|definefiller}} command requires ConTeXt version 2013.01.13 or newer.<br />
<br />
<texcode><br />
\definefiller<br />
[pavel-0]<br />
[alternative=symbol,<br />
method=global,<br />
width=1em,<br />
leftmargin=.5em,<br />
rightmargin=.5em,<br />
symbol=\clap{.}]<br />
<br />
\definefiller<br />
[pavel-1]<br />
[pavel-0]<br />
[align=left]<br />
<br />
\definefiller<br />
[pavel-2]<br />
[pavel-0]<br />
[align=middle]<br />
<br />
\newconditional\PavelState<br />
<br />
\define\PavelFiller<br />
{\ifconditional\PavelState<br />
\global\setfalse\PavelState<br />
\filler[pavel-1]%%<br />
\else<br />
\global\settrue\PavelState<br />
\filler[pavel-2]%%<br />
\fi}<br />
<br />
\setuplistalternative<br />
[c]<br />
[filler=\PavelFiller]<br />
<br />
\starttext<br />
\completecontent [alternative=c]<br />
\dorecurse{10}{\expanded{\chapter{Chapter \recurselevel}}}<br />
\stoptext<br />
</texcode></div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/signalrightpage&diff=21374Command/signalrightpage2013-01-12T15:19:40Z<p>Marco: Add additional information</p>
<hr />
<div>{{Reference<br />
|name=signalrightpage<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\signalrightpage<!--<br />
--></td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
Start tracking whether we are on a right- or a left-hand page. {{cmd|signalrightpage}} is only necessary for text <em>in</em><br />
the document. In the header it is sufficient to use {{cmd|doifoddpageelse}} to set different<br />
values for left/right pages.<br />
<br />
<br />
== Example ==<br />
<texcode><br />
\signalrightpage\doifrightpageelse{Right!}{Left!}<br />
</texcode><br />
<br />
== See also ==<br />
* {{cmd|doif...}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Layout|signalrightpage]]<br />
[[Category:Command/Internals|signalrightpage]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/defineMPinstance&diff=21216Command/defineMPinstance2012-11-26T15:11:13Z<p>Marco: Add info about MPinstance separated by double-colon</p>
<hr />
<div>{{Reference<br />
|name=defineMPinstance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\defineMPinstance<span class="first" >[...]</span><span class="second" >[...]</span><span class="third" >[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name for inheritance (optional)</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td>see [[Command/setupMPinstance|\setupMPinstance]]</td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
This command sets up a custom MetaPost style with particular features that can be selected using the first argument. The instance <code>metafun</code> is the default one and does not need to be created. However, custom styles can inherit from the <code>metafun</code> instance.<br />
<br />
The MetaPost instance is provided as first argument to <code>\startMPcode</code> or <code>\startuseMPgraphic</code>. In the latter case the figure name is separated by a double-colon from the instance name.<br />
<br />
== Predefined Instances ==<br />
<br />
<texcode><br />
\defineMPinstance [metafun] [format=metafun, extensions=yes, initializations=yes]<br />
\defineMPinstance [metapost] [format=mpost]<br />
</texcode><br />
<br />
== Example ==<br />
<context mode="mkiv" source="yes" text="Gives:"><br />
\defineMPinstance<br />
[important]<br />
[metafun] % needs to be inherited from the global metafun instance<br />
[textcolor=red]<br />
<br />
\defineMPinstance<br />
[veryimportant]<br />
[important]<br />
[textstyle=bold]<br />
<br />
\starttext<br />
<br />
% normal black text<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red text<br />
\startMPcode{important}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red bold text<br />
\startMPcode{veryimportant}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\startuseMPgraphic{veryimportant::mygraphic}<br />
draw textext("some text") ;<br />
\stopuseMPgraphic<br />
<br />
\useMPgraphic{veryimportant::mygraphic}<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
== See also ==<br />
{{MetaPost see also}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/MetaPost|definestartstop]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/startuseMPgraphic&diff=21215Command/startuseMPgraphic2012-11-26T15:06:43Z<p>Marco: Add info about MPinstance</p>
<hr />
<div>{{Reference<br />
|name=startuseMPgraphic<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\startuseMPgraphic<!--<br />
--><span class="first">{...}</span><!--<br />
--></td><br />
</tr><br />
<tr><td>%% MetaPost code</td></tr><br />
<tr><br />
<td colspan="2" class="cmd">\stopuseMPgraphic</td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">{...}</td><br />
<td>''name under which the graphic will be known''</td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
Define code for a MetaPost graphic. The graphic can be placed in the document with {{cmd|useMPgraphic}}, and will be recompiled every time it is placed.<br />
<br />
If a custom MetaPost instance should be used, the name of the MetaPost instance has to be provided as an argument followed by a double-colon and the MPgraphic name.<br />
<br />
== Example ==<br />
<context source=yes><br />
\def\mycolor{.625red}<br />
<br />
\defineMPinstance<br />
[myinstance]<br />
[metafun]<br />
<br />
\startuseMPgraphic{myinstance::name}<br />
fill fullcircle scaled 20pt withcolor \mycolor;<br />
\stopuseMPgraphic<br />
<br />
\startuseMPgraphic{name}<br />
fill fullcircle scaled 20pt withcolor \mycolor;<br />
\stopuseMPgraphic<br />
<br />
red: \useMPgraphic{name}<br />
red: \useMPgraphic{myinstance::name}<br />
<br />
\def\mycolor{.625blue}<br />
blue: \useMPgraphic{name}<br />
</context><br />
<br />
== See also ==<br />
{{MetaPost see also}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|startuseMPgraphic}}<br />
<br />
[[Category:Command/MetaPost|startuseMPgraphic]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=File:result.png&diff=21001File:result.png2012-11-08T17:26:46Z<p>Marco: Result image for \definelistalternative</p>
<hr />
<div>Result image for \definelistalternative</div>Marcohttps://wiki.contextgarden.net/index.php?title=User_talk:Esteis&diff=20852User talk:Esteis2012-10-01T11:42:48Z<p>Marco: Add random thoughts</p>
<hr />
<div>Speak your mind.<br />
<br />
{{cmd|startalignment}}<br />
{{cmd|startalignment|[middle]}}<br />
{{cmd|section|{First section}}}<br />
<br />
<br />
<cmd>startalignment</cmd><br />
asdf<br />
<br />
Correct horse battery staple</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setupcaptions&diff=20367Command/setupcaptions2012-09-04T11:58:18Z<p>Marco: Add prefix key</p>
<hr />
<div>{{Reference<br />
|name=setupcaptions<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupcaptions<span class="first" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:location|location]]</td><br />
<td>[[Command/value:top|top]] [[Command/value:bottom|bottom]] [[Command/value:none|none]] [[Command/value:high|high]] [[Command/value:low|low]] [[Command/value:middle|middle]] [[Command/value:left|left]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:width|width]]</td><br />
<td>[[Command/value:fit|fit]] [[Command/value:broad|broad]] [[Command/value:max|max]] [[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:minwidth|minwidth]]</td><br />
<td>[[Command/value:fit|fit]] [[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:headstyle|headstyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:number|number]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:inbetween|inbetween]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:flushleft|flushleft]] [[Command/value:middle|middle]] [[Command/value:flushright|flushright]] [[Command/value:right|right]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:numberconversion|numberconversion]]</td><br />
<td>[[Command/value:numbers|numbers]] [[Command/value:characters|characters]] [[Command/value:Characters|Characters]] [[Command/value:romannumerals|romannumerals]] [[Command/value:Romannumerals|Romannumerals]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:conversion|conversion]]</td><br />
<td>[[Command/value:numbers|numbers]] [[Command/value:characters|characters]] [[Command/value:Characters|Characters]] [[Command/value:romannumerals|romannumerals]] [[Command/value:Romannumerals|Romannumerals]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:way|way]]</td><br />
<td>[[Command/value:bytext|bytext]] [[Command/value:bysection|bysection]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:separator|separator]]</td><br />
<td>[[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:stopper|stopper]]</td><br />
<td>[[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:prefix|prefix]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:suffix|suffix]]</td><br />
<td>[[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:prefixsegments|prefixsegments]]</td><br />
<td>[[Command/value:none|none]] [[Command/value:section|section]] ...</td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:command|command]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
</table><br />
<br />
== Description ==<br />
<br />
{| class=wikitable<br />
|- style="vertical-align: top" <br />
| {{key|location}}<br />
| The first option defines the location of the caption relative to the figure itself. The option <code>[location=right]</code> e.g. puts the caption on the right of the figure. The values of the location can be combined, so that <code>[location={right,low}]</code> adjusts the caption position to be to the right of the figure and in a low vertical position. <br />
|- style="vertical-align: top"<br />
| {{key|width}} <br />
| This is the width of the figure caption. If you do not like default captions that are driven by figure (table) width, try: <code>\setupcaptions[minwidth=textwidth, align=middle]</code><br />
|- style="vertical-align: top"<br />
| {{key|headstyle}}<br />
| This defines the formatting of the label, i.e. usually the word ''figure'' or ''table'' and its number. For example, <code>[headstyle=\it]</code> will change it to ''italic''.<br />
|- style="vertical-align: top"<br />
| {{key|style}}<br />
| The formatting of the text of the caption, use <code>[style=\it]</code> to get an ''italic'' text. Several values can be given using curly brackets: <code>[style={\it\tfx}]</code>. Please note, that some formatting (such as font size) will affect the head as well.<br />
|- style="vertical-align: top"<br />
| {{key|number}}<br />
| The option <code>[number=no]</code> suppresses the label and figure number.<br />
|- style="vertical-align: top"<br />
| {{key|inbetween}}<br />
| The macros given here are executed after placing the figure and before placing the caption. To set the space between figure and caption to zero use <code>[inbetween=]</code><br />
|- style="vertical-align: top"<br />
| {{key|align}}<br />
| This can change the alignment of the caption. It can lead to confusion, since ''left'' and ''right'' means ''raggedleft'' and ''raggedright''. So to align a caption ''flush left'', use <code>[align=flushleft]</code>. <br />
|- style="vertical-align: top"<br />
| {{key|numberconversion}}<br />
| Here, it is possible to change the number of the e.g. figure. ''romannumerals'' means, well, roman numerals, the capitalized version capitalizes the number as well. In MkIV, ''numberconversion'' must be used instead of ''conversion''. Example: <code>numberconversion=Romannumerals</code><br />
|- style="vertical-align: top" <br />
| {{key|conversion}}<br />
| This is the MkII version of ''numberconversion''.<br />
|- style="vertical-align: top" <br />
| {{key|way}}<br />
| Using option <code>[way=bysection]</code> resets the numbering to 1 at each new section, but does not prefix the numbers with the section number, to do that, use the following options: <code>\setupcaptions[way=bysection,prefixsegments=section]</code>. If one has only a small number of figures and wishes to label them sequentially from 1 to ''n'', the following works:<code>\setupcaptions[way=bytext, prefixsegments=none]</code>.<br />
|- style="vertical-align: top" <br />
| {{key|suffix'''}}<br />
| If you like to have a colon in your caption, try:<code>\setupcaptions[suffix={:}]</code><br />
|- style="vertical-align: top" <br />
| {{key|prefixsegments}}<br />
| To have a figure number such as ''Figure 2.3'', where 2 is the section number and 3 the figure number, you can use this option. Normally, you want to reset the figure number with every section as well, so that ''Figure 2.1'' follows ''Figure 1.12'' instead of ''Figure 2.13''. Therefore, you have to use <code>\setupcaptions[prefix=yes,way=bysection,prefixsegments=section]</code>.<br />
|}<br />
<br />
== Example ==<br />
<context source=yes><br />
\setuppapersize[A6]<br />
\setupexternalfigures[location=default]<br />
\setupcaptions[<br />
style={\tfx\setupinterlinespace[line=10pt]}, <br />
headstyle=\rm, <br />
stopper={:}]<br />
<br />
\placefigure<br />
{Oh caption, my caption!\crlf<br />
(Apologies to Walt Whitman)}<br />
{\externalfigure[cow][width=2cm]}<br />
<br />
\input linden<br />
</context><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/Floating|setupcaptions]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Units&diff=20364Units2012-09-03T12:48:50Z<p>Marco: Add link to mkIV units manual</p>
<hr />
<div>< [[Math]] [[Physics]] ><br />
<br />
The units module comes with ConTeXt's default distribution, and can be accessed via <cmd>usemodule</cmd>[units].<br />
<br />
However, in MkIV we have integrated an upgrade to this mechanism so if you're using that version you might want to skip this first part.<br />
<br />
Additional documentation about units in MkIV is available from the [[http://www.pragma-ade.com/general/manuals/units-mkiv.pdf Units manual]]<br />
<br />
The following is copied from the source file [[source:m-units.tex|m-units.tex]] and only slightly modified:<br />
<br />
----<br />
<br />
* Scientific units can be typeset in math mode pretty well, but occasionally one has to take care of spacing.<br />
Furthermore, entering these units is not that natural as wanted. Therefore this module presents a more natural way of doing things, like:<br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
1.23 \Cubic \Meter \Per \Second<br />
</context><br />
<br />
This example shows that we use the order in which we say things, instead of typeset things. There is no dedicated manual for this module, but an article (in dutch) <br />
has been published in [[http://www.ntg.nl/maps/pdf/21_16.pdf Maps#21]], the journal of the NTG.<br />
<br />
<br />
* This runtime loadable module implements a way of defining units. The core macro is <cmd>dimension</cmd>, a rather clever one that is able to cooperate with some other dimension related macros. As said, this module enables user to enter:<br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
Some 10 \Square \Meter \Per \Second\ or more.<br />
</context><br />
<br />
(Note that the space after <cmd>Second</cmd> needs to be explicitly specified; otherwise, it will get eaten.)<br />
<br />
<br />
* Units act upon signals that they insert in the text, in case no quantity is given you need to start the unit sequence using <cmd>Unit</cmd><br />
<br />
<context source="yes"><br />
\usemodule[units]<br />
Units of measurement is \Unit \Milli \Meter<br />
</context><br />
<br />
The units itself are implemented as synonyms.<br />
<br />
<texcode><br />
\definesynonyms [unit] [units] [\unitmeaning]<br />
\setupsynonyms [unit] [textstyle=\dimension]<br />
</texcode><br />
<br />
This definition means that we can ask for the meaning of a unit using <cmd>unitmeaning</cmd> and get a list of used units by saying <cmd>placelistofunits</cmd>.<br />
<br />
We have to use the command <cmd>unitmeaning</cmd> instead of <cmd>meaning</cmd>, simply because the latter is a TeX primitive we don't want to lose. We use the label text mechanism for translations.<br />
<br />
----<br />
<br />
===Macros defined in units===<br />
<br />
External link: <br />
[[http://www.unc.edu/~rowlett/units/index.html How Many? A Dictionary of Units of Measurement]]<br />
<br />
* Prefixes: <cmd>Atto</cmd> a, <cmd>Femto</cmd> f, <cmd>Pico</cmd> p, <cmd>Nano</cmd> n, <cmd>Micro</cmd> μ, <cmd>Milli</cmd> m, <cmd>Centi</cmd> c, <cmd>Deci</cmd> d, <cmd>Hecto</cmd> h, <cmd>Kilo</cmd> k, <cmd>Mega</cmd> M, <cmd>Giga</cmd> G, <cmd>Tera</cmd> T, <cmd>Peta</cmd> P, <cmd>Exa</cmd> E (missing: <cmd>Zetta</cmd> Z, <cmd>Yotta</cmd> Y, <cmd>Zepto</cmd> z, <cmd>Yocto</cmd> y)<br />
* Suffixes: <cmd>Linear</cmd> <sup>1</sup>, <cmd>Square</cmd> <sup>2</sup>, <cmd>Cubic</cmd> <sup>3</sup>, <cmd>Inverse</cmd> or <cmd>ILinear</cmd> <sup>-1</sup>, <cmd>ISquare</cmd> <sup>-2</sup>, <cmd>ICubic</cmd> <sup>-3</sup><br />
* Fraction: <cmd>Per</cmd>, <cmd>Percent</cmd>, <cmd>Permille</cmd>, <cmd>Promille</cmd><br />
* Time: <cmd>Second</cmd>, <cmd>Minute</cmd>, <cmd>Hour</cmd>, <cmd>Day</cmd>, <cmd>Month</cmd>, <cmd>Year</cmd><br />
* Length, Area, Volume: <cmd>Meter</cmd>, <cmd>Angstrom</cmd>, <cmd>Foot</cmd>, <cmd>Inch</cmd>, <cmd>Liter</cmd><br />
* Mass, Force and Pressure: <cmd>Gram</cmd>, <cmd>Atom</cmd>, <cmd>Newton</cmd>, <cmd>Pascal</cmd>, <cmd>Mol</cmd>, <cmd>At</cmd>, <cmd>Atm</cmd>, <cmd>Bar</cmd>, <cmd>Force</cmd><br />
* Energy, Electricity and Magnetism: <cmd>Joule</cmd>, <cmd>Watt</cmd>, <cmd>Cal</cmd>, <cmd>Farad</cmd>, <cmd>Henry</cmd>, <cmd>Ohm</cmd>, <cmd>Siemens</cmd>, <cmd>Ampere</cmd>, <cmd>Coulomb</cmd>, <cmd>Volt</cmd>, <cmd>Tesla</cmd>, <cmd>Gauss</cmd>, <cmd>VoltAC</cmd>, <cmd>VoltDC</cmd>, <cmd>EVolt</cmd>, <cmd>Weber</cmd><br />
* Temperature: <cmd>Degrees</cmd>, <cmd>Kelvin</cmd>, <cmd>Celsius</cmd>, <cmd>Fahrenheit</cmd><br />
* Angle: <cmd>Rad</cmd>, <cmd>Deg</cmd>, <cmd>Sterant</cmd><br />
* Frequency, Optics and Acoustics: <cmd>Hertz</cmd>, <cmd>RevPerSec</cmd>, <cmd>RevPerMin</cmd>, <cmd>Candela</cmd>, <cmd>Lux</cmd>, <cmd>Bell</cmd><br />
* Chemistry and Radiation: <cmd>Atom</cmd>, <cmd>Mol</cmd>, <cmd>Molair</cmd>, <cmd>Equivalent</cmd>, <cmd>Bequerel</cmd>, <cmd>Sievert</cmd>, <cmd>Gray</cmd><br />
* Informatics: <cmd>Baud</cmd>, <cmd>Bit</cmd>, <cmd>Byte</cmd><br />
* some old dutch (not listed)<br />
<br />
===Using the built-in command===<br />
<br />
In MkIV you can use the built-in <cmd>unit</cmd> command. This time we don't use commands, if only because it is somewhat cumbersome. Let's give a few examples: <br />
<br />
<texcode><br />
10 \unit{km/h}<br />
\unit{10 km/h}<br />
\unit{~1 km/h}<br />
\unit{KiloMeter/Hour}<br />
\unit{10 cubic meter / second}<br />
\unit{kilo pascal square meter / second}<br />
\unit{kilo pascal square meter / kelvin second }$<br />
\unit{10 AC}<br />
$\frac{10 \unit{m/s}}{20 \unit{m/s}}$<br />
{\ss 30 \unit{kilo pascal square meter / second kelvin}}<br />
\unit{123.22^-3 km/s}<br />
\unit{123.22e-3 km/s}<br />
</texcode><br />
<br />
The command works in text as well as in math mode and spaces are normally ignored. You can define your own command: <br />
<br />
<texcode><br />
\defineunits[un][alternative=text,separator=medium]<br />
</texcode><br />
<br />
Valid separators are <code>cdot</code>, <code>big</code>, <code>medium</code>, and <code>space</code> with the first being the default. You can later tune the rendering with <br />
<br />
<texcode><br />
\setupunits[un][separator=cdot]<br />
</texcode><br />
<br />
In due time there will be a few more options. Numbers are formatted cf the digits mechanism (not discussed here). <br />
<br />
===Expressing Physical quantities===<br />
<br />
A physical quantity is number plus unit, and should not be split. A simple way to do this follows - define your own macro:<br />
<br />
<texcode><br />
\define[3]\physicalquantityle{\hbox{#1 \times \lunit{10^#2 #3}}}<br />
</texcode><br />
<br />
You can then write<br />
\physicalquantityle{number}{exponent}{unit}<br />
<br />
This seems to give better results than any other way I have found of combining digits and units.<br />
<br />
The full range of variants allow expression of physical quantities with and without exponents, with units in long form or not:<br />
<texcode><br />
\define[2]\physicalquantity{\hbox{\unit{#1 #2}}}<br />
% \physicalquantity{number}{unit} -- gives short form of unit<br />
\define[2]\physicalquantityl{\hbox{\lunit{#1 #2}}}<br />
% \physicalquantityl{number}{unit} -- gives long form of unit<br />
\define[3]\physicalquantitye{\hbox{#1 \times \lunit{10^#2 #3}}}<br />
% \physicalquantitye{number}{exponent}{unit} -- gives short form of unit<br />
\define[3]\physicalquantityle{\hbox{#1 \times \lunit{10^#2 #3}}}<br />
% \physicalquantityle{number}{exponent}{unit} -- gives long form of unit<br />
</texcode><br />
<br />
<br />
You can also do ranges of units, that are otherwise messy to code up on an individual basis<br />
<br />
<br />
<texcode><br />
\define[3]\physicalquantityspread{\hbox{#1\endash \lunit{#2 #3}}}<br />
</texcode><br />
<br />
You can then write:<br />
\physicalquantityspread{start}{end}{unit}<br />
<br />
<br />
<br />
<br />
<br />
[[Category:Math]]<br />
[[Category:Modules]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=TABLE&diff=20360TABLE2012-08-31T15:50:06Z<p>Marco: Add section about diagonal rules</p>
<hr />
<div>< [[Tables Overview]] | [[XML]] ><br />
<br />
=Introduction=<br />
<br />
This table mode is called &ldquo;natural tables&rdquo; or &ldquo;automatic tables.&rdquo; I'd call it &ldquo;HTML tables,&rdquo; because it's very similar to them. They're especially suited for [[XML]] conversions.<br />
<br />
Beware: every element must use <tt>\b</tt> ... <tt>\e</tt>!<br />
<br />
You find a lot of samples in [[manual:enattab.pdf|enattab.pdf]]<br />
<br />
Willi Egger wrote a [[My Way]] how he set a typesetter's lead type case: [http://dl.contextgarden.net/myway/NaturalTables.pdf Use of natural tables]<br />
<br />
To place a table use:<br />
<br />
<texcode><br />
\placetable{Caption}<br />
{\bTABLE<br />
\bTR \bTD One \eTD \bTD two \eTD \eTR<br />
\bTR \bTD One \eTD \bTD two \eTD \eTR<br />
\eTABLE}<br />
</texcode><br />
<br />
Here is a more elaborate example:<br />
<br />
<context source=yes><br />
This is our red-coloured table.<br />
\setupTABLE[row][odd][background=color,backgroundcolor=red, width=.2\textwidth]<br />
\bTABLE[split=yes] % allow splitting over page boundaries<br />
\bTR \bTD[nr=3] 1 \eTD \bTD[nc=2] 2/3 \eTD \bTD[nr=3] 4 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD[nc=3] 1/2/3 \eTD \bTD 4 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 2 \eTD \bTD 3 \eTD \bTD 4 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
<br />
= Multipage TABLEs =<br />
<br />
Try to divide your table into...<br />
* <cmd>bTABLEhead</cmd> (table header)<br />
* <cmd>bTABLEnext</cmd> (alternate table header on following pages)<br />
* <cmd>bTABLEbody</cmd> (table body)<br />
* <cmd>bTABLEfoot</cmd> (table footer)<br />
and <cmd>setupTABLE</cmd><tt>[split=yes]</tt> or <tt>[split=repeat]</tt><br />
<br />
see also [[source:core-ntb.tex|core-ntb.tex]]<br />
<br />
If you must <b>split</b> a natural table over several pages, you can<br />
simply do this by adding <tt>\setupTABLE[split=yes]</tt> to your TABLE<br />
definition. Another way is to define it right at the TABLE start<br />
by adding the parameter <tt>[split=yes]</tt> (see example).<br />
However,<br />
{{cmd|startlinecorrection}}<br />
can lead to unpredictable vertical spaces between rows [http://archive.contextgarden.net/message/20100912.112605.8a1aaf13.en.html].<br />
<br />
In this case the <b>table head</b><br />
(all between <cmd>bTABLEhead</cmd> and <cmd>eTABLEhead</cmd>)<br />
is printed only once at the beginning of the table. But if you use <tt>[split=repeat]</tt>,<br />
it is printed on top of every new page, that contains parts of<br />
your multipage table. Please take account of the fact, that the<br />
head cells are enclosed by <cmd>bTH</cmd> and <cmd>eTH</cmd> (and not \[be]TC).<br />
<br />
If you want to use an alternative table header for all following pages,<br />
you can do this by defining an additional header. Just add the second header<br />
between <cmd>bTABLEnext</cmd>...<cmd>eTABLEnext</cmd>,<br />
right after your normal head definition.<br />
Now every additional page of the multipage table starts with the<br />
<b>next table head</b>.<br />
<br />
The <b>table foot</b> is declared between <cmd>bTABLEfoot</cmd> and<br />
<cmd>eTABLEfoot</cmd>. It defines the concluding row of your natural table.<br />
<br />
'''Beware:''' Split tables often begin not on the page (or in the column, if you use them) where they ''could'' start, but on/in the next one.<br />
This is a known limitation due to the complicated calculation of remaining space on the page.<br />
That won't become better before this calculations are newly written in Lua. (Said Hans on 2010-09-24.)<br />
<br />
The following standalone example deals with all the mentioned aspects of natural tables.<br />
Just <i>copy&paste</i> it as a starting point for further experiments...<br />
<br />
<texcode><br />
\starttext<br />
<br />
\setupcolors[state=start]<br />
<br />
% setup for all cells<br />
\setupTABLE[r][each][style=\tfx\it, align=center]<br />
<br />
% setup table head<br />
\setupTABLE[r][first]<br />
[background=color,<br />
backgroundcolor=yellow]<br />
% setup table footer<br />
\setupTABLE[r][last]<br />
[style=bold,<br />
background=color,<br />
backgroundcolor=green]<br />
<br />
\bTABLE[split=repeat,option=stretch]% head on every page, stretch columns<br />
%<br />
% IMPORTANT: use \bTH ... \eTH to enclose the head|next cells<br />
\bTABLEhead<br />
\bTR<br />
\bTH head1 \eTH<br />
\bTH head2 \eTH<br />
\bTH head3 \eTH<br />
\eTR<br />
\eTABLEhead<br />
% <br />
\bTABLEnext % setup for next table head<br />
\bTR [background=color,backgroundcolor=cyan]<br />
\bTH next1 \eTH<br />
\bTH next2 \eTH<br />
\bTH next3 \eTH<br />
\eTR<br />
\eTABLEnext<br />
%<br />
% the table body (main part)<br />
%<br />
\bTABLEbody<br />
%<br />
\dorecurse{100}{% 100 rows<br />
\bTR<br />
\bTC body body body body body \eTC<br />
\bTC body body body body body \eTC<br />
\bTC body body body body body \eTC<br />
\eTR<br />
}%<br />
%<br />
\eTABLEbody<br />
%<br />
% the table foot<br />
%<br />
\bTABLEfoot<br />
\bTR<br />
\bTC foot1 \eTC<br />
\bTC foot2 \eTC<br />
\bTC foot3 \eTC<br />
\eTR<br />
\eTABLEfoot<br />
%<br />
\eTABLE<br />
<br />
\stoptext<br />
</texcode><br />
<br />
= Tables in multiple columns =<br />
<br />
... just work (at least in luaTeX and not here...). See the following example.<br />
<br />
<texcode><br />
\starttext<br />
\startcolumns[n=3]<br />
\bTABLE<br />
\dorecurse{21}<br />
{\bTR \bTD a\eTD \bTD b \eTD \eTR}<br />
\eTABLE<br />
\stopcolumns<br />
\stoptext<br />
</texcode><br />
<br />
= Creating tables from CSV data (Comma Separated Values) =<br />
<br />
See also [[m-database|the database module]]!<br />
<br />
and [http://dl.contextgarden.net/myway/csv.pdf Creating Tables using CSV (Comma-separated values)] by Mojca Miklavec<br />
<br />
<br />
<!-- Maybe some other place or a separate page is more appropriate for this section --><br />
<br />
An interesting example of creating a table using comma separated values was posted to the [http://archive.contextgarden.net/message/20050923.193302.f2110c93.en.html mailing list] by [[User:ChristopherCreutzig|Christopher Creutzig]]<br />
<br />
The following macros take care of processing CSV data:<br />
<texcode><br />
% Iterate over all the lines of text captured with \obeylines active<br />
% command to call is first argument, is not called for empty lines<br />
\bgroup<br />
\obeylines<br />
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%<br />
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%<br />
\doifnotempty{#2}{#1{#2}}%<br />
\doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%<br />
}%<br />
\egroup<br />
<br />
\def\startCSV{\bgroup\obeylines\dostartCSV}<br />
</texcode><br />
<br />
The next lines are an example of transforming the data into a natural table, but can be easily adapted to any type of the table or perhaps (mis)used in even more strange ways:<br />
<br />
<texcode><br />
\def\TBLentry#1{\bTD#1\eTD}<br />
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}<br />
<br />
\def\dostartCSV#1\stopCSV{%<br />
\bTABLE<br />
\ProcessLines\TBLline{#1}%<br />
\eTABLE<br />
\egroup<br />
}<br />
</texcode><br />
<br />
The following lines will then finally result in a desired table:<br />
<br />
<texcode><br />
% some additional settings for the table may be made as well<br />
\setupTABLE[c][2][style=\tt]<br />
\setupTABLE[c][3][align=middle]<br />
\setupTABLE[r][1][style=bold] % how to override the \tt in the second column?<br />
<br />
\startCSV<br />
Name,Email,Accepted<br />
\CONTEXT,worth@trying.to,Yes<br />
Hans,main@developer.of,Yes<br />
Bug,get@rid.of,No<br />
\stopCSV<br />
</texcode><br />
<br />
<context><br />
\setuppapersize[A5]<br />
<br />
% Iterate over all the lines of text captured with \obeylines active<br />
% command to call is first argument, is not called for empty lines<br />
\bgroup<br />
\obeylines<br />
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%<br />
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%<br />
\doifnotempty{#2}{#1{#2}}%<br />
\doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%<br />
}%<br />
\egroup<br />
<br />
\def\startCSV{\bgroup\obeylines\dostartCSV}<br />
<br />
\def\TBLentry#1{\bTD#1\eTD}<br />
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}<br />
<br />
\def\dostartCSV#1\stopCSV{%<br />
\bTABLE<br />
\ProcessLines\TBLline{#1}%<br />
\eTABLE<br />
\egroup<br />
}<br />
<br />
\setupTABLE[c][2][style=\tt]<br />
\setupTABLE[c][3][align=middle]<br />
\setupTABLE[r][1][style={\rm\bf}]<br />
\startCSV<br />
Name,Email,Accepted<br />
\CONTEXT,worth@trying.to,Yes<br />
Hans,main@developer.of,Yes<br />
Bug,get@rid.of,No<br />
\stopCSV<br />
</context><br />
<br />
Some remarks: the (tentative) code ignores the fact that<br />
* csv data may optionally be enclosed in "" quotes that have to be removed (to be done in \TBLentry) <br />
* quoted strings may contain commas themselves (which means writing a custom version of \processcommalist instead).<br />
<br />
See also {{cmd|processseparatedlist}}.<br />
<br />
= Designing complex TABLEs =<br />
<br />
Everything is easy when a simple grid is enough. Unfortunately, this<br />
is not the case most of the time, tables tend to have information<br />
which should flow accross cell boundaries either vertically<br />
or horizontally. One of the reasons to use TABLE instead of the<br />
table environment is that TABLE provides an easy (relatively speaking, <br />
at least) way to make merged cells to both directions.<br />
<br />
There are probably as many ways to design TABLEs as there are<br />
users, but a simple one to begin with is to start with a<br />
grid:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[r][each][height=0.5cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\bTABLE<br />
\bTR \bTD r1c1 \eTD \bTD r1c2 \eTD \bTD r1c3 \eTD \bTD r1c4 \eTD \bTD r1c5 \eTD \bTD r1c6 \eTD \eTR<br />
\bTR \bTD r2c1 \eTD \bTD r2c2 \eTD \bTD r2c3 \eTD \bTD r2c4 \eTD \bTD r2c5 \eTD \bTD r2c6 \eTD \eTR<br />
\bTR \bTD r3c1 \eTD \bTD r3c2 \eTD \bTD r3c3 \eTD \bTD r3c4 \eTD \bTD r3c5 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD r4c2 \eTD \bTD r4c3 \eTD \bTD r4c4 \eTD \bTD r4c5 \eTD \bTD r4c6 \eTD \eTR<br />
\bTR \bTD r5c1 \eTD \bTD r5c2 \eTD \bTD r5c3 \eTD \bTD r5c4 \eTD \bTD r5c5 \eTD \bTD r5c6 \eTD \eTR<br />
\bTR \bTD r6c1 \eTD \bTD r6c2 \eTD \bTD r6c3 \eTD \bTD r6c4 \eTD \bTD r6c5 \eTD \bTD r6c6 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
The desired table layout is then drawn onto this grid, and the top left corner cell<br />
of each cell in the final layout identified:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[r][each][height=0.5cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\setupTABLE[r][1][height=0cm,frame=off]<br />
\bTABLE<br />
\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR<br />
\bTR \bTD[nc=2,nr=2] r1c1 \eTD \bTD r1c3 \eTD \bTD[nr=2] r1c4 \eTD \bTD[nc=2,nr=2] r1c5 \eTD \eTR<br />
\bTR \bTD[nr=2] r2c3 \eTD \eTR<br />
\bTR \bTD[nc=2] r3c1 \eTD \bTD[nc=2] r3c4 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD[nc=2] r4c2 \eTD \bTD[nr=2] r4c4 \eTD \bTD[nc=2] r4c5 \eTD \eTR<br />
\bTR \bTD[nr=2,nc=2] r5c1 \eTD \bTD[nr=2] r5c3 \eTD \bTD[nr=2,nc=2] r5c5 \eTD \eTR<br />
\bTR \bTD r6c4 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
The cells are listed from left to right and up to down. Each larger cell is then given<br />
it size by using <tt>nc=...</tt> and <tt>nr=...</tt> parameters with <tt>\bTD</tt>. The<br />
code producing the table above is:<br />
<br />
<texcode><br />
\setupTABLE[r][each][height=1cm]<br />
\setupTABLE[c][each][width=1cm]<br />
\setupTABLE[r][1][height=0cm,frame=off]<br />
\bTABLE<br />
\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR<br />
\bTR \bTD[nc=2,nr=2] r1c1 \eTD \bTD r1c3 \eTD \bTD[nr=2] r1c4 \eTD \bTD[nr=2,nc=2] r1c5 \eTD \eTR<br />
\bTR \bTD[nr=2] r2c3 \eTD \eTR<br />
\bTR \bTD[nc=2] r3c1 \eTD \bTD[nc=2] r3c4 \eTD \bTD r3c6 \eTD \eTR<br />
\bTR \bTD r4c1 \eTD \bTD[nc=2] r4c2 \eTD \bTD[nr=2] r4c4 \eTD \bTD[nc=2] r4c5 \eTD \eTR<br />
\bTR \bTD[nr=2,nc=2] r5c1 \eTD \bTD[nr=2] r5c3 \eTD \bTD[nr=2,nc=2] r5c5 \eTD \eTR<br />
\bTR \bTD r6c4 \eTD \eTR<br />
\eTABLE<br />
</texcode><br />
<br />
N.B. There is an ugly hack in the code. An empty first row with zero height and no borders<br />
is added. If the row is omitted, then something odd happens to the number of<br />
columns. The table should have all cells, so this may be a bug. (Or then I have<br />
blundered something with this example, possibly.)<br />
<br />
Everything rectangular can be done with TABLE, as long as it can be fit in the grid. The grid<br />
does not have to be equidistant, and if its dimensions are omitted, the program<br />
will fit the data in. L-shaped or other complex cell shapes are not possible.<br />
Using them would be a bit odd, in any case, as alignment and text flow problems<br />
would be quite interesting.<br />
<br />
<br />
== Cell Addressing and Frames ==<br />
<br />
The setup commands for TABLE do not seem to be very verbosedly commented.<br />
There are, however, a few shorthands, which are useful to understand.<br />
First of all, there are several ways to address cells. This is a brief<br />
summary of some of them:<br />
<br />
<texcode><br />
\setupTABLE[r][(list of rows)][...]<br />
\setupTABLE[c][(list of columns)][...]<br />
\setupTABLE[(list of columns)][(list of rows)][...]<br />
</texcode><br />
<br />
A list contains one or more numbers separated by commas.<br />
Word "last" is equivalent to the number of the last row or<br />
column. The complete list can be replaced by the word "each"<br />
to address all cells on the row/column.<br />
<br />
Let us consider the following table:<br />
<br />
<texcode><br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=1.0cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
...<br />
</texcode><br />
<br />
In plain language the rows are interpreted as follows:<br />
<br />
* Align each cell in each column (i.e. all cells) horizontally in the middle<br />
and vertically in the middle (lohi), and remove all frames (borders)<br />
* The height of rows 2 -- 6 is 1.0 cm<br />
* Draw a line on top of rows 2 and 4<br />
* Draw a line to the right side of columns 1 -- 3<br />
<br />
In this case the table is slightly complicated, there are some split cells,<br />
as shown below:<br />
<br />
<table><tr valign="top"><td><br />
<texcode><br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
</td></tr></table><br />
<br />
The cell numbering is well worth noting. It is very logical (upper<br />
leftmost part of a combined cell), but sometimes the results are<br />
surprising in the beginning.<br />
<br />
The important point about cell numbering is that there is really<br />
a difference between "bottom border of row 3" and "top border of<br />
row 4". To illustrate this, let us change the frame setups:<br />
<br />
<texcode><br />
\setupTABLE[r][2,4][topframe=on]<br />
</texcode><br />
<br />
is changed to<br />
<br />
<texcode><br />
\setupTABLE[r][1,3][bottomframe=on]<br />
</texcode><br />
<br />
At first sight this is exactly the same thing. But...<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][1,3][bottomframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
Where did the horizontal line in column 3 disappear? Nowhere. There is no<br />
row 3 in column 3, so there cannot be a frame under it. This problem<br />
can be overcome by using topframe and leftframe instead of bottom and<br />
right, as the cells below and to the right of a border have to exist.<br />
<br />
However, this solution leaves the problem of bottom and rightmost borders.<br />
How to draw a line in the bottom of the table? Using <br />
<tt>\setupTABLE[r][6][bottomframe=on]</tt> will leave the gap in columns 3 and 4, <br />
and <tt>\setupTABLE[r][7][topframe=on]</tt> is not possible, as there is no <br />
row 7. The clever idea of using "last" instead of the row number (6) will fail, <br />
as "last" seems to behave exactly the same way as number 6.<br />
<br />
One useful method is to switch on the borders cell by<br />
cell by adding <tt>\setupTABLE[3,4][4][bottomframe=on]</tt>, i.e.<br />
draw a border under cells r4c3 and r4c4.<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\setupTABLE[c][each][align={middle,lohi},frame=off]<br />
\setupTABLE[r][2,3,4,5,6][height=0.5cm]<br />
\setupTABLE[r][2,4][topframe=on]<br />
\setupTABLE[c][1,2,3][rightframe=on]<br />
\setupTABLE[r][6][bottomframe=on]<br />
\setupTABLE[3,4][4][bottomframe=on]<br />
\bTABLE<br />
\bTR<br />
\bTD \bf r1c1 \eTD<br />
\bTD \bf r1c2 \eTD<br />
\bTD \bf r1c3 \eTD<br />
\bTD \bf r1c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r2c1 \eTD<br />
\bTD r2c2 \eTD<br />
\bTD[nr=2] r2c3 \eTD<br />
\bTD r2c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r3c1 \eTD<br />
\bTD r3c2 \eTD<br />
\bTD r3c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r4c1 \eTD<br />
\bTD r4c2 \eTD<br />
\bTD[nr=3] r4c3 \eTD<br />
\bTD[nr=3] r4c4 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r5c1 \eTD<br />
\bTD r5c2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD r6c1 \eTD<br />
\bTD r6c2 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Column Offset/Gap ==<br />
<br />
From the mailing list at 2005-11-09 by Vit Zyka, modified by Hans Hagen:<br />
<br />
<texcode><br />
\starttext<br />
<br />
% distance mechanism, per column (H)<br />
<br />
\start<br />
\setupTABLE[c][1][distance=2em]<br />
\setupTABLE[c][2][distance=3em]<br />
<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR<br />
\eTABLE<br />
<br />
\bTABLE[option=stretch]<br />
\bTR \bTD test \eTD \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD[nx=2] test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD[nx=2] test \eTD \eTR<br />
\eTABLE<br />
\stop<br />
<br />
% distance mechanism, per table (V)<br />
<br />
\framed[offset=none]{%<br />
\setupTABLE[column][2][align=left]<br />
\setupTABLE[column][3][align=right]<br />
\bTABLE[columndistance=2cm,leftmargindistance=.3cm,rightmargindistance=.5cm]<br />
\bTR<br />
\bTH[nc=3] Table head\eTH<br />
\eTR<br />
\bTR\bTD[nc=2] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD[nc=2,align=left] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD[nc=2,align=middle] AB\eTD\bTD C\eTD\eTR<br />
\bTR\bTD A\eTD\bTD B\eTD\bTD C\eTD\eTR<br />
\bTR\bTD Aa\eTD\bTD Bb\eTD\bTD Cccc\eTD\eTR<br />
\bTR\bTD[nc=3,align=middle] ABC\eTD\eTR<br />
\eTABLE<br />
}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Make a cell bold ==<br />
<br />
Drawing bold lines around a cell is done using the<br />
<tt>[rulethickness=''dim'']</tt> key on a cell. The thicker rules will<br />
offset the text inside the cell both downwards and sideways, so care<br />
should be taken that the cell's increased rulethickness is offset by an<br />
equal decrease in offset.<br />
<br />
<context source="yes" text="produces"><br />
\setupTABLE[row][each][rulethickness=.25pt,offset=\dimexpr1mm+1.75pt] <br />
\bTABLE<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 2/3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 2 \eTD \bTD[rulethickness=2pt,offset=1mm] 2 \eTD \bTD 3 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 4 \eTD \eTR<br />
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 2 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
A more realistic example: an invoice with thick rules.<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
{\bfa Invoice}<br />
\switchtobodyfont[6pt]<br />
\blank<br />
\bTABLE<br />
\setupTABLE[frame=off,offset=1mm]<br />
\setupTABLE[row][*][height=7.25mm]<br />
\setupTABLE[column][1]%<br />
[width=18mm,<br />
offset=\dimexpr1mm+2pt,<br />
align=flushleft]<br />
\setupTABLE[column][2]%<br />
[width=20mm,<br />
offset=\dimexpr1mm+2pt,<br />
align=flushleft]<br />
\setupTABLE[column][3]%<br />
[width=18mm,<br />
offset=\dimexpr1mm+2pt,<br />
align=flushright]<br />
\setupTABLE[column][4]%<br />
[width=18mm,<br />
offset=\dimexpr1mm+2pt,<br />
align=flushright]<br />
\setupTABLE[column][5]%<br />
[width=18mm,<br />
offset=\dimexpr1mm+2pt,<br />
align=left]<br />
\bTR[bottomframe=on, rulethickness=2pt,offset=1mm]<br />
\bTD\bf Date \eTD<br />
\bTD\bf Description \eTD<br />
\bTD\bf Quantity \eTD<br />
\bTD\bf Price \eTD<br />
\bTD\bf Total \eTD<br />
\eTR<br />
\bTR[bottomframe=on,rulethickness=.25pt]<br />
\bTD 05-01-2010 \eTD<br />
\bTD Element 1 \eTD<br />
\bTD 10.0 \eTD<br />
\bTD 6.00 \eTD<br />
\bTD 60.00 \eTD<br />
\eTR<br />
\bTR[bottomframe=on,rulethickness=.25pt]<br />
\bTD 05-01-2010 \eTD<br />
\bTD Element 2 \eTD<br />
\bTD 2.0 \eTD<br />
\bTD 3.00 \eTD<br />
\bTD 6.00 \eTD<br />
\eTR<br />
\bTR[topframe=on,rulethickness=2pt,offset=1mm]<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] Subtotal \eTD<br />
\bTD 66.00 \eTD<br />
\eTR<br />
\bTR[offset=\dimexpr1mm+2pt]<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] VAT 19\% \eTD<br />
\bTD 12.54 \eTD<br />
\eTR<br />
\bTR<br />
\bTD[nx=3] \eTD<br />
\bTD[align=flushleft] \bf Total \eTD<br />
\bTD 78.54 \eTD<br />
\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Rules with different thickness ==<br />
<br />
There is only one value for all four borders. However, MetaPost can be used as a workaround until the separate "rulethickness" values are implemented.<br />
<br />
The following example (mkiv only!) by Wolfgang Schuster shows a table using MetaPost for the rules:<br />
<br />
<texcode><br />
\startuseMPgraphic{tableborders}<br />
<br />
draw leftboundary OverlayBox withpen pensquare scaled \frameddimension {leftrulethickness} ;<br />
draw rightboundary OverlayBox withpen pensquare scaled \frameddimension {rightrulethickness} ;<br />
draw topboundary OverlayBox withpen pensquare scaled \frameddimension {toprulethickness} ;<br />
draw bottomboundary OverlayBox withpen pensquare scaled \frameddimension{bottomrulethickness} ;<br />
<br />
clip currentpicture to OverlayBox<br />
leftenlarged (\frameddimension {leftrulethickness}/2)<br />
rightenlarged (\frameddimension {rightrulethickness}/2)<br />
topenlarged (\frameddimension {toprulethickness}/2)<br />
bottomenlarged (\frameddimension{bottomrulethickness}/2) ;<br />
<br />
setbounds currentpicture to OverlayBox ;<br />
<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay[tableborders][\useMPgraphic{tableborders}]<br />
<br />
\startsetups tableborders<br />
<br />
\setupTABLE<br />
[ background={color,tableborders},<br />
frame=off,<br />
backgroundoffset=0pt,<br />
leftrulethickness=\framedparameter{rulethickness},<br />
rightrulethickness=\framedparameter{rulethickness},<br />
toprulethickness=\framedparameter{rulethickness},<br />
bottomrulethickness=\framedparameter{rulethickness}]<br />
<br />
\setupTABLE[row] [odd] [backgroundcolor=lightgray]<br />
\setupTABLE[row] [first][backgroundcolor=gray,bottomrulethickness=2pt]<br />
\setupTABLE[row] [last] [toprulethickness=2pt,bottomrulethickness=2pt]<br />
\setupTABLE[first][last] [leftrulethickness=2pt]<br />
\setupTABLE[last] [last] [rightrulethickness=2pt]<br />
<br />
\stopsetups<br />
<br />
\starttext<br />
<br />
\bTABLE<br />
\dorecurse{7}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}<br />
\eTABLE<br />
<br />
\blank<br />
<br />
\bTABLE[setups=tableborders]<br />
\dorecurse{7}{\bTR\dorecurse{3}{\bTD#1-##1\eTD}\eTR}<br />
\eTABLE<br />
<br />
\stoptext<br />
</texcode><br />
<br />
See the corresponding thread on the list: [http://www.ntg.nl/pipermail/ntg-context/2011/058549.html rules with different thickness]<br />
<br />
== Diagonal rules ==<br />
<br />
Sometimes a diagonal rule is required in the top left corner cell of a table to create two fields, one for the left column and one for the top row.<br />
<br />
<br />
<context mode="mkiv" source="yes" text="Gives:"><br />
\startuseMPgraphic{DiagonalRule}<br />
rulethickness := \frameddimension{rulethickness};<br />
<br />
drawoptions(<br />
withpen pencircle scaled rulethickness<br />
withcolor \MPcolor{\framedparameter{framecolor}});<br />
<br />
pair leftcorner, rightcorner;<br />
leftcorner := (rulethickness, \overlayheight-rulethickness);<br />
rightcorner := (\overlaywidth-rulethickness, rulethickness);<br />
<br />
draw leftcorner -- rightcorner;<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay<br />
[DiagonalRule]<br />
[\useMPgraphic{DiagonalRule}]<br />
<br />
\define[2]\DiagonalLabel{%<br />
\setuptabulate [after={\blank[\frameddimension{offset}]}]<br />
\starttabulate [|p|r|]<br />
\NC \NC #2 \NC\NR<br />
\NC #1 \NC \NC\NR<br />
\stoptabulate<br />
}<br />
<br />
\starttext<br />
\setupTABLE [row] [1] [width=2cm]<br />
\bTABLE<br />
\bTR<br />
\bTD [background=DiagonalRule]<br />
\DiagonalLabel{Foo}{Bar}<br />
\eTD<br />
\bTD Second \eTD<br />
\bTD Third \eTD<br />
\eTR<br />
\bTR<br />
\bTD Alpha \eTD<br />
\bTD Beta \eTD<br />
\bTD Gamma \eTD<br />
\eTR<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
This solution has (at least) one caveat: Because the first<br />
tabulate column is set in paragraph mode, it will eat up as much<br />
space as <em>possible</em>, in contrast to occupying as much space as<br />
</em>necessary</em>. That is why the width of the column has to be set<br />
explicitly.<br />
<br />
== Using character alignment ==<br />
<br />
ConTeXt can align columns of numbers on a character (often a decimal point to align accounting data) automatically, removing the need to add fixed spaces into your document. For any such column you need to specify the character on which to align. You use the <tt>aligncharacter=yes</tt> parameter to set up character alignment, <tt>alignmentcharacter={.}</tt> to say what the character should be (in this case a full stop) and <tt>align=middle</tt> to set the overall alignment of the column.<br />
<br />
<table><tr valign="top"><td><br />
<texcode><br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},<br />
aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</texcode><br />
</td><td><br />
<context><br />
\setuppapersize[A5]<br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</context><br />
</td></tr></table><br />
<br />
You'll note that the final line, because it has no <code>.</code> in the number, gets aligned under the right-hand side of the numbers. In most circumstances you would want such a number aligned with the left-hand set of digits. To so do, issue the following command in your preamble:<br />
<br />
<texcode><br />
\chardef\characteralignmentmode=2<br />
</texcode><br />
<br />
and now the table above will turn out like this:<br />
<br />
<context><br />
\setuppapersize[A5]<br />
\chardef\characteralignmentmode=2<br />
\bTABLE<br />
\setupTABLE[column][1][align=right]<br />
\setupTABLE[column][2][alignmentcharacter={.},aligncharacter=yes,align=middle]<br />
\bTR \bTH Category \eTH \bTH Data entry \eTH \eTR<br />
\bTR \bTD First \eTD \bTD 71.3 \eTD \eTR<br />
\bTR \bTD Second \eTD \bTD 43.7 \eTD \eTR<br />
\bTR \bTD Total \eTD \bTD 115 \eTD \eTR<br />
\eTABLE<br />
</context><br />
<br />
If there's no <code>alignmentcharacter</code> in the cell, the content will be aligned in the following way depending on the value of <code>\characteralignmentmode</code>:<br />
<table style="border:1px solid #DDDDDD;"><br />
<tr style="background-color:#DDDDDD; font-weight: bold;"><td>mode</td><td width="200"></td><td>.</td><td width="200"></td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">0</td><td colspan="3" align="center">centered</td></tr><br />
<tr style="background-color:#EEEEEE;"><td style="background-color:#DDDDDD" align="center">1</td><td align="left">left in before</td><td style="background-color:#DDDDDD">.</td><td></td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">2</td><td align="right">right in before</td><td style="background-color:#DDDDDD">.</td><td></td></tr><br />
<tr style="background-color:#EEEEEE;"><td style="background-color:#DDDDDD" align="center">3</td><td></td><td style="background-color:#DDDDDD">.</td><td align="left">left in after</td></tr><br />
<tr><td style="background-color:#DDDDDD" align="center">4</td><td></td><td style="background-color:#DDDDDD">.</td><td align="right">right in after</td></tr><br />
</table><br />
<br />
== Specifying the cell column ==<br />
<br />
When writing a table you can omit empty cells and define only cells for specified columns. To have this feature fully available you need to have a beta or a quite fresh ConTeXt version.<br />
<br />
Two methods are available:<br />
<br />
* With the TD "n" option, the undefined cells are merged into a single spanned cell.<br />
* With the TD "m" option, the undefined cells appear as empty normal cells.<br />
<br />
Here is an example using the "n" option:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\bTABLE[width=3em]<br />
\bTR\bTD d1 \eTD\bTD[n=2] d2 \eTD\bTD[n=5] d5 \eTD\bTD[n=7] d7 \eTD\eTR<br />
\bTR\bTD f1 \eTD\bTD[n=4] f4 \eTD\bTD[n=5] f5 \eTD\bTD[n=7] f7 \eTD\eTR<br />
\eTABLE<br />
</context><br />
<br />
Here is an example using the "m" option:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
\bTABLE[width=3em]<br />
\bTR\bTD d1 \eTD\bTD[m=2] d2 \eTD\bTD[m=5] d5 \eTD\bTD[m=7] d7 \eTD\eTR<br />
\bTR\bTD f1 \eTD\bTD[m=4] f4 \eTD\bTD[m=5] f5 \eTD\bTD[m=7] f7 \eTD\eTR<br />
\eTABLE<br />
</context><br />
<br />
== Round corners ==<br />
<br />
For a different approach for round corners and colored background follow the text after this example.<br />
<br />
It is possible to round the corners of the table if you turn off the main frame of the table and frame the table in {{cmd|framed}}. Compare two different approaches in the first and second example.<br />
<br />
You can't color the background of the table with round corners unless the frame rulethickness is not big enough to cover the rectangular corners of the background (second example). Well, you can if you frame the table twice. Once in the thick white frame and then in the thin frame with negative offset and slightly smaller corner radius (third example). Be aware of other complications -- notice that the thick white frame is still visible in the text above it.<br />
<br />
<context source="yes"><br />
\starttext<br />
\setupcolors[state=start] <br />
%\showstruts<br />
\setupTABLE[background=color,backgroundcolor=yellow]<br />
\setupframed[framecolor=darkgreen]<br />
<br />
\defineparagraphs[ThreeCols]<br />
<br />
\startThreeCols<br />
<br />
First<br />
<br />
\def\StartTable<br />
{\setupTABLE[row] [first][topframe=off]%<br />
\setupTABLE[row] [last] [bottomframe=off]%<br />
\setupTABLE[column][first][leftframe=off]%<br />
\setupTABLE[column][last] [rightframe=off]%<br />
\framed[strut=no,corner=round,offset=.5\linewidth]<br />
\bgroup}<br />
<br />
\def\StopTable<br />
{\egroup}<br />
<br />
\StartTable<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\StopTable<br />
<br />
\nextThreeCols<br />
<br />
Second<br />
<br />
\setupTABLE[row] [first][topframe=off]<br />
\setupTABLE[row] [last] [bottomframe=off]<br />
\setupTABLE[column][first][leftframe=off]<br />
\setupTABLE[column][last] [rightframe=off]<br />
\framed[strut=no,corner=round,offset=.5\linewidth,,rulethickness=1mm]\bgroup<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\egroup<br />
<br />
\nextThreeCols<br />
<br />
Third<br />
<br />
\setupTABLE[row] [first][topframe=off]<br />
\setupTABLE[row] [last] [bottomframe=off]<br />
\setupTABLE[column][first][leftframe=off]<br />
\setupTABLE[column][last] [rightframe=off]<br />
\framed[strut=no,corner=round,<br />
radius=1.4mm,offset=-1mm,,rulethickness=.1mm]\bgroup<br />
\framed[strut=no,corner=round,<br />
radius=1.5mm,offset=0mm,,rulethickness=1mm,framecolor=white]\bgroup<br />
\bTABLE<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\bTR \bTD test \eTD \bTD test \eTD \eTR<br />
\eTABLE<br />
\egroup<br />
\egroup<br />
<br />
\stopThreeCols<br />
<br />
\stoptext<br />
</context><br />
<br />
From 2006-10-11 on, ConTeXt contains one more mechanism for round corners. Watch the example:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\starttext<br />
\setupcolors[state=start]<br />
\setupTABLE [y] [first][background=color,backgroundcolor=blue,frame=off,bottomframe=on,topframe=on,framecolor=white]<br />
\setupTABLE [first][first][backgroundcorner=2,corner=10,frame=on]<br />
\setupTABLE [last] [first][backgroundcorner=4,corner=12,frame=on]<br />
\setupTABLE [row] [each] [background=color,backgroundcolor=blue,frame=on,framecolor=white]<br />
\setupTABLE [first][2] [corner=8]<br />
\setupTABLE [last] [2] [corner=5]<br />
\setupTABLE [first][last] [corner=7]<br />
\setupTABLE [last] [last] [corner=6]<br />
<br />
\bTABLE[frame=off,align=middle]<br />
\bTR \bTD one \eTD \bTD two \eTD \bTD three \eTD \eTR<br />
\bTR \bTD first \eTD \bTD second \eTD \bTD third \eTD \eTR<br />
\bTR \bTD alpha \eTD \bTD beta \eTD \bTD gamma \eTD \eTR<br />
\eTABLE<br />
\stoptext<br />
</context><br />
<br />
== Other options ==<br />
<br />
Some other useful options that were not covered above:<br />
* <tt>align=yes</tt> will align the text both left and right justified<br />
* <tt>loffset</tt>, <tt>roffset</tt>, <tt>toffset</tt>, <tt>boffset</tt> can be used in addition to <tt>offset</tt> to specify cell content offsets in each direction separately, see also {{cmd|framed}}<br />
<br />
= TABLEs with old table syntax =<br />
<br />
From the mailing list in March 2009, by Wolfgang Schuster and Hans Hagen:<br />
<br />
<texcode><br />
\def\startTABLE<br />
{\dosingleempty\dostartTABLE}<br />
<br />
\def\dostartTABLE[#1]%<br />
{\bgroup<br />
\bTABLE[#1]%<br />
\let\NC\doTABLENC<br />
\let\NR\doTABLENR<br />
\let\bTR\relax<br />
\let\bTD\relax<br />
\let\bTH\relax<br />
\let\bTN\relax}<br />
<br />
\def\stopTABLE<br />
{\eTABLE<br />
\egroup}<br />
<br />
\newconditional\inTABLEnc<br />
<br />
\unexpanded\def\doTABLENR<br />
{\eTR<br />
\setfalse\inTABLEnc}<br />
<br />
\unexpanded\def\doTABLENC<br />
{\futurelet\next\dodoTABLENC}<br />
<br />
\def\dodoTABLENC<br />
{\ifx\next\doTABLENR \else<br />
\expandafter\dododoTABLENC<br />
\fi}<br />
<br />
\long\def\dododoTABLENC#1\NC<br />
{\ifconditional\inTABLEnc\else\settrue\inTABLEnc\parseTR[][]\fi<br />
\dodoubleempty\parseTD#1\eTD\NC}<br />
</texcode><br />
<br />
This is now part of the core as the [[source:tabl-nte.tex|NTE module]]. Quoting its internal documentation:<br />
<br />
This module is suggested by Wolfgang Schuster who also prototyped it and came up with the rationale:<br />
<br />
This module provides an easy way to use natural in a similiar way as the older table module (based on the [[TABLE]] macros) and the newer [[tabulate]] module.<br />
<br />
You can see the advantage in the following table, once created with the new macros and once with the normal macros provided with the natural table module.<br />
<br />
Let us start with the original macros:<br />
<br />
<texcode><br />
\bTABLE<br />
\bTR<br />
\bTD Text 1 \eTD<br />
\bTD Text 2 \eTD<br />
\eTR<br />
\bTR<br />
\bTD Text 3 \eTD<br />
\bTD Text 4 \eTD<br />
\eTR<br />
\eTABLE<br />
</texcode><br />
<br />
Watch how the new macros use less code:<br />
<br />
<texcode><br />
\startTABLE<br />
\NC Text 1 \NC Text 2 \NC\NR<br />
\NC Text 3 \NC Text 4 \NC\NR<br />
\stopTABLE<br />
</texcode><br />
<br />
The actual code differs from the prototype that it does not need to collect whole rows and parse them but looks ahead instead.<br />
<br />
[[Category:Tables]]<br />
[[Category:XML]]<br />
tt>\bTD</div>Marcohttps://wiki.contextgarden.net/index.php?title=Columns&diff=20146Columns2012-07-24T16:45:02Z<p>Marco: Adapt code for “Vertical lines between columnsets” to current beta</p>
<hr />
<div>< [[Visuals]] | [[Layout]] ><br />
<br />
There are different possibilities to typeset text in two or more columns:<br />
* columns : for simple cases of multi column text<br />
* paragraphs : if you need a table-like structure (translations, questionaires etc.)<br />
* column sets : the flexible way for varying columns or other complex tasks<br />
* streams : set different text synchronized side-by-side (e.g. bilingual editions)<br />
<br />
Columns and columnset are two different mechanism to produce a document<br />
with text and two or more columns. <br />
* The <code>columns</code> mechanism is the older one with limited control about the placement of figures but allows you to mix one column and multicolumns text on a page. <br />
* <code>columnsets</code> is a new version of the column mechanism with more control about the placement of figures and other features like spanned columns etc. (look at the [[Columns#Column_Sets|manual]] for more); it is better than <code>columns</code> for magazine-like layouts.<br />
<br />
=Columns=<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startcolumns[n=3]<br />
\input knuth<br />
\stopcolumns<br />
</context><br />
<br />
You can add all the options of {{cmd|setupcolumns}} to {{cmd|startcolumns}}. For example, simple ruled columns are easy:<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startcolumns[n=2,rule=on]<br />
\input knuth<br />
\stopcolumns<br />
</context><br />
<br />
Normally, columns are automatically balanced with the text distributed over the number or requested columns. You can provoke a column switch using {{cmd|column}}.<br />
<br />
<context source=yes><br />
\setuppapersize[A5]<br />
<br />
\startcolumns[n=2]<br />
\input ward<br />
\column<br />
\input weisman<br />
\stopcolumns<br />
</context><br />
<br />
Column balancing fails in "lines" mode (e.g. for poetry).<br />
<br />
=Paragraphs=<br />
<br />
Paragraphs are useful in collecting text to be displayed together.<br />
For example:<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
\enableregime[utf]<br />
<br />
\defineparagraphs[TwoThird][n=2]<br />
<br />
% The width of the second paragraph is automatically calculated if unspecified.<br />
\setupparagraphs[TwoThird][1][width=.66\textwidth]<br />
<br />
\startTwoThird<br />
\quotation{...{\it why is there something rather than nothing?}<br />
For nothing is simpler and easier than something.<br />
Furthermore, assuming that things must exist,<br />
one must be able to explain<br />
{\it why they must exist thus,}<br />
and not otherwise.}<br />
\nextTwoThird<br />
G. W. Leibniz, {\it\fr Principes de la nature et de la grâce fondés en raison,} 1714.<br />
\stopTwoThird<br />
</context><br />
<br />
See "Paragraphs in Columns" section in the [[manual:cont-enp.pdf|manual]]<br />
for further details.<br />
<br />
=(Simple)Columns in a narrow frame=<br />
To put multiple columns in a frame, this works:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\framed[width=0.9\hsize,location=middle]\bgroup<br />
\startnarrower[2*middle]<br />
\setlocalhsize \hsize\localhsize <br />
\startsimplecolumns<br />
\input tufte<br />
\stopsimplecolumns<br />
\stopnarrower<br />
\egroup<br />
</context><br />
<br />
Another possibility is to use [[TextBackground|textbackground]] around the text. (The examples don't work in this wiki because, for security reasons, it has [[write18]] disabled. They should work for you, though, provided that [[write18]] is enabled on your local installation.)<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\setupcolors[state=start]<br />
\definetextbackground [book]<br />
[state=start, topoffset=.5ex, location=paragraph,<br />
leftoffset=1ex,bottomoffset=1ex]<br />
<br />
\starttextbackground[book]<br />
Tufte again<br />
\startcolumns[n=2]<br />
\input tufte<br />
\stopcolumns<br />
\stoptextbackground<br />
</context><br />
<br />
=Column Sets=<br />
<br />
An alternative method of typesetting text into columns uses columnsets.<br />
This method offers more possibilities than simple columns,<br />
in particular in placing floats such as figures and in creating columnspans.<br />
See [[manual:columns.pdf|Columns manual]] or [[source:page-set.tex|column sets source]] for many examples.<br />
<br />
If you don't need much more than the "normal" columns, but e.g. "lines" mode, try this:<br />
<br />
<context source="yes"><br />
\setuppapersize[A5]<br />
<br />
\definecolumnset[TwoColumns][n=2]<br />
<br />
\startcolumnset[TwoColumns]<br />
<br />
\startlines % enforce line breaks<br />
Starlight, star bright,<br />
first star I see tonight;<br />
\stoplines<br />
<br />
\column<br />
<br />
\startlines<br />
I wish I may, I wish I might<br />
have the wish I wish tonight.<br />
\stoplines<br />
<br />
\stopcolumnset<br />
</context><br />
<br />
For more details (layout grid features, spreads, different column widths etc.) please refer to the [[manual:columns.pdf|manual]]!<br />
<br />
==Vertical lines between columnsets (rules)==<br />
<br />
Sometimes it is required to have a vertical line between the columns of your columnset. This code draws MetaPost lines in the right place:<br />
<br />
<texcode><br />
\startuseMPgraphic{verticalrule}<br />
if CurrentColumn < NOfColumns :<br />
draw rightboundary OverlayBox shifted (4mm,0);<br />
setbounds currentpicture to OverlayBox enlarged 2.5mm;<br />
fi<br />
\stopuseMPgraphic<br />
<br />
\defineoverlay<br />
[verticalrule]<br />
[\useMPgraphic{verticalrule}]<br />
<br />
\definecolumnset<br />
[example]<br />
[n=2,<br />
background=verticalrule]<br />
<br />
\starttext<br />
\startcolumnset [example]<br />
\dorecurse{4}{\input knuth}<br />
\stopcolumnset<br />
\stoptext<br />
</texcode><br />
<br />
=Streams=<br />
<br />
From the [[http://archive.contextgarden.net/message/20060331.175831.414d087b.en.html announcement mail]] by Thomas Schmitz:<br />
<br />
We have streams for even and odd pages that can be synchronized at certain points. <br />
This is useful for, e.g., typesetting bilingual books: have the original on the even pages, the translation on the odd pages, and synchronize at certain points.<br />
<br />
For details see [[source:m-streams.tex|streams module source]]<br />
<br />
The module provides a rather low-lever interface. Hans suggested some handy shortcuts:<br />
<texcode><br />
\usemodule[streams] <br />
<br />
\def\StartCouple{\page\SwitchToNormal} <br />
\def\StopCouple {\SwitchToNormal \SynchronizeLeftAndRight \FlushLeftAndRight} <br />
\def\Original {\SwitchToNormal\SynchronizeLeftAndRight\SwitchToLeft} <br />
\def\Translation{\SwitchToRight} <br />
<br />
\Original\en<br />
Are you sleeping, brother John?<br />
<br />
\Translation\de<br />
Bruder Jakob, schläfst du noch?<br />
</texcode><br />
<br />
So you put the part of your document where synchronization should take place between <cmd>StartCouple</cmd> and <cmd>StopCouple</cmd>. After that , <cmd>Original</cmd> and <cmd>Translation</cmd> switches between even and odd pages. <br />
<br />
Beware, streams don't work in columns and not very good in columnsets.<br />
<br />
{{todo|We need documentation and samples for Paragraphs, Streams and Column Sets}}<br />
<br />
=Floats and other limitations of columns=<br />
<br />
Columns and one-column floats don't work well together in TeX. It seems that you can't have a float that spans one column automatically put at the top or the bottom and have the columns balanced automatically at the end. Neither ConTeXt nor LaTeX can do it in a automatized way (like with floats that span more than a column). Here you have some tricks to make it work more or less:<br />
<br />
==Columnsets==<br />
<br />
With columnsets you can put floats that span one, two or any number of columns and in any position (top, bottom, middle of the text). The price for this is that you have to balance the columns manually at the end (see [[manual:columns.pdf|Columnset manual]]).<br />
<br />
Columnsets have a limitation, however: they are very strongly grid-based, and you can't change the interlinespace within the columnset (e.g., if some paragraphs are typed in a smaller font). You can change the interlinespace if the entire text with a smaller interlinespace fits in one column, like a float or a section title (putting it between <code>\startlinecorrection\stoplinecorrection</code>), but if the text with a smaller interlinespace starts in one column and has to continue in the following one, nothing will work, and the layout will be completely messed.<br />
<br />
Changing the font weight or shape inbetween <cmd>startcolumnset</cmd> and <cmd>stopcolumnset</cmd> may cause some columns to be shifted vertically. Then you must use <cmd>restoreinterlinespace</cmd> after the font switch (<cmd>bf</cmd>, <cmd>ss</cmd>) to correct the interline spacing. See [http://thread.gmane.org/gmane.comp.tex.context/20932].<br />
<br />
So, if you want columns and one-column floats and don't have to change the interlinespacing, use Columnsets. If not, you can use Columns with some tricks.<br />
<br />
==Columns and Floats ==<br />
<br />
With Columns you have the columns automatically balanced at the end, but only certain floats are "officially" supported:<br />
<br />
* '''Floats that span more than a column at the top of the following page'''<br />
* '''Floats that span one column in the middle of the text, accidentally at the top of the following page'''<br />
<br />
Here, the optional argument <code>placefloat[here, top, bottom, etc.]</code> does nothing. When you place a float, if its width is larger than the column width (<code>\textwidth</code>), that float will be automatically put at the top of the following page, spanning the columns needed. If its width is shorter than the column width, the float will be put in the middle of the text, spanning one column. If there is not enough space left in the column, it will float until the top of the following column. You can use this method to put floats at the top of a column, but it's not recommended, because it is tedious and if you change the text before the float, you will probably find it then in the middle of the column.<br />
<br />
There is a semi-automatic way to put:<br />
<br />
* '''Floats that span one column at the top of the left column of a page'''<br />
* '''Any float in a separated page, without text'''<br />
<br />
with the possibility of changing the text and having the float always correctly put, like with "officially" supported floats, using <code>\startpostponing\stoppostponing</code>. Everything that goes into this environment will be put at the beginning of the next page, or in the page indicated in the optional argument (e.g., <code>\startpostponing[34]</code>; see [[Latex_Packages#afterpage|this wiki entry]]). If we write<br />
<br />
<texcode><br />
\startpostponing[35]<br />
\vbox{\vskip-\baselineskip<br />
\placefigure{caption}{\externalfigure[file][width=\textwidth]}<br />
}<br />
\stoppostponing<br />
</texcode><br />
<br />
the figure will be put at the top of the first column at page 35, or four pages further on, if we put [+4], or on the following page, with no optional argument. The figure has to be enclosed in a box, or the grid will be broken. Putting the figure in a box lowers it a line (why?), so it has to be corrected with the <code>\vskip-\baselineskip</code>.<br />
<br />
You can put more than a float in the same column, but they have to be into the same box, or the grid will be broken<br />
<br />
<texcode><br />
\startpostponing<br />
\vbox{\vskip-\baselineskip<br />
\placefigure{caption}{\externalfigure[file][width=\textwidth]}<br />
\placefigure{caption2}{\externalfigure[file2][width=\textwidth]}<br />
}<br />
\stoppostponing<br />
</texcode><br />
<br />
With this method you can put a float in a separated page, without any text<br />
<br />
<texcode><br />
\startpostponing[+5]<br />
\vbox{<br />
\placefigure{caption}{\externalfigure[file][width=\makeupwidth]}<br />
}<br />
\page<br />
\stoppostponing<br />
</texcode><br />
<br />
And you can use it to put a float that span more than a column in a page other than the one chosen by the algorithm (without <code>\vbox</code>):<br />
<br />
<texcode><br />
\startpostponing[67]<br />
\placefigure{caption}{\externalfigure[file][width=\makeupwidth]}<br />
\stoppostponing<br />
</texcode><br />
<br />
This has some limitations, too. If you put a float at the top of a column and there is another float that spans more than a column over all, the grid will be broken, so you have to put it in another page, but you can put more than one float of the same type together, as seen above.</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setupheads&diff=20053Command/setupheads2012-07-18T14:53:32Z<p>Marco: Add insidesection with example</p>
<hr />
<div>{{Reference<br />
|name=setupheads<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupheads<span class="first" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:sectionnumber|sectionnumber]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:number|number]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:alternative|alternative]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:margin|margin]] [[Command/value:middle|middle]] [[Command/value:text|text]] [[Command/value:paragraph|paragraph]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:separator|separator]]</td><br />
<td>[[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:stopper|stopper]]</td><br />
<td>[[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:flushleft|flushleft]] [[Command/value:flushright|flushright]] [[Command/value:normal|normal]] [[Command/value:broad|broad]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:aligntitle|aligntitle]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:float|float]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:tolerance|tolerance]]</td><br />
<td>[[Command/value:verystrict|verystrict]] [[Command/value:strict|strict]] [[Command/value:tolerant|tolerant]] [[Command/value:verytolerant|verytolerant]] [[Command/value:stretch|stretch]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:indentnext|indentnext]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:command|command]]</td><br />
<td>[[Command/value:twoarguments|twoarguments]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:margin|margin]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[[Command/keyword:insidesection|insidesection]]</td><br />
<td>[[Command/value:COMMAND|COMMAND]] </td><br />
</tr><br />
<br />
</table><br />
<br />
== Description == <br />
Note that this command has been reported non-working for some people (but it seems to work fine for me).<br />
<br />
This command sets up the default options for all headings (e.g., the stuff generated by {{cmd|section}}, {{cmd|subsection}}, etc.). The {{cmd|setuphead}} command can be used to override these settings on a per-level basis (e.g., only for \section) and has some extra options as well.<br />
<br />
aligntitle=float causes the title to appear next to floats. By default, a title will be moved down to appear below a float, it will not be "wrapped" around a float like normal text. Setting this option causes it to wrap like normal text.<br />
<br />
The <code>insidesection</code> command is injected right after the <code>after</code> command of <code>\setuphead</code>. It can be used for example to insert a table of contents local to a chapter. <code>insidesection</code> only works with the <code>\startchapter, \startsection, …</code> variants, not with <code>\chapter, \section, …</code>.<br />
<br />
== Example ==<br />
Table of contents local to a chapter:<br />
<br />
<texcode><br />
\setuphead<br />
[chapter]<br />
[after={\blank[1cm]},<br />
insidesection=\placecontent]<br />
<br />
\starttext<br />
<br />
\startchapter [title=Foo]<br />
\startsection [title=Zapf]<br />
\input zapf<br />
\stopsection<br />
\startsection [title=Knuth]<br />
\input knuth<br />
\stopsection<br />
\stopchapter<br />
<br />
\stoptext<br />
</texcode><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/Sections|setupheads]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setupmakeup&diff=19668Command/setupmakeup2012-06-12T14:05:31Z<p>Marco: Add information and example</p>
<hr />
<div>{{Reference<br />
|name=setupmakeup<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupmakeup<span class="first" >[...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:width|width]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:height|height]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:voffset|voffset]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:hoffset|hoffset]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:page|page]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:yes|yes]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:commands|commands]]</td><br />
<td>[[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:doublesided|doublesided]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:empty|empty]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:headerstate|headerstate]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:stop|stop]] [[Command/value:start|start]] [[Command/value:empty|empty]] [[Command/value:none|none]] [[Command/value:nomarking|nomarking]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:footerstate|footerstate]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:stop|stop]] [[Command/value:start|start]] [[Command/value:empty|empty]] [[Command/value:none|none]] [[Command/value:nomarking|nomarking]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:textstate|textstate]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:stop|stop]] [[Command/value:start|start]] [[Command/value:empty|empty]] [[Command/value:none|none]] [[Command/value:nomarking|nomarking]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:topstate|topstate]]</td><br />
<td>[[Command/value:stop|stop]] [[Command/value:start|start]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:bottomstate|bottomstate]]</td><br />
<td>[[Command/value:stop|stop]] [[Command/value:start|start]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:pagestate|pagestate]]</td><br />
<td>[[Command/value:stop|stop]] [[Command/value:start|start]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:color|color]]</td><br />
<td>[[Command/value:name|name]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description ==<br />
from [http://www.ntg.nl/pipermail/ntg-context/2010/049662.html a mail] by [[User:Taco|Taco]]:<br />
<br />
A makeup is a separate page, like a title page or colofon. There is one standard makeup page, but you can define more if needed.<br />
<br />
It is a page type with a special layout / header & footer sections that last only temporarily. The key point is that such a page does not (have to) rely on the current page layout style, which is especially useful for title pages.<br />
<br />
By default the page layout set up with <code>\setuplayout</code> is being reused. However, a custom page layout can be used as well. <code>\definemakeup</code> automatically uses a layout defined with <code>definelayout</code> with the same name as the makeup.<br />
<br />
There are two different ways to switch to the defined makeups:<br />
<br />
<texcode><br />
\startmakeup [custom]<br />
… some content …<br />
\stopmakeup<br />
</texcode><br />
<br />
and<br />
<br />
<texcode><br />
\startcustommakeup<br />
… some content …<br />
\stopcustommakeup<br />
</texcode><br />
<br />
== Example ==<br />
<br />
<texcode><br />
% this layout is automatically used by the “custom” makeup<br />
\definelayout<br />
[custom]<br />
[backspace=5mm]<br />
<br />
\definemakeup<br />
[custom]<br />
<br />
\starttext<br />
<br />
\startmakeup [custom]<br />
\input ward<br />
\stopmakeup<br />
<br />
\input knuth<br />
<br />
\startcustommakeup<br />
\input ward<br />
\stopcustommakeup<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== See also ==<br />
* [[Makeup]],<br />
* [[source:page-mak.mkiv|source]].<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|setupmakeup]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setupMPinstance&diff=19667Command/setupMPinstance2012-06-12T12:11:19Z<p>Marco: Add explanation about intitalizations and extensions keys</p>
<hr />
<div>{{Reference<br />
|name=setupMPinstance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupMPinstance<span class="first" >[...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">format</td><br />
<td>metafun mpost </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">extensions</td><br />
<td>yes no </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">initializations</td><br />
<td>yes no </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">textstyle</td><br />
<td>bold sans mono … </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">textcolor</td><br />
<td>color spec</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">setups</td><br />
<td></td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
This command sets up the default MetaPost instance <code>metafun</code> or a custom MetaPost instance previously defined with {{cmd|defineMPinstance}}.<br />
<br />
The <code>extensions</code> and <code>initializations</code> keys control whether the content of the <code>\startMPextensions</code> and <code>\startMPinitializations</code> environment is used or ignored in the metapost code.<br />
<br />
== Usage ==<br />
<br />
To print all MetaPost labels in red:<br />
<br />
<texcode><br />
\setupMPinstance [metafun] [textcolor=red]<br />
<br />
\starttext<br />
<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Another example using the <code>setups</code> key:<br />
<br />
<texcode><br />
\defineMPinstance<br />
[mpinstanceprefixed]<br />
[metafun]<br />
[setups=mp:instanceprefix:one, textcolor=red]<br />
<br />
\startsetups mp:instanceprefix:one<br />
prefix:\space<br />
\stopsetups<br />
<br />
\starttext<br />
<br />
\startMPcode<br />
draw textext("normal text") ;<br />
\stopMPcode<br />
<br />
\startMPcode{mpinstanceprefixed}<br />
draw textext("red text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
The above code prints:<br />
<br />
<pre><br />
normal text<br />
prefix: red text<br />
</pre><br />
<br />
“normal text” is printed in black, as well as “prefix:”, only “red text” is printed in red.<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
{{cmd|defineMPinstance}}, [[Mpgraphic]]<br />
<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|setupMPinstance]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Layers&diff=19544Layers2012-06-04T16:28:55Z<p>Marco: Add section about delayed font mechanism</p>
<hr />
<div>< [[Layout]] | [[Columns]] | [[Overlays]] | [[Logos]] | [[Collectors]] ><br />
<br />
'''Layers''' are ConTeXt's mechanism for absolute positioning of elements and other advanced techniques like switching elements on and off.<br />
<br />
There's still no manual about them.<br />
<br />
==My first Layer==<br />
<br />
Define a layer that takes the whole page<br />
<texcode><br />
\definelayer[mybg] % name of the layer<br />
[x=0mm, y=0mm, % from upper left corner of paper<br />
width=\paperwidth, height=\paperheight] % let the layer cover the full paper<br />
</texcode><br />
<br />
Now you can put something in that layer:<br />
<texcode><br />
\setlayer[mybg] % name of the layer<br />
[hoffset=1cm, voffset=1cm] % placement (from upper left corner of the layer)<br />
{\framed[frame=on, width=3cm, height=2cm]{LAYER}} % the actual contents of the layer<br />
</texcode><br />
<br />
Activate the layer as a background:<br />
<texcode><br />
\setupbackgrounds[page][background=mybg]<br />
</texcode><br />
This command makes the contents of the layer appear only once after the background is activated. If you want to repeat the contents of the layer on each page, use the option <code>repeat=yes</code> in the {{cmd|definelayer}} command. Then the contents of the layer will be shown on every page. You can add to these contents by a new {{cmd|setlayer}}[mybg] command. To clear the accumulated contents use {{cmd|resetlayer}}>[mybg]. To make the layer appear on each page, so that it can be populated with different content, set the option <code>state=repeat</code> in {{cmd|setupbackgrounds}}.<br />
<br />
Now you can test the whole thing:<br />
<context source=yes><br />
\setuppapersize[A10][A9,landscape]<br />
\setuparranging[2UP] % two pages side by side<br />
\showframe % show entire pages<br />
<br />
\definelayer[mybg] % name of the layer<br />
[x=0mm, y=0mm, % from upper left corner of paper<br />
width=\paperwidth, height=\paperheight, % let the layer cover the full paper<br />
]<br />
<br />
\setupbackgrounds[page][background=mybg]<br />
<br />
\setlayer[mybg] % name of the layer<br />
[hoffset=0.2cm, voffset=0.2cm] % placement (from upper left corner of the layer)<br />
{\framed[frame=on, width=2cm, height=1cm]{LAYER}} % the actual contents of the layer<br />
<br />
\starttext<br />
<br />
\dorecurse{2}{\page[empty]} % for testing, to get 2 pages, 1st with layer, 2nd without<br />
<br />
\stoptext<br />
<br />
</context><br />
<br />
<br />
==Placement==<br />
<br />
There are several possibilities for defining the placement of layer content:<br />
* x, y : offset from upper left corner of paper [=the current block; can sometimes be the text area instead of the page/paper!]<br />
* hoffset, voffset : offset from upper left corner of layer<br />
* corner : reference point, something like <code>{left, top}</code><br />
* location : alignment of the element relative to the corner, something like <code>{right, bottom}</code><br />
* preset : a named location, see below<br />
<br />
There are some "presets" for paper edge placement:<br />
<texcode><br />
% These four are defined by ConTeXt!<br />
\definelayerpreset [lefttop] [corner={left,top}, location={right,bottom}]<br />
\definelayerpreset [righttop] [corner={right,top}, location={left,bottom}]<br />
\definelayerpreset [leftbottom] [corner={left,bottom}, location={right,top}]<br />
\definelayerpreset [rightbottom] [corner={right,bottom}, location={left,top}]<br />
</texcode><br />
Similarly you can define your own presets.<br />
<br />
==State==<br />
<br />
The available options for the "state" of a layer are:<br />
<br />
* start: layer appears only on the current page<br />
* stop: layer doesn't show up<br />
* repeat: layer prints on all pages<br />
* next: layer appears on the following page<br />
* continue: layer appears on all pages except the first<br />
<br />
==Line breaking and fixed size==<br />
<br />
You may experience cases where the defined size of your layer is ignored and you can’t get linebreaking or multiple lines at all.<br />
This is due to <cmd>setlayer</cmd> using <cmd>hbox</cmd> internally. You can work around the problem using <cmd>setlayerframed</cmd>:<br />
<br />
<context source=yes><br />
\setuppapersize[A6]<br />
<br />
\definelayer[AddressBg][<br />
x=20mm, y=30mm, <br />
width=65mm, height=30mm, <br />
state=start] % size is ignored!<br />
\setupbackgrounds[paper][<br />
setups=ALayer, <br />
background=AddressBg, <br />
state=start]<br />
<br />
\starttext<br />
\strut<br />
\startsetups ALayer<br />
\setlayer[AddressBg] % Change this to \setlayerframed to get it to work<br />
[width=65mm, height=30mm,<br />
frame=off,<br />
hoffset=0mm, voffset=0mm,<br />
align=right]%<br />
{<br />
PRAGMA Advanced Document Engineering\crlf<br />
Mr. Hans Hagen (the wizard who wrote it all, \CONTEXT\ and everything else, <br />
with the help of his little elves)\crlf<br />
Ridderstraat 27\crlf<br />
8061GH Hasselt\crlf<br />
THE NETHERLANDS<br />
}<br />
\stopsetups<br />
\stoptext<br />
</context><br />
<br />
<br />
==Place labels on pictures==<br />
<br />
Layers can be used to put labels on pictures, alternative ways can be found in the [[manual:details.pdf| Details]] manual<br />
(see also [[Collectors]]).<br />
<br />
<context source="yes"><br />
\setupexternalfigures[location={local,default}]<br />
% (necessary for the wiki conTeXt live processor)<br />
<br />
\definelayer [figure][width=\overlaywidth,height=\overlayheight]<br />
\defineoverlay[figure][{\directsetup{figure}\tightlayer[figure]}]<br />
<br />
\setupcolors[state=start]<br />
<br />
\starttext<br />
<br />
\startsetups figure<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=rightbottom,<br />
x=.25\layerwidth,<br />
y=.25\layerheight]<br />
{\green HERE}<br />
<br />
\setlayerframed<br />
[figure]<br />
[preset=leftbottom,<br />
x=.15\layerwidth,<br />
y=.35\layerheight]<br />
{\red THERE}<br />
<br />
\stopsetups<br />
<br />
\externalfigure[cow][background={foreground,figure},width=4cm,height=3cm]<br />
<br />
\stoptext<br />
</context><br />
<br />
==Use dynamic content==<br />
<br />
The content of layer is fixed after your set it and will appear in the same way on each page.<br />
<br />
<texcode><br />
\definelayer<br />
[pagenumber]<br />
[width=\paperwidth,<br />
height=\paperheight,<br />
preset=middle,<br />
state=repeat]<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\setupbackgrounds[page][background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]} % Every page will say "Page 1"<br />
\stoptext<br />
</texcode><br />
<br />
This is not always what you desire like in the example above, where on each page the current page number should be shown and not the number from the first page.<br />
<br />
To recalculate the content on each new page you have to enclose the <cmd>setlayer</cmd> settings within <cmd>startsetups</cmd> ... <cmd>stopsetups</cmd> and<br />
write <code>\setupbackgrounds[page][setups=setupname,background=layername]</code> in your document.<br />
<br />
<texcode><br />
\definelayer<br />
[pagenumber]<br />
[width=\paperwidth,<br />
height=\paperheight,<br />
preset=middle]<br />
<br />
\startsetups layer<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\stopsetups<br />
<br />
\setupbackgrounds[page][setups=layer,background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]} % You get "Page 1, Page 2" etc.<br />
\stoptext<br />
</texcode><br />
<br />
<br />
Another solution was given by Wolfgang on the mailing list on February 21, 2012. He writes: ''Here is a slightly different version which is better when you need more dynamic layers.''<br />
<br />
<texcode><br />
<br />
\definelayer [pagenumber][width=\overlaywidth,height=\overlayheight,preset=middle]<br />
\defineoverlay[pagenumber][\texsetup{layer}]<br />
<br />
\startsetups layer<br />
<br />
\setlayer[pagenumber]{Page \pagenumber}<br />
<br />
\tightlayer[pagenumber]<br />
<br />
\stopsetups<br />
<br />
\setupbackgrounds[page][setups=layer,background=pagenumber]<br />
<br />
\starttext<br />
\dorecurse{4}{\page[empty]}<br />
\stoptext<br />
<br />
</texcode><br />
<br />
== Layers and the delayed font mechanism ==<br />
<br />
Until some years ago the Latin Modern font was always automatically<br />
loaded, regardless of the users choice of font. Font loading takes a<br />
considerable amount of time (check the stats at the end of a context<br />
run to get an idea). This led to the question:<br />
<br />
“Why start loading a big, complex font like Latin Modern before we<br />
know which font the user actually wants to use and waste several<br />
seconds on it, just to start loading the users choice afterwards?”<br />
<br />
The answer was:<br />
<br />
”We delay loading the font until we know which font the user wants<br />
to use. If the user doesn't tell us, then we fall back to Latin<br />
Modern.”<br />
<br />
The body font is set up in the setup area (the part above<br />
<code>\starttext</code>). That, in turn, means that when having reached<br />
<code>\starttext</code>, the users choice of font is known and can be loaded. It<br />
is more efficient if a font other then Latin Modern is used.<br />
<br />
One drawback is that typeset text in the setup area has no font<br />
setup and will fall back to Latin Modern Mono. Usually no text is<br />
typeset in the setup area. However, layers are an exception and<br />
a font needs to be set up beforehand.<br />
<br />
== See Also ==<br />
<br />
* Some applications in the [[manual:details.pdf|Details]] manual<br />
* [[Sample documents]]: [[BusinessCard]] and [[Letter style]]<br />
* Source: [[source:pack-lyr.mkii|pack-lyr.mkii]] or [[source:pack-lyr.mkiv|pack-lyr.mkiv]]<br />
* Example of [[Alternating backgrounds and repeating layers]] and [[Draft Watermark]]<br />
<br />
{{todo|We need a lot of documentation and samples for this complicated subject.}}<br />
<br />
[[Category:Graphics]] [[Category:Layers]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setupinterlinespace&diff=19363Command/setupinterlinespace2012-05-14T23:16:17Z<p>Marco: Format code block</p>
<hr />
<div>{{Reference<br />
|name=setupinterlinespace<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupinterlinespace<span class="first" style="color:red;">[...]</span><span class="second" >|</span><span class="third" >[...,...=...,...]</span><span class="first" >|</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>reset <strong>small</strong> medium auto big on off </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:height|height]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:depth|depth]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:line|line]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:top|top]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:bottom|bottom]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<pre><br />
can be used in 3 variants:<br />
<br />
1. \setupinterlinespace<br />
(without any param) set line=2.8ex<br />
<br />
2. \setupinterlinespace[...]<br />
reset<br />
small<br />
medium<br />
big<br />
on<br />
off<br />
<br />
3. \setupinterlinespace[...,...=...,...]<br />
line: base interline spacing (baselineskip) (e.g. 3ex or 12pt)<br />
<br />
height: size of strut as multiple of line height (e.g. 0.72)<br />
depth: size of strut as multiple of line height (e.g. 0.28)<br />
<br />
top: topskip (as multiple of line height)<br />
bottom: maxdepth (as multiple of line height)<br />
<br />
stretch: (glue) line stretching<br />
</pre><br />
<br />
== Comment ==<br />
<br />
It seems, that <tt>\setupinterlinespace[line=XX\baselineskip]</tt> interacts badly with <tt>\setuplayout</tt> while <tt>\setupinterlinespace[big]</tt> works fine.<br />
<br />
Those used to traditional typography specifications (e.g. "eleven point type on fourteen point leading" written as 11/14) would use the following:<br />
<br />
<texcode><br />
\setupbodyfont [11pt] % 12pt is the default font size<br />
\setupinterlinespace [line=14pt] % default: line=2.8ex<br />
</texcode><br />
<br />
<br />
<br />
<br />
== Example ==<br />
<context source="yes"><br />
\starttext<br />
{\definedfont[Serif at 32pt]This is the long long long title of my book.\par}<br />
<br />
{\definedfont[Serif at 32pt]\setupinterlinespace This is the long long long title of my book.\par}<br />
\stoptext<br />
</context><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/Paragraphs|setupinterlinespace]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setupMPinstance&diff=19316Command/setupMPinstance2012-05-08T19:53:52Z<p>Marco: Move info about predefined instances to \defineMPinstance</p>
<hr />
<div>{{Reference<br />
|name=setupMPinstance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupMPinstance<span class="first" >[...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">format</td><br />
<td>metafun mpost </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">extensions</td><br />
<td>yes no </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">initializations</td><br />
<td>yes no </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">textstyle</td><br />
<td>bold sans mono … </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">textcolor</td><br />
<td>color spec</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">setups</td><br />
<td></td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
This command sets up the default MetaPost instance <code>metafun</code> or a custom MetaPost instance previously defined with {{cmd|defineMPinstance}}.<br />
<br />
== Usage ==<br />
<br />
To print all MetaPost labels in red:<br />
<br />
<texcode><br />
\setupMPinstance [metafun] [textcolor=red]<br />
<br />
\starttext<br />
<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Another example using the <code>setups</code> key:<br />
<br />
<texcode><br />
\defineMPinstance<br />
[mpinstanceprefixed]<br />
[metafun]<br />
[setups=mp:instanceprefix:one, textcolor=red]<br />
<br />
\startsetups mp:instanceprefix:one<br />
prefix:\space<br />
\stopsetups<br />
<br />
\starttext<br />
<br />
\startMPcode<br />
draw textext("normal text") ;<br />
\stopMPcode<br />
<br />
\startMPcode{mpinstanceprefixed}<br />
draw textext("red text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
The above code prints:<br />
<br />
<pre><br />
normal text<br />
prefix: red text<br />
</pre><br />
<br />
“normal text” is printed in black, as well as “prefix:”, only “red text” is printed in red.<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
{{cmd|defineMPinstance}}, [[Mpgraphic]]<br />
<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|setupMPinstance]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/defineMPinstance&diff=19315Command/defineMPinstance2012-05-08T19:53:28Z<p>Marco: Add info about predefined instances</p>
<hr />
<div>{{Reference<br />
|name=defineMPinstance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\defineMPinstance<span class="first" >[...]</span><span class="second" >[...]</span><span class="third" >[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name for inheritance (optional)</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td>see [[Command/setupMPinstance|\setupMPinstance]]</td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
This command sets up a custom MetaPost style with particular features that can be selected using the first argument. The instance <code>metafun</code> is the default one and does not need to be created. However, custom styles can inherit from the <code>metafun</code> instance.<br />
<br />
== Predefined Instances ==<br />
<br />
<texcode><br />
\defineMPinstance [metafun] [format=metafun, extensions=yes, initializations=yes]<br />
\defineMPinstance [metapost] [format=mpost]<br />
</texcode><br />
<br />
== Example ==<br />
<texcode><br />
\defineMPinstance<br />
[important]<br />
[metafun] % needs to be inherited from the global metafun instance<br />
[textcolor=red]<br />
<br />
\defineMPinstance<br />
[veryimportant]<br />
[important]<br />
[textstyle=bold]<br />
<br />
\starttext<br />
<br />
% normal black text<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red text<br />
\startMPcode{important}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red bold text<br />
\startMPcode{veryimportant}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
{{cmd|setupMPinstance}}, [[Mpgraphic]]<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|definestartstop]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setupMPinstance&diff=19314Command/setupMPinstance2012-05-08T19:52:21Z<p>Marco: Add additional keys and info about predefined instances</p>
<hr />
<div>{{Reference<br />
|name=setupMPinstance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupMPinstance<span class="first" >[...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">format</td><br />
<td>metafun mpost </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">extensions</td><br />
<td>yes no </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">initializations</td><br />
<td>yes no </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">textstyle</td><br />
<td>bold sans mono … </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">textcolor</td><br />
<td>color spec</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">setups</td><br />
<td></td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
This command sets up the default MetaPost instance <code>metafun</code> or a custom MetaPost instance previously defined with {{cmd|defineMPinstance}}.<br />
<br />
== Predefined Instances ==<br />
<br />
<texcode><br />
\defineMPinstance [metafun] [format=metafun, extensions=yes, initializations=yes]<br />
\defineMPinstance [metapost] [format=mpost]<br />
</texcode><br />
<br />
== Usage ==<br />
<br />
To print all MetaPost labels in red:<br />
<br />
<texcode><br />
\setupMPinstance [metafun] [textcolor=red]<br />
<br />
\starttext<br />
<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Another example using the <code>setups</code> key:<br />
<br />
<texcode><br />
\defineMPinstance<br />
[mpinstanceprefixed]<br />
[metafun]<br />
[setups=mp:instanceprefix:one, textcolor=red]<br />
<br />
\startsetups mp:instanceprefix:one<br />
prefix:\space<br />
\stopsetups<br />
<br />
\starttext<br />
<br />
\startMPcode<br />
draw textext("normal text") ;<br />
\stopMPcode<br />
<br />
\startMPcode{mpinstanceprefixed}<br />
draw textext("red text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
The above code prints:<br />
<br />
<pre><br />
normal text<br />
prefix: red text<br />
</pre><br />
<br />
“normal text” is printed in black, as well as “prefix:”, only “red text” is printed in red.<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
{{cmd|defineMPinstance}}, [[Mpgraphic]]<br />
<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|setupMPinstance]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/defineMPinstance&diff=19313Command/defineMPinstance2012-05-08T19:40:01Z<p>Marco: Add link</p>
<hr />
<div>{{Reference<br />
|name=defineMPinstance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\defineMPinstance<span class="first" >[...]</span><span class="second" >[...]</span><span class="third" >[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name for inheritance (optional)</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td>see [[Command/setupMPinstance|\setupMPinstance]]</td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
This command sets up a custom MetaPost style with particular features that can be selected using the first argument. The instance <code>metafun</code> is the default one and does not need to be created. However, custom styles can inherit from the <code>metafun</code> instance.<br />
<br />
== Example ==<br />
<texcode><br />
\defineMPinstance<br />
[important]<br />
[metafun] % needs to be inherited from the global metafun instance<br />
[textcolor=red]<br />
<br />
\defineMPinstance<br />
[veryimportant]<br />
[important]<br />
[textstyle=bold]<br />
<br />
\starttext<br />
<br />
% normal black text<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red text<br />
\startMPcode{important}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red bold text<br />
\startMPcode{veryimportant}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
{{cmd|setupMPinstance}}, [[Mpgraphic]]<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|definestartstop]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setupMPinstance&diff=19312Command/setupMPinstance2012-05-08T19:39:19Z<p>Marco: Initial commit</p>
<hr />
<div>{{Reference<br />
|name=setupMPinstance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupMPinstance<span class="first" >[...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">textstyle</td><br />
<td>bold sans mono … </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">textcolor</td><br />
<td>color spec</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">setups</td><br />
<td></td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
This command sets up the default MetaPost instance <code>metafun</code> or a custom MetaPost instance previously defined with {{cmd|defineMPinstance}}.<br />
<br />
== Usage ==<br />
<br />
To print all MetaPost labels in red:<br />
<br />
<texcode><br />
\setupMPinstance [metafun] [textcolor=red]<br />
<br />
\starttext<br />
<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Another example using the <code>setups</code> key:<br />
<br />
<texcode><br />
\defineMPinstance<br />
[mpinstanceprefixed]<br />
[metafun]<br />
[setups=mp:instanceprefix:one, textcolor=red]<br />
<br />
\startsetups mp:instanceprefix:one<br />
prefix:\space<br />
\stopsetups<br />
<br />
\starttext<br />
<br />
\startMPcode<br />
draw textext("normal text") ;<br />
\stopMPcode<br />
<br />
\startMPcode{mpinstanceprefixed}<br />
draw textext("red text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
The above code prints:<br />
<br />
<pre><br />
normal text<br />
prefix: red text<br />
</pre><br />
<br />
“normal text” is printed in black, as well as “prefix:”, only “red text” is printed in red.<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
{{cmd|defineMPinstance}}, [[Mpgraphic]]<br />
<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|setupMPinstance]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/defineMPinstance&diff=19311Command/defineMPinstance2012-05-08T19:19:28Z<p>Marco: Initial commit</p>
<hr />
<div>{{Reference<br />
|name=defineMPinstance<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\defineMPinstance<span class="first" >[...]</span><span class="second" >[...]</span><span class="third" >[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name for inheritance (optional)</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...]</td><br />
<td>see [[Command/setupMPinstance|\setupMPinstance]]</td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
This command sets up a custom MetaPost style with particular features that can be selected using the first argument. The instance <code>metafun</code> is the default one and does not need to be created. However, custom styles can inherit from the <code>metafun</code> instance.<br />
<br />
== Example ==<br />
<texcode><br />
\defineMPinstance<br />
[important]<br />
[metafun] % needs to be inherited from the global metafun instance<br />
[textcolor=red]<br />
<br />
\defineMPinstance<br />
[veryimportant]<br />
[important]<br />
[textstyle=bold]<br />
<br />
\starttext<br />
<br />
% normal black text<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red text<br />
\startMPcode{important}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red bold text<br />
\startMPcode{veryimportant}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
[[Mpgraphic]]<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|definestartstop]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=MetaFun_-_MetaPost_in_ConTeXt&diff=19310MetaFun - MetaPost in ConTeXt2012-05-08T18:49:57Z<p>Marco: Add section about \defineMPinstance and \setupMPinstance</p>
<hr />
<div>< [[Graphics]]|[[Metafun]]|[[Metapost]]><br />
<br />
ConTeXT provides a tight integration of TeX and [[Metapost]]. Metapost can used behind the scenes for some graphic trickery. This integration is also helpful for drawing figures in metapost and use them in the document. Some of the commonly used commands for this are<br />
<br />
==<cmd>defineMPinstance</cmd> and <cmd>setupMPinstance</cmd>==<br />
<br />
These commands can be used to set up MetaPost invocations with particular<br />
features. One use case could be to select a sans serif font for all MetaPost<br />
labels. Example:<br />
<br />
<texcode><br />
\setupMPinstance [metafun] [textstyle=sans]<br />
\starttext<br />
<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Another use case could be to create a custom setup with important text in bold and red for<br />
selected MetaPost graphics. Example:<br />
<br />
<texcode><br />
\defineMPinstance<br />
[important]<br />
[metafun] % needs to be inherited from the global metafun instance<br />
[textcolor=red]<br />
<br />
\defineMPinstance<br />
[veryimportant]<br />
[important]<br />
[textstyle=bold]<br />
<br />
\starttext<br />
<br />
% normal black text<br />
\startMPcode<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red text<br />
\startMPcode{important}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
% red bold text<br />
\startMPcode{veryimportant}<br />
draw textext("some text") ;<br />
\stopMPcode<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
==<cmd>startMPenvironment</cmd>==<br />
<em>Deprecated,</em> use <cmd>defineMPinstance</cmd> and <cmd>setupMPinstance</cmd> instead.<br />
<br />
This is used to change the body font for metapost graphics. For example, to get the text in metapost graphics in times, use<br />
<br />
<texcode><br />
\startMPenvironment<br />
\usetypescript[times][texnansi]<br />
\switchtobodyfont[times,10pt]<br />
\stopMPenvironment<br />
</texcode><br />
<br />
An MPenvironment is sort of like <b>verbatimtex..etex</b> in regular (standalone) MetaPost figures. Here is an example of using verbatimtex in a regular MetaPost figure:<br />
<texcode><br />
verbatimtex<br />
% center-align and stack the two arguments<br />
\def\2#1#2{\vbox{\halign{\hfil##\hfil\cr #1\cr #2\cr}}}<br />
etex<br />
<br />
beginfig(1)<br />
z0 = (2in,0);<br />
draw fullcircle scaled 3cm;<br />
label(btex \2{sun}{mass $M$} etex, origin);<br />
draw fullcircle scaled 1.5cm shifted z0;<br />
label(btex \2{earth}{mass $m$} etex, z0);<br />
endfig;<br />
end<br />
</texcode><br />
<br />
To integrate such a graphic into a ConTeXt source file, there are several choices. <br />
<br />
1. Place the definition of <b>\2</b> in the MPenvironment. However, that fails (as of the 2006.09.28 beta but it's likely to work soon, knowing Hans) because the definition is stored as a macro itself, and then the parameters #1 and #2 become ##1 and ##2, alas. There is a <b>\startbuffer</b> trick that Hans posted on the mailing list. But perhaps the easiest is:<br />
<br />
2. Place the definition of <b>\2</b> in the ConTeXt environment, and change <b>btex..etex</b> to <b>\sometxt</b>. Here's an example:<br />
<br />
<texcode><br />
% in a large document, put this def in an environment<br />
\def\2#1#2{\vbox{\halign{\hfil##\hfil\cr #1\cr #2\cr}}}<br />
<br />
\starttext<br />
<br />
% earth and sun<br />
\startreusableMPgraphic{fig}<br />
z0 = (2in,0);<br />
draw fullcircle scaled 3cm;<br />
label(\sometxt{\2{sun}{mass $M$}}, origin);<br />
draw fullcircle scaled 1.5cm shifted z0;<br />
label(\sometxt{\2{earth}{mass $m$}}, z0);<br />
\stopreusableMPgraphic<br />
<br />
\reuseMPgraphic{fig}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Warning: <b>\sometxt</b> cannot be used in loops. Instead use <b>\textext</b>. [Someone who understands why should expand this statement!]<br />
<br />
==<cmd>startMPinclusions</cmd>==<br />
This can be used for specifying metapost files to ''input'' and also to define metapost functions.<br />
For example<br />
<texcode><br />
\startMPinclusions<br />
input boxes ;<br />
<br />
vardef my_metapost_fun(expr var)=<br />
...<br />
enddef ;<br />
\stopMPinclusions<br />
</texcode><br />
<br />
<br />
==<cmd>startMPpage</cmd>==<br />
This produces a page containing metapost graphic. The resulting pdf is self contained (it has all the fonts embedded) This is useful if you want to send the figure to a coauthor or a journal. For example, one can have<br />
<br />
<texcode><br />
\starttext<br />
\startMPpage<br />
draw fullcircle scaled 2cm ;<br />
dotlabel.bot(textext("(0,0)"),origin) ;<br />
\stopMPpage<br />
<br />
\startMPpage<br />
draw fullcircle scaled 2cm ;<br />
drawarrow (0,0)--(1cm,0) ;<br />
label.bot(textext("$r$"),(5mm,0)) ;<br />
\stopMPpage<br />
<br />
\stoptext<br />
</texcode><br />
<br />
Processing this file using<br />
<texcode><br />
texmfstart texexec --pdf filename<br />
</texcode><br />
gives a pdf with two pages of graphics.<br />
<br />
==<cmd>startstaticMPfigure</cmd>==<br />
<cmd>startuseMPgraphic</cmd> series of commands were designed for using metapost for drawing fancy frames and backgrounds and not for using <i>stand-alone</i> graphics for a document. <cmd>startstaticMPfigure</cmd> creates a separate pdf file containing the graphic. This pdf can be included in the document using <cmd>usestaticMPfigure</cmd>. Context is clever enough to recompile the resulting metapost file, only if something inside the start stop staticMPgraphic has changed.<br />
<br />
For example,<br />
<texcode><br />
\startstaticMPfigure{center}<br />
draw fullcircle scaled 2cm ;<br />
dotlabel.bot(textext("(0,0)"),origin) ;<br />
\stopstaticMPfigure<br />
<br />
\startstaticMPfigure{radius}<br />
draw fullcircle scaled 2cm ;<br />
drawarrow (0,0)--(1cm,0) ;<br />
label.bot(textext("$r$"),(5mm,0)) ;<br />
\stopstaticMPfigure<br />
<br />
\starttext<br />
<br />
Circle centered \usestaticMPfigure[center][width=1cm] at origin with radius<br />
\usestaticMPfigure[radius][width=1cm] $r=1\,\text{cm}$.<br />
<br />
\stoptext<br />
</texcode><br />
<br />
* '''center''' and '''radius''' above are ''labels'' that are used to access the figure.<br />
* <cmd>usestaticMPfigure</cmd> takes the first argument as the ''label'' of the figure to be inserted. The second argument has the same options as the second argument of <cmd>externalfigure</cmd><br />
* To force the figure files to be regenerated, remove all the <code>*.mp.md5</code> files from the current directory.<br />
==Transparent colors in figures==<br />
<br />
You can use transparent colors! For example:<br />
<br />
<texcode><br />
\runMPgraphicstrue<br />
\setupcolors[state=start]<br />
\starttext<br />
\startreusableMPgraphic{a}<br />
fill unitsquare scaled 1cm withcolor yellow;<br />
fill unitsquare shifted (0.5,0.5)<br />
scaled 1cm withcolor transparent(1,0.5,red);<br />
\stopreusableMPgraphic<br />
<br />
\placefigure[force,none]{}{\reuseMPgraphic{a}}<br />
\stoptext<br />
</texcode><br />
<br />
If you see black squares rather than a yellow one underneath a partially transparent red one, then you probably hit the 'missing specials' problem diagnosed by Taco (ntg-context list, 23 Sep 2006 22:00:42 +0200):<br />
<br />
<pre><br />
This all sounds like the 'missing specials' problem that is caused<br />
by conflicting -progname= arguments when using the web2c version<br />
of metapost.<br />
<br />
Make sure you do not have conflicting memory settings for both<br />
main_memory.mpost<br />
as well as<br />
main_memory.metafun<br />
<br />
The best is to remove all trace of '.mpost' and '.metafun' memory<br />
settings from your texmf.cnf, but at least make sure all the<br />
'.mpost' and 'metafun' values are the same .<br />
<br />
Then regenerate metafun using texexec --make, and all should be<br />
well again.<br />
</pre><br />
<br />
And indeed it fixed it for me (Sanjoy). These were the memory setting in the ''/etc/texmf/texmf.d/95NonPath.cnf''<br />
configlet that is part of Debian and Ubuntu distributions of TeX:<br />
<br />
<pre><br />
main_memory = 1000000 % words of inimemory available; also applies to inimf&mp<br />
main_memory.context = 1500000<br />
main_memory.mpost = 1500000<br />
</pre><br />
<br />
I commented out the .mpost line (there was no separate metafun line,<br />
which I guess instead used the main_memory value of 1000000),<br />
regenerated ''/etc/texmf/texmf.cnf'' with ''update-texmf'' (as root), then regenerated metafun with ''texexec --make metafun'' (as me) and transparency worked.<br />
<br />
[[Category:Graphics]]<br />
[[Category:Metapost]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/datasetvariable&diff=19161Command/datasetvariable2012-04-22T14:06:03Z<p>Marco: Initial commit</p>
<hr />
<div>{{Reference<br />
|name=datasetvariable<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\datasetvariable<span class="first" >{...}</span><span class="second" >{...}</span><span class="third" >{...}</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">{...}</td><br />
<td>name of data set</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">{...}</td><br />
<td>identifier or number </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">{...}</td><br />
<td>key </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
This command retrieves the values that have been saved with the {{cmd|setdataset}} command. The first argument is the data set name, given by the first argument of {{cmd|setdataset}}. The second argument is an integer if {{cmd|setdataset}} was used with two arguments and an identifier if {{cmd|setdataset}} was used with three arguments. The last argument is the key, which value should be retrieved.<br />
<br />
== Usage ==<br />
<br />
<texcode><br />
\datasetvariable{somedataset}{1}{foo}<br />
</texcode><br />
<br />
or<br />
<br />
<texcode><br />
\datasetvariable{somedataset}{alpha}{bar}<br />
</texcode><br />
<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
More detailled explanations and examples can be found under <br />
[[System_Macros/Key_Value_Assignments|Key-Value Assignments]] section Two-pass data.<br />
<br />
<br />
{{cmd|definedataset}},<br />
{{cmd|setdataset}}<br />
<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|datasetvariable]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setdataset&diff=19160Command/setdataset2012-04-22T13:58:44Z<p>Marco: Fix typo</p>
<hr />
<div>{{Reference<br />
|name=setdataset<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setdataset<span class="first" >[...]</span><span class="second" >[...]</span><span class="third" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td> </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
This command is used to store key-value pairs previously defined with {{cmd|definedataset}}. The first argument is the data set name, the last argument is a list of key-value pairs of data that should be saved. The second argument is optional. When it is not used, the data saved in the set is enumerated or when provided, it is the identifier which can be used to address this particular saved key-value pair.<br />
<br />
== Usage ==<br />
<br />
<texcode><br />
\setdataset [somedataset] [foo=first, bar=second]<br />
</texcode><br />
<br />
or<br />
<br />
<texcode><br />
\setdataset [somedataset] [alpha] [foo=first, bar=second]<br />
\setdataset [somedataset] [beta] [foo=first, bar=second]<br />
</texcode><br />
<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
More detailled explanations and examples can be found under <br />
[[System_Macros/Key_Value_Assignments|Key-Value Assignments]] section Two-pass data.<br />
<br />
<br />
{{cmd|definedataset}},<br />
{{cmd|datasetvariable}}<br />
<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|setdataset]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/setdataset&diff=19159Command/setdataset2012-04-22T13:58:02Z<p>Marco: Initial commit</p>
<hr />
<div>{{Reference<br />
|name=setdataset<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setdataset<span class="first" >[...]</span><span class="second" >[...]</span><span class="third" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td> </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
This command is used to store key-value pairs previously defined with {{cmd|definedataset}}. The first argument is the data set name, the last argument is a list of key-value pairs of data that should be saved. The second argument is optional. When it is not used, the data saved in the set is enumerated or when provided, it is the identifier which can be used to address this particular saved key-value pair.<br />
<br />
== Usage ==<br />
<br />
<texcode><br />
\setdataset [somedataset] [foo=first, bar=second]<br />
</texcode><br />
<br />
or<br />
<br />
<texcode><br />
\setdataset [somedataset] [alpha] [foo=first, bar=second]<br />
\setdataset [somedataset] [beta] [foo=first, bar=second]<br />
</texcode><br />
<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
More detailled explanations and examples can be found under <br />
[[System_Macros/Key_Value_Assignments|Key-Value Assignments]] section Two-pass data.<br />
<br />
<br />
{{cmd|definedataset}},<br />
{{cmd|datasetvariable}}<br />
<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|definedataset]]</div>Marcohttps://wiki.contextgarden.net/index.php?title=Command/definedataset&diff=19158Command/definedataset2012-04-22T13:49:40Z<p>Marco: Fix typo</p>
<hr />
<div>{{Reference<br />
|name=definedataset<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definedataset<span class="first" >[...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>delay </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:delay|delay]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
This command stores two-pass data in the <code>.tuc</code> file.<br />
<br />
== Usage ==<br />
<br />
<texcode><br />
\definedataset [somedataset]<br />
</texcode><br />
<br />
or<br />
<br />
<texcode><br />
\definedataset [somedataset] [delay=yes]<br />
</texcode><br />
<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
More detailled explanations and examples can be found under <br />
[[System_Macros/Key_Value_Assignments|Key-Value Assignments]] section Two-pass data.<br />
<br />
<br />
{{cmd|setdataset}},<br />
{{cmd|datasetvariable}}<br />
<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Commands|definedataset]]</div>Marco