https://wiki.contextgarden.net/api.php?action=feedcontributions&user=Henri&feedformat=atomWiki - User contributions [en]2024-03-28T16:54:47ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Unexpected_behavior&diff=25677Unexpected behavior2020-02-14T06:02:29Z<p>Henri: /* Assignments */</p>
<hr />
<div>If ConTeXt appears to behave in a counterintuitive way, chances are<br />
that it’s actually your intuitions that lack calibration.<br />
<br />
== Controlling Page Break Before Headings ==<br />
If you add the option <code>page=yes</code> to a heading setup, this<br />
will cause ConTeXt to break the page.<br />
Ordinarily this works as expected, unless, however, the heading<br />
immediately follows a previous section heading with no text in between.<br />
The rationale behind this is that consecutive headings are conceived of<br />
collectively as one single structural element.<br />
For example, the following code will generate only a single page<br />
break although the unit {{cmd|section}} appears twice.<br />
<br />
<texcode><br />
\setuphead[section][page=yes] %% toggle page breaking<br />
<br />
\starttext<br />
\chapter{foo} %% structural inhibits breaking<br />
\section{bar} \input knuth %% -> no break!<br />
\section{baz} \input dawkins %% -> break<br />
\stoptext<br />
</texcode><br />
<br />
In order to get the page break at the section regardless of surrounding<br />
structurals elements, you need to ''unset'' the heading parameter<br />
<code>continue</code> as well.<br />
[http://archive.contextgarden.net/message/20080107.115201.ca26c682.en.html]<br />
<br />
<texcode><br />
\setuphead[section][page=yes,continue=no]<br />
<br />
\starttext<br />
\chapter{foo}<br />
\section{bar} \input knuth %% -> break<br />
\section{baz} \input dawkins %% -> break<br />
\stoptext<br />
</texcode><br />
<br />
(For the curious, the explanation can be found in the definition of the<br />
macro {{cmd|strc_sectioning_handle_page_nop|link=no}} in {{src|strc-sec.mkiv}}).<br />
<br />
<br />
== Unsolicited Vertical Mode ==<br />
Some commands like {{cmd|framed}} cause line breaks to happen if used<br />
in vertical mode, e.g. at the beginning of a line.<br />
Example:<br />
<br />
<context source="yes"><br />
\starttext<br />
\framed{foo} bar.<br />
\stoptext<br />
</context><br />
<br />
The explanation according to the corresponding<br />
[http://wiki.contextgarden.net/FAQ#Why_is_there_a_line-break_in_the_output_after_some_commands.3F FAQ item]<br />
is that before the token <code>\frame</code> is encountered, TEX is<br />
in vertical mode.<br />
This state is ''preserved until after TEX finishes typesetting the<br />
<code>\framed</code> macro''.<br />
Consequently, horizontal mode (where paragraphs are made) is entered<br />
only at the tokens <code>bar</code>.<br />
<br />
To have the frame begin the paragraph instead, horizontal mode will<br />
have to be initiated explicitly.<br />
There are a couple macros for this purpose: the very basic<br />
{{cmd|leavevmode}} ({{src|syst-ini.mkiv}}; inserts an empty box, same<br />
as in the Plain format) and the more familiar {{cmd|dontleavehmode}}<br />
({{src|syst-aux.mkiv}}).<br />
Just use the chosen macro immediately before the <code>\framed</code> macro and<br />
everything should be fine:<br />
<br />
<context source="yes"><br />
\starttext<br />
\leavevmode \framed{foo} bar.\par<br />
\dontleavehmode \framed{foo} bar.<br />
\stoptext<br />
</context><br />
<br />
== Disappearing Crop Marks ==<br />
Crop marks, activated as <code>\setuplayout[marking=on]</code>, are a<br />
useful feature that Context supports out of the box.<br />
They have a peculiarity, though, which my make them useless in specific<br />
cases: They are, by definition, located ''outside the page dimension''.<br />
This means that they show up iff the paper size exceeds the page size.<br />
<br />
Thus if you need auxiliary lines for cutting but have the pages fit the<br />
paper size exactly, you can instead resort to enabling the '''page<br />
background frame'''.<br />
This example sums up the solutions posted by Wolfgang and Marco on<br />
[http://archive.contextgarden.net/message/20120605.202113.0989aa34.en.html<br />
the Context Mailing List].<br />
<texcode><br />
%% the paper size will be a multiple of the page sizes<br />
\setuppapersize [A6,landscape] [A3] <br />
\setuplayout [nx=2,ny=4]%, marking=on] <br />
%% enable the page frame<br />
\setupbackgrounds [page] [frame=on]<br />
%% some further display setups<br />
\setuppagenumbering [location=] <br />
\setupbackgrounds [page] [background=color, backgroundcolor=gray] <br />
\setupbodyfont [sans,58pt] <br />
%% testing ...<br />
\starttext <br />
\dorecurse{4} <br />
{\null\vfill\centerline\recurselevel\vfill\null\page} <br />
\stoptext<br />
</texcode><br />
<br />
== Left and Right ==<br />
When it comes to the justification of paragraphs, do not trust your<br />
intuitions about ''handedness''.<br />
This is a [[Right_and_left|FAQ item]].<br />
<br />
== Footnotes: The Difference between {{cmd|setupnotation}} and {{cmd|setupnote}} ==<br />
<br />
There is a bit of terminology mess concerning notes.<br />
<br />
<!-- I really loathe the wikitext table syntax. --><br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Instruction !! Goal<br />
|-<br />
| {{cmd|setupnotation}}<br />
| This command configures the '''note insert''', i.e. the textual content that will usually be placed at the bottom (with footnotes) or the end of the text (with endnotes). (The control sequence used to be <code>\setupnotedefinition</code>.)<br />
|-<br />
| {{cmd|setupnote}}<br />
| Configure the '''note environment''' where the inserts will be located. Inherits some parameters from {{cmd|framed}}.<br />
|-<br />
| <code>\setupnote[textstyle=,textcommand=]</code><br />
| Configure the '''note symbol''' as appears in the main text, where the note macro is called.<br />
|-<br />
| Plural forms {{cmd|setupnotes}}, {{cmd|setupnotations}}<br />
| These are synonyms for their singular forms.<br />
|-<br />
| {{cmd|setupfootnotes}}<br />
| This is equivalent to <code>\setupnote[footnote]</code>.<br />
|}<br />
<br />
''Summary'':<br />
to setup a blue note, you would first need to define and configure the<br />
insert via {{cmd|setupnotation}}:<br />
<texcode><br />
\definenote [bluenote] [footnote]<br />
\setupnotation [bluenote] [<br />
color=blue,<br />
style=bf,<br />
]<br />
<br />
\starttext foo\bluenote{bar} baz \stoptext<br />
</texcode><br />
<br />
Now adjust the container where the blue notes will reside at the bottom<br />
of the page ({{cmd|setupnote}}):<br />
<br />
<texcode><br />
\definenote [bluenote] [footnote]<br />
\setupnote [bluenote] [<br />
frame=on, %% frame containing all inserts<br />
framecolor=blue,<br />
background=screen,<br />
rulecolor=blue, %% the line above the inserts<br />
rulethickness=1pt, %% both the frame and line width<br />
]<br />
<br />
\starttext foo\bluenote{bar} baz \bluenote{xyzzy} \stoptext<br />
</texcode><br />
<br />
Finally, direct your attention to the note indicator, most commonly a<br />
number or a symbol.<br />
For precise control over the placement define a monadic macro and hook<br />
it into <code>textcommand</code>.<br />
<br />
<texcode><br />
\setupnote [bluenote] [<br />
textstyle=\tx\sans\bold\blue,<br />
textcommand=\myfootnotecommand,<br />
]<br />
\define[1]\myfootnotecommand{\rotate[rotation=42]{#1}}<br />
<br />
\starttext foo\bluenote{bar} baz \bluenote{xyzzy} \stoptext<br />
</texcode><br />
<br />
(For more definite answers concerning the ''notes'' mechanism, use the<br />
source, Luke: {{src|strc-not.mkvi}}.)<br />
<br />
<br />
== Float Insertion Issues ==<br />
<br />
Floating objects can be tricky.<br />
Deciding where they fit best is hard enough, actually getting them<br />
there may be a lot tougher.<br />
Inserting a float will force a line break where the object is<br />
referenced in the source code.<br />
Thus, very long paragraphs may not leave an opportunity to inject the<br />
float if they cover the entire page.<br />
[http://archive.contextgarden.net/message/20120405.103626.a1349c1c.en.html]<br />
<texcode><br />
\starttext<br />
Cows make<br />
\placefigure[top]{A genuine Dutch cow.}{\externalfigure[cow]}<br />
great pets.<br />
\stoptext<br />
</texcode><br />
In these cases the ''postponing mechanism'' offers a reliable way out<br />
({{cmd|startpostponing}}).<br />
It lets you specify an offset (in pages) by which the content of the<br />
postponing environment will be delayed.<br />
In order to place a floating object at the top of the ''n''th page from<br />
the location it is encountered, its argument has needs to be<br />
<code>[+n]</code>.<br />
(Absolute pages can be specified as simply <code>[n]</code>.)<br />
E.&nbsp;g. to put the foat on the following page:<br />
<texcode><br />
\starttext<br />
\startpostponing[+1]<br />
\placefigure[top]{A genuine Dutch cow.}{\externalfigure[cow.pdf]}<br />
\stoppostponing<br />
\input knuth<br />
\page<br />
Cows make great pets.<br />
\stoptext<br />
</texcode><br />
<br />
Another solution can be the less-known ''hangaround environment''<br />
({{cmd|starthangaround}}, cf.<br />
[[Using_Graphics#Flow_text_around_a_picture|Hangaround]]).<br />
It lets the text of a given paragraph (the content of the environment)<br />
flow around a box (the first argument).<br />
In contrast to real floats it does not place a caption.<br />
This poses a problem in MkIV as the new code will not allow placing<br />
captions arbitrarily.<br />
[[http://repo.or.cz/w/context.git/blob/refs/heads/origin:/tex/context/base/strc-flt.mkvi#l257]]<br />
(If you desparately need separate captions please send a feature<br />
request to one of the<br />
[[ConTeXt_Mailing_Lists#Mailing Lists]]).<br />
<br />
<context source="yes" mode="mkii"><br />
\starttext<br />
\input dawkins<br />
<br />
\starthangaround{<br />
\framed[align=right,frame=off,width=.3\textwidth]{<br />
\externalfigure [cow] [width=.3\textwidth]\crlf<br />
%% NB the fake caption works *only in mkii*<br />
\placefloatcaption<br />
[figure]<br />
[ref:acow]<br />
{A smiling Dutch cow.<br />
{\italic Bos primigenius taurus}}<br />
}<br />
}<br />
\input dawkins<br />
\stophangaround<br />
<br />
\input dawkins<br />
\stoptext<br />
</context><br />
<br />
=== The “paragraph in a group” problem ===<br />
<br />
Another common issue with sidefloats is starting a paragraph in a group.<br />
<br />
<context source="yes" mode="mkiv"><br />
\placefigure[right,none]{}{\externalfigure[cow][width=0.25\textwidth]}<br />
Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br />
<br />
{\bf Oeps} \samplefile{lorem}<br />
</context><br />
As you can see the paragraph starting with “Oeps” just overflows into the picture.<br />
That is a well-known problem and there are posts about it on the mailing<br />
list every once in a while. The sidefigure mechanism uses <code>\parshape</code> to<br />
make the paragraph flow around the figure. The <code>\parshape</code> primitive only<br />
applies to a single paragraph, so ConTeXt communicates the current<br />
<code>\parshape</code> settings to the next paragraph using <code>\everypar</code>. However, when<br />
a new paragraph starts in a group, i.e.<br />
<texcode><br />
{\bf Oeps} ...<br />
</texcode><br />
TeX inserts the <code>\everypar</code> tokens inside that group because only the<br />
first letter starts the paragraph. That is to say is effectively looks<br />
like this<br />
<texcode><br />
% \everypar inserted inside the group<br />
% ~~~v<br />
{\bf \the\everypar Opes} ...<br />
% ~~~~~~~~~~~~~~~~~~~~~^<br />
% Setting of \everypar are discarded again when leaving the group and \parshape is lost.<br />
</texcode><br />
You have to explicitly start a new paragraph before opening a group.<br />
The easiest way to do this is<br />
<texcode><br />
\dontleavehmode{\bf Oeps} ...<br />
</texcode><br />
Now the <code>\everypar</code> tokens are inserted directly after {{cmd|dontleavehmode}}<br />
outside the group and the problem goes away.<br />
<br />
= Syntax =<br />
== Assignments ==<br />
<br />
Spaces before commas or before the closing <code>]</code> are '''''not''''' ignored in ConTeXt. That is a common pitfall and leads to errors that can be confusing for beginner, especially those coming from LaTeX, where this is the default behaviour. Formatting your keys like this might look nice but leads to spurious spaces:<br />
<context source="yes" mode="mkiv"><br />
\getparameters[test]<br />
[ foo=bar<br />
, hello=world<br />
]<br />
“\testfoo” “\testhello”<br />
</context><br />
Instead it is recommended to adhere to the style that is used in the ConTeXt source to avoid problems with trailing spaces:<br />
<context source="yes" mode="mkiv"><br />
\getparameters[test]<br />
[foo=bar,<br />
hello=world]<br />
“\testfoo” “\testhello”<br />
</context><br />
<br />
In the most common form of key-value type arguments, ConTeXt will<br />
accept trailing commas or even empty items. For example, the following<br />
code shows this tolerance for the command {{cmd|definehighlight}}.<br />
<br />
<texcode><br />
\definehighlight [dontmiss] [<br />
color=red,<br />
,, %% empty option: do nothing<br />
style=bold, %% trailing delimiter<br />
]<br />
</texcode><br />
<br />
This is the syntax accepted e.g. by the majority of setups and<br />
[[Commands_with_KeyVal_arguments|<code>\getparameters</code>]].<br />
(For the parser code cf. {{src|syst-aux.mkiv}}.)<br />
<br />
There are, however, exceptions to this rule. A known case where<br />
options are processed in a less tolerant fashion is<br />
{{cmd|setuplabeltext}}.<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067585.html]<br />
Thus the following snippet will not compile, forcing ConTeXt to fail<br />
with a cryptic <code>Argument of ...</code> error message.<br />
<texcode><br />
\setuplabeltext<br />
[Nomen=nomen,<br />
Est=est,<br />
Omen=est,] %% <= fails!<br />
\setuplabeltext [Nomen=nomen, Est=est, Omen=omen] %% <= works<br />
\starttext<br />
\labeltext{Nomen}<br />
\labeltext{Est}<br />
\labeltext{Omen}<br />
\stoptext<br />
</texcode><br />
<br />
(A similar exception concerning {{cmd|definepalet}} has been migrated<br />
to the standard argument model but may still show the earlier behavior<br />
in not so recent installations.<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067673.html])<br />
<br />
<!--<br />
== \usepath ==<br />
Hans announced this one can be expected to be unified in the near<br />
future.<br />
[http://archive.contextgarden.net/message/20110929.151806.3ad6fbdd.en.html]<br />
<br />
What’s the status of this?<br />
--><br />
<br />
== Treacherous Dimensions ==<br />
<br />
At some places dimension-lookalikes are expected but they do not behave<br />
exactly as in TEX per se because they are evaluated differently.<br />
A very common example is the command {{cmd|setupbodyfont}} that is<br />
possibly called, albeit implicitly, in every production document.<br />
Its argument, the ''font size'', although it may look like an ordinary<br />
dimension expression, will not have the same result if it has zeros<br />
prepended or decimal places are specified.<br />
<br />
Suppose you want to set the main font to a very large size:<br />
<br />
<texcode><br />
\setupbodyfont[42pt]<br />
\starttext foobar \stoptext<br />
</texcode><br />
<br />
this works out well as long as you do not mistake the expression<br />
''42pt'' to be a real dimension.<br />
<br />
In TEX dimensions (which are really just integers) are treated the same<br />
irrespective of leading or trailing zeros used in the variable<br />
assignment.<br />
Thus the following are all equivalent:<br />
<br />
<texcode><br />
\newdimen\fortytwo\fortytwo=42pt<br />
\newdimen\fortytoo\fortytoo=042pt<br />
\newdimen\fortytww\fortytww=42.00pt<br />
<br />
\starttext<br />
\the\fortytwo\ \ifnum\fortytwo=\fortytoo\m{\top}\else\m{\bot}\fi\par<br />
\the\fortytoo\ \ifnum\fortytwo=\fortytww\m{\top}\else\m{\bot}\fi\par<br />
\the\fortytww\ \ifnum\fortytoo=\fortytww\m{\top}\else\m{\bot}\fi\par<br />
\stoptext<br />
</texcode><br />
<br />
However, this does not hold for the Context commands<br />
{{cmd|setupbodyfont}} and {{cmd|switchtobodyfont}}.<br />
With the latter macros, only the ''pure-integer'' specification<br />
(<code>42pt</code>) can be used reliably, everything else, even though it<br />
denotates the same TEX dimension, will result in a warning:<br />
<br />
<pre><br />
fonts > bodyfont 42.0pt is defined (can better be done global)<br />
</pre><br />
<br />
Additionally, if the code in question relies on font switching a lot<br />
(e.&nbsp;g. Lua snippets that calculcate font sizes from floating point<br />
numbers), there will be a ''huge'' perfomance penalty because everytime<br />
a font switch occurs, the font will be reloaded entirely.<br />
The reason for this is that the process of defining a font for the main<br />
text is accompanied by a myriad of secondary definitions for different<br />
relative font sizes ({{cmd|tfx|link=no}}, {{cmd|tfa|link=no}}<br />
[[Font_Switching#Font_sizes|and the likes]]) and shapes &ndash; the<br />
creation of the ''body font environment''.<br />
If the “size” requested by {{cmd|setupbodyfont}} cannot be found in the<br />
internal table, this environment will be rebuilt on the spot.<br />
<br />
''It is also not possible to catch these cases by predefining the corresponding bodyfont environments''<br />
by placing {{cmd|definebodyfontenvironment}} statements in the preamble.<br />
So if you have, say:<br />
<br />
<texcode><br />
\definebodyfontenvironment[42.0pt]<br />
\definebodyfontenvironment[042pt]<br />
\definebodyfontenvironment[042.0pt]<br />
\starttext<br />
\setupbodyfont[42.0pt] foo bar<br />
\setupbodyfont[042pt] foo bar<br />
\setupbodyfont[042.0pt] foo bar<br />
\stoptext<br />
</texcode><br />
<br />
the warning and slowdown will occur regardless.<br />
The only real option is to serve {{cmd|setupbodyfont}} and the likes<br />
natural integers only.<br />
<br />
Alternatively you can always employ raw font definitions, if there<br />
isn’t any need for the environment in the first place:<br />
<texcode><br />
\starttext<br />
\definedfont[file:iwona-regular.otf at 42.0pt] foo bar<br />
\definedfont[file:iwona-regular.otf at 042pt] foo bar<br />
\definedfont[file:iwona-regular.otf at 042.0pt] foo bar<br />
\stoptext<br />
</texcode><br />
Here the dimensions are ''real''.<br />
<br />
For further information see<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067324.html this] and<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/066940.html this]<br />
thread on the mailing list.<br />
<br />
<br />
= Multipass =<br />
<br />
In some circumstances, portions of code are evaluated two or more<br />
times.<br />
This can be disruptive in contexts where the order of actions is<br />
important.<br />
<br />
== Trialtypesetting ==<br />
<br />
Often the size of elements must be calculated prior to determining the<br />
optimal placements.<br />
Probably the most common example are tables:<br />
In order to align cells correctly the dimensions of later parts of the<br />
document must already be determined before anything is typeset.<br />
The stage during which this takes place is called *trial typesetting*.<br />
<br />
The system mode ''trialtypesetting'' allows fine-grained control over<br />
what code should be executed during what stage.<br />
For instance, the naive definition of a macro that increments and<br />
prints a counter register will behave erratically in tables:<br />
<br />
<context source="yes" mode="mkiv"><br />
\def \inccount {%<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]%<br />
}<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
To bypass the extra evaluation, wrap the incrementation part in an<br />
<code>\iftrialtypesetting</code> conditional.<br />
<br />
<context source="yes" mode="mkiv"><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\fi<br />
\getnumber [somecount]%<br />
}<br />
<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
Note that annoying as it may appear, the trial typesetting phase is<br />
essential for certain features to work, so take extra care when<br />
omitting it.<br />
In the example above the number itself must be present as placeholder<br />
during the first pass even though it has not been updated at this<br />
point.<br />
<br />
<texcode><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]% <= wrong!<br />
\fi<br />
}<br />
</texcode><br />
<br />
<context mode="mkiv" source="no"><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]%<br />
\fi<br />
}<br />
<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
== Tables ==<br />
<br />
In addition to trial typesetting Context also knows a ''table'' state:<br />
<br />
<context mode="mkiv" source="yes"><br />
\def \tablecheck {\ifintable In table. \else Outside table. \fi}<br />
<br />
\starttext<br />
\tablecheck<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \tablecheck \eTD \bTD \tablecheck \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
\tablecheck %% decrement<br />
\stoptext<br />
</context><br />
<br />
== Metapost ==<br />
<br />
As with TeX, Metapost sometimes requires multiple passes,<br />
especially when processing text.<br />
In below snippet, the Metapost tracer reveals that the code is actually<br />
evaluated twice:<br />
<br />
<texcode><br />
\enabletrackers[metapost.showlog]<br />
\starttext<br />
\startMPcode<br />
show "This gets printed twice.";<br />
label (btex Some label text etex, (0,0));<br />
\stopMPcode<br />
\stoptext<br />
</texcode><br />
<br />
NB removing the <code>label</code> statement will result in the second<br />
pass being omitted.<br />
<br />
In [[Metafun]], the default Metapost format in Context, the booleans<br />
<code>mfun_first_run</code> and <code>mfun_trial_run</code> allow<br />
detecting the individual stages:<br />
<br />
<texcode><br />
\enabletrackers[metapost.showlog]<br />
\starttext<br />
\startMPcode<br />
if mfun_trial_run :<br />
show "This gets printed during the trial pass.";<br />
else :<br />
show "This gets printed during the final pass.";<br />
fi;<br />
label (btex Some label text etex, (0,0));<br />
\stopMPcode<br />
\stoptext<br />
</texcode></div>Henrihttps://wiki.contextgarden.net/index.php?title=Unexpected_behavior&diff=25676Unexpected behavior2020-02-14T06:01:55Z<p>Henri: /* Assignments */</p>
<hr />
<div>If ConTeXt appears to behave in a counterintuitive way, chances are<br />
that it’s actually your intuitions that lack calibration.<br />
<br />
== Controlling Page Break Before Headings ==<br />
If you add the option <code>page=yes</code> to a heading setup, this<br />
will cause ConTeXt to break the page.<br />
Ordinarily this works as expected, unless, however, the heading<br />
immediately follows a previous section heading with no text in between.<br />
The rationale behind this is that consecutive headings are conceived of<br />
collectively as one single structural element.<br />
For example, the following code will generate only a single page<br />
break although the unit {{cmd|section}} appears twice.<br />
<br />
<texcode><br />
\setuphead[section][page=yes] %% toggle page breaking<br />
<br />
\starttext<br />
\chapter{foo} %% structural inhibits breaking<br />
\section{bar} \input knuth %% -> no break!<br />
\section{baz} \input dawkins %% -> break<br />
\stoptext<br />
</texcode><br />
<br />
In order to get the page break at the section regardless of surrounding<br />
structurals elements, you need to ''unset'' the heading parameter<br />
<code>continue</code> as well.<br />
[http://archive.contextgarden.net/message/20080107.115201.ca26c682.en.html]<br />
<br />
<texcode><br />
\setuphead[section][page=yes,continue=no]<br />
<br />
\starttext<br />
\chapter{foo}<br />
\section{bar} \input knuth %% -> break<br />
\section{baz} \input dawkins %% -> break<br />
\stoptext<br />
</texcode><br />
<br />
(For the curious, the explanation can be found in the definition of the<br />
macro {{cmd|strc_sectioning_handle_page_nop|link=no}} in {{src|strc-sec.mkiv}}).<br />
<br />
<br />
== Unsolicited Vertical Mode ==<br />
Some commands like {{cmd|framed}} cause line breaks to happen if used<br />
in vertical mode, e.g. at the beginning of a line.<br />
Example:<br />
<br />
<context source="yes"><br />
\starttext<br />
\framed{foo} bar.<br />
\stoptext<br />
</context><br />
<br />
The explanation according to the corresponding<br />
[http://wiki.contextgarden.net/FAQ#Why_is_there_a_line-break_in_the_output_after_some_commands.3F FAQ item]<br />
is that before the token <code>\frame</code> is encountered, TEX is<br />
in vertical mode.<br />
This state is ''preserved until after TEX finishes typesetting the<br />
<code>\framed</code> macro''.<br />
Consequently, horizontal mode (where paragraphs are made) is entered<br />
only at the tokens <code>bar</code>.<br />
<br />
To have the frame begin the paragraph instead, horizontal mode will<br />
have to be initiated explicitly.<br />
There are a couple macros for this purpose: the very basic<br />
{{cmd|leavevmode}} ({{src|syst-ini.mkiv}}; inserts an empty box, same<br />
as in the Plain format) and the more familiar {{cmd|dontleavehmode}}<br />
({{src|syst-aux.mkiv}}).<br />
Just use the chosen macro immediately before the <code>\framed</code> macro and<br />
everything should be fine:<br />
<br />
<context source="yes"><br />
\starttext<br />
\leavevmode \framed{foo} bar.\par<br />
\dontleavehmode \framed{foo} bar.<br />
\stoptext<br />
</context><br />
<br />
== Disappearing Crop Marks ==<br />
Crop marks, activated as <code>\setuplayout[marking=on]</code>, are a<br />
useful feature that Context supports out of the box.<br />
They have a peculiarity, though, which my make them useless in specific<br />
cases: They are, by definition, located ''outside the page dimension''.<br />
This means that they show up iff the paper size exceeds the page size.<br />
<br />
Thus if you need auxiliary lines for cutting but have the pages fit the<br />
paper size exactly, you can instead resort to enabling the '''page<br />
background frame'''.<br />
This example sums up the solutions posted by Wolfgang and Marco on<br />
[http://archive.contextgarden.net/message/20120605.202113.0989aa34.en.html<br />
the Context Mailing List].<br />
<texcode><br />
%% the paper size will be a multiple of the page sizes<br />
\setuppapersize [A6,landscape] [A3] <br />
\setuplayout [nx=2,ny=4]%, marking=on] <br />
%% enable the page frame<br />
\setupbackgrounds [page] [frame=on]<br />
%% some further display setups<br />
\setuppagenumbering [location=] <br />
\setupbackgrounds [page] [background=color, backgroundcolor=gray] <br />
\setupbodyfont [sans,58pt] <br />
%% testing ...<br />
\starttext <br />
\dorecurse{4} <br />
{\null\vfill\centerline\recurselevel\vfill\null\page} <br />
\stoptext<br />
</texcode><br />
<br />
== Left and Right ==<br />
When it comes to the justification of paragraphs, do not trust your<br />
intuitions about ''handedness''.<br />
This is a [[Right_and_left|FAQ item]].<br />
<br />
== Footnotes: The Difference between {{cmd|setupnotation}} and {{cmd|setupnote}} ==<br />
<br />
There is a bit of terminology mess concerning notes.<br />
<br />
<!-- I really loathe the wikitext table syntax. --><br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Instruction !! Goal<br />
|-<br />
| {{cmd|setupnotation}}<br />
| This command configures the '''note insert''', i.e. the textual content that will usually be placed at the bottom (with footnotes) or the end of the text (with endnotes). (The control sequence used to be <code>\setupnotedefinition</code>.)<br />
|-<br />
| {{cmd|setupnote}}<br />
| Configure the '''note environment''' where the inserts will be located. Inherits some parameters from {{cmd|framed}}.<br />
|-<br />
| <code>\setupnote[textstyle=,textcommand=]</code><br />
| Configure the '''note symbol''' as appears in the main text, where the note macro is called.<br />
|-<br />
| Plural forms {{cmd|setupnotes}}, {{cmd|setupnotations}}<br />
| These are synonyms for their singular forms.<br />
|-<br />
| {{cmd|setupfootnotes}}<br />
| This is equivalent to <code>\setupnote[footnote]</code>.<br />
|}<br />
<br />
''Summary'':<br />
to setup a blue note, you would first need to define and configure the<br />
insert via {{cmd|setupnotation}}:<br />
<texcode><br />
\definenote [bluenote] [footnote]<br />
\setupnotation [bluenote] [<br />
color=blue,<br />
style=bf,<br />
]<br />
<br />
\starttext foo\bluenote{bar} baz \stoptext<br />
</texcode><br />
<br />
Now adjust the container where the blue notes will reside at the bottom<br />
of the page ({{cmd|setupnote}}):<br />
<br />
<texcode><br />
\definenote [bluenote] [footnote]<br />
\setupnote [bluenote] [<br />
frame=on, %% frame containing all inserts<br />
framecolor=blue,<br />
background=screen,<br />
rulecolor=blue, %% the line above the inserts<br />
rulethickness=1pt, %% both the frame and line width<br />
]<br />
<br />
\starttext foo\bluenote{bar} baz \bluenote{xyzzy} \stoptext<br />
</texcode><br />
<br />
Finally, direct your attention to the note indicator, most commonly a<br />
number or a symbol.<br />
For precise control over the placement define a monadic macro and hook<br />
it into <code>textcommand</code>.<br />
<br />
<texcode><br />
\setupnote [bluenote] [<br />
textstyle=\tx\sans\bold\blue,<br />
textcommand=\myfootnotecommand,<br />
]<br />
\define[1]\myfootnotecommand{\rotate[rotation=42]{#1}}<br />
<br />
\starttext foo\bluenote{bar} baz \bluenote{xyzzy} \stoptext<br />
</texcode><br />
<br />
(For more definite answers concerning the ''notes'' mechanism, use the<br />
source, Luke: {{src|strc-not.mkvi}}.)<br />
<br />
<br />
== Float Insertion Issues ==<br />
<br />
Floating objects can be tricky.<br />
Deciding where they fit best is hard enough, actually getting them<br />
there may be a lot tougher.<br />
Inserting a float will force a line break where the object is<br />
referenced in the source code.<br />
Thus, very long paragraphs may not leave an opportunity to inject the<br />
float if they cover the entire page.<br />
[http://archive.contextgarden.net/message/20120405.103626.a1349c1c.en.html]<br />
<texcode><br />
\starttext<br />
Cows make<br />
\placefigure[top]{A genuine Dutch cow.}{\externalfigure[cow]}<br />
great pets.<br />
\stoptext<br />
</texcode><br />
In these cases the ''postponing mechanism'' offers a reliable way out<br />
({{cmd|startpostponing}}).<br />
It lets you specify an offset (in pages) by which the content of the<br />
postponing environment will be delayed.<br />
In order to place a floating object at the top of the ''n''th page from<br />
the location it is encountered, its argument has needs to be<br />
<code>[+n]</code>.<br />
(Absolute pages can be specified as simply <code>[n]</code>.)<br />
E.&nbsp;g. to put the foat on the following page:<br />
<texcode><br />
\starttext<br />
\startpostponing[+1]<br />
\placefigure[top]{A genuine Dutch cow.}{\externalfigure[cow.pdf]}<br />
\stoppostponing<br />
\input knuth<br />
\page<br />
Cows make great pets.<br />
\stoptext<br />
</texcode><br />
<br />
Another solution can be the less-known ''hangaround environment''<br />
({{cmd|starthangaround}}, cf.<br />
[[Using_Graphics#Flow_text_around_a_picture|Hangaround]]).<br />
It lets the text of a given paragraph (the content of the environment)<br />
flow around a box (the first argument).<br />
In contrast to real floats it does not place a caption.<br />
This poses a problem in MkIV as the new code will not allow placing<br />
captions arbitrarily.<br />
[[http://repo.or.cz/w/context.git/blob/refs/heads/origin:/tex/context/base/strc-flt.mkvi#l257]]<br />
(If you desparately need separate captions please send a feature<br />
request to one of the<br />
[[ConTeXt_Mailing_Lists#Mailing Lists]]).<br />
<br />
<context source="yes" mode="mkii"><br />
\starttext<br />
\input dawkins<br />
<br />
\starthangaround{<br />
\framed[align=right,frame=off,width=.3\textwidth]{<br />
\externalfigure [cow] [width=.3\textwidth]\crlf<br />
%% NB the fake caption works *only in mkii*<br />
\placefloatcaption<br />
[figure]<br />
[ref:acow]<br />
{A smiling Dutch cow.<br />
{\italic Bos primigenius taurus}}<br />
}<br />
}<br />
\input dawkins<br />
\stophangaround<br />
<br />
\input dawkins<br />
\stoptext<br />
</context><br />
<br />
=== The “paragraph in a group” problem ===<br />
<br />
Another common issue with sidefloats is starting a paragraph in a group.<br />
<br />
<context source="yes" mode="mkiv"><br />
\placefigure[right,none]{}{\externalfigure[cow][width=0.25\textwidth]}<br />
Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br />
<br />
{\bf Oeps} \samplefile{lorem}<br />
</context><br />
As you can see the paragraph starting with “Oeps” just overflows into the picture.<br />
That is a well-known problem and there are posts about it on the mailing<br />
list every once in a while. The sidefigure mechanism uses <code>\parshape</code> to<br />
make the paragraph flow around the figure. The <code>\parshape</code> primitive only<br />
applies to a single paragraph, so ConTeXt communicates the current<br />
<code>\parshape</code> settings to the next paragraph using <code>\everypar</code>. However, when<br />
a new paragraph starts in a group, i.e.<br />
<texcode><br />
{\bf Oeps} ...<br />
</texcode><br />
TeX inserts the <code>\everypar</code> tokens inside that group because only the<br />
first letter starts the paragraph. That is to say is effectively looks<br />
like this<br />
<texcode><br />
% \everypar inserted inside the group<br />
% ~~~v<br />
{\bf \the\everypar Opes} ...<br />
% ~~~~~~~~~~~~~~~~~~~~~^<br />
% Setting of \everypar are discarded again when leaving the group and \parshape is lost.<br />
</texcode><br />
You have to explicitly start a new paragraph before opening a group.<br />
The easiest way to do this is<br />
<texcode><br />
\dontleavehmode{\bf Oeps} ...<br />
</texcode><br />
Now the <code>\everypar</code> tokens are inserted directly after {{cmd|dontleavehmode}}<br />
outside the group and the problem goes away.<br />
<br />
= Syntax =<br />
== Assignments ==<br />
<br />
Space before commas or before the closing <code>]</code> is '''''not''''' ignored in ConTeXt. That is a common pitfall and leads to errors that can be confusing for beginner, especially those coming from LaTeX, where this is the default behaviour. Formatting your keys like this might look nice but leads to spurious spaces:<br />
<context source="yes" mode="mkiv"><br />
\getparameters[test]<br />
[ foo=bar<br />
, hello=world<br />
]<br />
“\testfoo” “\testhello”<br />
</context><br />
Instead it is recommended to adhere to the style that is used in the ConTeXt source to avoid problems with trailing spaces:<br />
<context source="yes" mode="mkiv"><br />
\getparameters[test]<br />
[foo=bar,<br />
hello=world]<br />
“\testfoo” “\testhello”<br />
</context><br />
<br />
In the most common form of key-value type arguments, ConTeXt will<br />
accept trailing commas or even empty items. For example, the following<br />
code shows this tolerance for the command {{cmd|definehighlight}}.<br />
<br />
<texcode><br />
\definehighlight [dontmiss] [<br />
color=red,<br />
,, %% empty option: do nothing<br />
style=bold, %% trailing delimiter<br />
]<br />
</texcode><br />
<br />
This is the syntax accepted e.g. by the majority of setups and<br />
[[Commands_with_KeyVal_arguments|<code>\getparameters</code>]].<br />
(For the parser code cf. {{src|syst-aux.mkiv}}.)<br />
<br />
There are, however, exceptions to this rule. A known case where<br />
options are processed in a less tolerant fashion is<br />
{{cmd|setuplabeltext}}.<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067585.html]<br />
Thus the following snippet will not compile, forcing ConTeXt to fail<br />
with a cryptic <code>Argument of ...</code> error message.<br />
<texcode><br />
\setuplabeltext<br />
[Nomen=nomen,<br />
Est=est,<br />
Omen=est,] %% <= fails!<br />
\setuplabeltext [Nomen=nomen, Est=est, Omen=omen] %% <= works<br />
\starttext<br />
\labeltext{Nomen}<br />
\labeltext{Est}<br />
\labeltext{Omen}<br />
\stoptext<br />
</texcode><br />
<br />
(A similar exception concerning {{cmd|definepalet}} has been migrated<br />
to the standard argument model but may still show the earlier behavior<br />
in not so recent installations.<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067673.html])<br />
<br />
<!--<br />
== \usepath ==<br />
Hans announced this one can be expected to be unified in the near<br />
future.<br />
[http://archive.contextgarden.net/message/20110929.151806.3ad6fbdd.en.html]<br />
<br />
What’s the status of this?<br />
--><br />
<br />
== Treacherous Dimensions ==<br />
<br />
At some places dimension-lookalikes are expected but they do not behave<br />
exactly as in TEX per se because they are evaluated differently.<br />
A very common example is the command {{cmd|setupbodyfont}} that is<br />
possibly called, albeit implicitly, in every production document.<br />
Its argument, the ''font size'', although it may look like an ordinary<br />
dimension expression, will not have the same result if it has zeros<br />
prepended or decimal places are specified.<br />
<br />
Suppose you want to set the main font to a very large size:<br />
<br />
<texcode><br />
\setupbodyfont[42pt]<br />
\starttext foobar \stoptext<br />
</texcode><br />
<br />
this works out well as long as you do not mistake the expression<br />
''42pt'' to be a real dimension.<br />
<br />
In TEX dimensions (which are really just integers) are treated the same<br />
irrespective of leading or trailing zeros used in the variable<br />
assignment.<br />
Thus the following are all equivalent:<br />
<br />
<texcode><br />
\newdimen\fortytwo\fortytwo=42pt<br />
\newdimen\fortytoo\fortytoo=042pt<br />
\newdimen\fortytww\fortytww=42.00pt<br />
<br />
\starttext<br />
\the\fortytwo\ \ifnum\fortytwo=\fortytoo\m{\top}\else\m{\bot}\fi\par<br />
\the\fortytoo\ \ifnum\fortytwo=\fortytww\m{\top}\else\m{\bot}\fi\par<br />
\the\fortytww\ \ifnum\fortytoo=\fortytww\m{\top}\else\m{\bot}\fi\par<br />
\stoptext<br />
</texcode><br />
<br />
However, this does not hold for the Context commands<br />
{{cmd|setupbodyfont}} and {{cmd|switchtobodyfont}}.<br />
With the latter macros, only the ''pure-integer'' specification<br />
(<code>42pt</code>) can be used reliably, everything else, even though it<br />
denotates the same TEX dimension, will result in a warning:<br />
<br />
<pre><br />
fonts > bodyfont 42.0pt is defined (can better be done global)<br />
</pre><br />
<br />
Additionally, if the code in question relies on font switching a lot<br />
(e.&nbsp;g. Lua snippets that calculcate font sizes from floating point<br />
numbers), there will be a ''huge'' perfomance penalty because everytime<br />
a font switch occurs, the font will be reloaded entirely.<br />
The reason for this is that the process of defining a font for the main<br />
text is accompanied by a myriad of secondary definitions for different<br />
relative font sizes ({{cmd|tfx|link=no}}, {{cmd|tfa|link=no}}<br />
[[Font_Switching#Font_sizes|and the likes]]) and shapes &ndash; the<br />
creation of the ''body font environment''.<br />
If the “size” requested by {{cmd|setupbodyfont}} cannot be found in the<br />
internal table, this environment will be rebuilt on the spot.<br />
<br />
''It is also not possible to catch these cases by predefining the corresponding bodyfont environments''<br />
by placing {{cmd|definebodyfontenvironment}} statements in the preamble.<br />
So if you have, say:<br />
<br />
<texcode><br />
\definebodyfontenvironment[42.0pt]<br />
\definebodyfontenvironment[042pt]<br />
\definebodyfontenvironment[042.0pt]<br />
\starttext<br />
\setupbodyfont[42.0pt] foo bar<br />
\setupbodyfont[042pt] foo bar<br />
\setupbodyfont[042.0pt] foo bar<br />
\stoptext<br />
</texcode><br />
<br />
the warning and slowdown will occur regardless.<br />
The only real option is to serve {{cmd|setupbodyfont}} and the likes<br />
natural integers only.<br />
<br />
Alternatively you can always employ raw font definitions, if there<br />
isn’t any need for the environment in the first place:<br />
<texcode><br />
\starttext<br />
\definedfont[file:iwona-regular.otf at 42.0pt] foo bar<br />
\definedfont[file:iwona-regular.otf at 042pt] foo bar<br />
\definedfont[file:iwona-regular.otf at 042.0pt] foo bar<br />
\stoptext<br />
</texcode><br />
Here the dimensions are ''real''.<br />
<br />
For further information see<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067324.html this] and<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/066940.html this]<br />
thread on the mailing list.<br />
<br />
<br />
= Multipass =<br />
<br />
In some circumstances, portions of code are evaluated two or more<br />
times.<br />
This can be disruptive in contexts where the order of actions is<br />
important.<br />
<br />
== Trialtypesetting ==<br />
<br />
Often the size of elements must be calculated prior to determining the<br />
optimal placements.<br />
Probably the most common example are tables:<br />
In order to align cells correctly the dimensions of later parts of the<br />
document must already be determined before anything is typeset.<br />
The stage during which this takes place is called *trial typesetting*.<br />
<br />
The system mode ''trialtypesetting'' allows fine-grained control over<br />
what code should be executed during what stage.<br />
For instance, the naive definition of a macro that increments and<br />
prints a counter register will behave erratically in tables:<br />
<br />
<context source="yes" mode="mkiv"><br />
\def \inccount {%<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]%<br />
}<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
To bypass the extra evaluation, wrap the incrementation part in an<br />
<code>\iftrialtypesetting</code> conditional.<br />
<br />
<context source="yes" mode="mkiv"><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\fi<br />
\getnumber [somecount]%<br />
}<br />
<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
Note that annoying as it may appear, the trial typesetting phase is<br />
essential for certain features to work, so take extra care when<br />
omitting it.<br />
In the example above the number itself must be present as placeholder<br />
during the first pass even though it has not been updated at this<br />
point.<br />
<br />
<texcode><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]% <= wrong!<br />
\fi<br />
}<br />
</texcode><br />
<br />
<context mode="mkiv" source="no"><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]%<br />
\fi<br />
}<br />
<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
== Tables ==<br />
<br />
In addition to trial typesetting Context also knows a ''table'' state:<br />
<br />
<context mode="mkiv" source="yes"><br />
\def \tablecheck {\ifintable In table. \else Outside table. \fi}<br />
<br />
\starttext<br />
\tablecheck<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \tablecheck \eTD \bTD \tablecheck \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
\tablecheck %% decrement<br />
\stoptext<br />
</context><br />
<br />
== Metapost ==<br />
<br />
As with TeX, Metapost sometimes requires multiple passes,<br />
especially when processing text.<br />
In below snippet, the Metapost tracer reveals that the code is actually<br />
evaluated twice:<br />
<br />
<texcode><br />
\enabletrackers[metapost.showlog]<br />
\starttext<br />
\startMPcode<br />
show "This gets printed twice.";<br />
label (btex Some label text etex, (0,0));<br />
\stopMPcode<br />
\stoptext<br />
</texcode><br />
<br />
NB removing the <code>label</code> statement will result in the second<br />
pass being omitted.<br />
<br />
In [[Metafun]], the default Metapost format in Context, the booleans<br />
<code>mfun_first_run</code> and <code>mfun_trial_run</code> allow<br />
detecting the individual stages:<br />
<br />
<texcode><br />
\enabletrackers[metapost.showlog]<br />
\starttext<br />
\startMPcode<br />
if mfun_trial_run :<br />
show "This gets printed during the trial pass.";<br />
else :<br />
show "This gets printed during the final pass.";<br />
fi;<br />
label (btex Some label text etex, (0,0));<br />
\stopMPcode<br />
\stoptext<br />
</texcode></div>Henrihttps://wiki.contextgarden.net/index.php?title=Unexpected_behavior&diff=24267Unexpected behavior2019-07-18T23:00:37Z<p>Henri: Paragraph in a group issue</p>
<hr />
<div>If ConTeXt appears to behave in a counterintuitive way, chances are<br />
that it’s actually your intuitions that lack calibration.<br />
<br />
== Controlling Page Break Before Headings ==<br />
If you add the option <code>page=yes</code> to a heading setup, this<br />
will cause ConTeXt to break the page.<br />
Ordinarily this works as expected, unless, however, the heading<br />
immediately follows a previous section heading with no text in between.<br />
The rationale behind this is that consecutive headings are conceived of<br />
collectively as one single structural element.<br />
For example, the following code will generate only a single page<br />
break although the unit {{cmd|section}} appears twice.<br />
<br />
<texcode><br />
\setuphead[section][page=yes] %% toggle page breaking<br />
<br />
\starttext<br />
\chapter{foo} %% structural inhibits breaking<br />
\section{bar} \input knuth %% -> no break!<br />
\section{baz} \input dawkins %% -> break<br />
\stoptext<br />
</texcode><br />
<br />
In order to get the page break at the section regardless of surrounding<br />
structurals elements, you need to ''unset'' the heading parameter<br />
<code>continue</code> as well.<br />
[http://archive.contextgarden.net/message/20080107.115201.ca26c682.en.html]<br />
<br />
<texcode><br />
\setuphead[section][page=yes,continue=no]<br />
<br />
\starttext<br />
\chapter{foo}<br />
\section{bar} \input knuth %% -> break<br />
\section{baz} \input dawkins %% -> break<br />
\stoptext<br />
</texcode><br />
<br />
(For the curious, the explanation can be found in the definition of the<br />
macro {{cmd|strc_sectioning_handle_page_nop|link=no}} in {{src|strc-sec.mkiv}}).<br />
<br />
<br />
== Unsolicited Vertical Mode ==<br />
Some commands like {{cmd|framed}} cause line breaks to happen if used<br />
in vertical mode, e.g. at the beginning of a line.<br />
Example:<br />
<br />
<context source="yes"><br />
\starttext<br />
\framed{foo} bar.<br />
\stoptext<br />
</context><br />
<br />
The explanation according to the corresponding<br />
[http://wiki.contextgarden.net/FAQ#Why_is_there_a_line-break_in_the_output_after_some_commands.3F FAQ item]<br />
is that before the token <code>\frame</code> is encountered, TEX is<br />
in vertical mode.<br />
This state is ''preserved until after TEX finishes typesetting the<br />
<code>\framed</code> macro''.<br />
Consequently, horizontal mode (where paragraphs are made) is entered<br />
only at the tokens <code>bar</code>.<br />
<br />
To have the frame begin the paragraph instead, horizontal mode will<br />
have to be initiated explicitly.<br />
There are a couple macros for this purpose: the very basic<br />
{{cmd|leavevmode}} ({{src|syst-ini.mkiv}}; inserts an empty box, same<br />
as in the Plain format) and the more familiar {{cmd|dontleavehmode}}<br />
({{src|syst-aux.mkiv}}).<br />
Just use the chosen macro immediately before the <code>\framed</code> macro and<br />
everything should be fine:<br />
<br />
<context source="yes"><br />
\starttext<br />
\leavevmode \framed{foo} bar.\par<br />
\dontleavehmode \framed{foo} bar.<br />
\stoptext<br />
</context><br />
<br />
== Disappearing Crop Marks ==<br />
Crop marks, activated as <code>\setuplayout[marking=on]</code>, are a<br />
useful feature that Context supports out of the box.<br />
They have a peculiarity, though, which my make them useless in specific<br />
cases: They are, by definition, located ''outside the page dimension''.<br />
This means that they show up iff the paper size exceeds the page size.<br />
<br />
Thus if you need auxiliary lines for cutting but have the pages fit the<br />
paper size exactly, you can instead resort to enabling the '''page<br />
background frame'''.<br />
This example sums up the solutions posted by Wolfgang and Marco on<br />
[http://archive.contextgarden.net/message/20120605.202113.0989aa34.en.html<br />
the Context Mailing List].<br />
<texcode><br />
%% the paper size will be a multiple of the page sizes<br />
\setuppapersize [A6,landscape] [A3] <br />
\setuplayout [nx=2,ny=4]%, marking=on] <br />
%% enable the page frame<br />
\setupbackgrounds [page] [frame=on]<br />
%% some further display setups<br />
\setuppagenumbering [location=] <br />
\setupbackgrounds [page] [background=color, backgroundcolor=gray] <br />
\setupbodyfont [sans,58pt] <br />
%% testing ...<br />
\starttext <br />
\dorecurse{4} <br />
{\null\vfill\centerline\recurselevel\vfill\null\page} <br />
\stoptext<br />
</texcode><br />
<br />
== Left and Right ==<br />
When it comes to the justification of paragraphs, do not trust your<br />
intuitions about ''handedness''.<br />
This is a [[Right_and_left|FAQ item]].<br />
<br />
== Footnotes: The Difference between {{cmd|setupnotation}} and {{cmd|setupnote}} ==<br />
<br />
There is a bit of terminology mess concerning notes.<br />
<br />
<!-- I really loathe the wikitext table syntax. --><br />
{|cellpadding="10" style="border:2px solid #addeff"<br />
! style="background:#addeff;" | Instruction !! Goal<br />
|-<br />
| {{cmd|setupnotation}}<br />
| This command configures the '''note insert''', i.e. the textual content that will usually be placed at the bottom (with footnotes) or the end of the text (with endnotes). (The control sequence used to be <code>\setupnotedefinition</code>.)<br />
|-<br />
| {{cmd|setupnote}}<br />
| Configure the '''note environment''' where the inserts will be located. Inherits some parameters from {{cmd|framed}}.<br />
|-<br />
| <code>\setupnote[textstyle=,textcommand=]</code><br />
| Configure the '''note symbol''' as appears in the main text, where the note macro is called.<br />
|-<br />
| Plural forms {{cmd|setupnotes}}, {{cmd|setupnotations}}<br />
| These are synonyms for their singular forms.<br />
|-<br />
| {{cmd|setupfootnotes}}<br />
| This is equivalent to <code>\setupnote[footnote]</code>.<br />
|}<br />
<br />
''Summary'':<br />
to setup a blue note, you would first need to define and configure the<br />
insert via {{cmd|setupnotation}}:<br />
<texcode><br />
\definenote [bluenote] [footnote]<br />
\setupnotation [bluenote] [<br />
color=blue,<br />
style=bf,<br />
]<br />
<br />
\starttext foo\bluenote{bar} baz \stoptext<br />
</texcode><br />
<br />
Now adjust the container where the blue notes will reside at the bottom<br />
of the page ({{cmd|setupnote}}):<br />
<br />
<texcode><br />
\definenote [bluenote] [footnote]<br />
\setupnote [bluenote] [<br />
frame=on, %% frame containing all inserts<br />
framecolor=blue,<br />
background=screen,<br />
rulecolor=blue, %% the line above the inserts<br />
rulethickness=1pt, %% both the frame and line width<br />
]<br />
<br />
\starttext foo\bluenote{bar} baz \bluenote{xyzzy} \stoptext<br />
</texcode><br />
<br />
Finally, direct your attention to the note indicator, most commonly a<br />
number or a symbol.<br />
For precise control over the placement define a monadic macro and hook<br />
it into <code>textcommand</code>.<br />
<br />
<texcode><br />
\setupnote [bluenote] [<br />
textstyle=\tx\sans\bold\blue,<br />
textcommand=\myfootnotecommand,<br />
]<br />
\define[1]\myfootnotecommand{\rotate[rotation=42]{#1}}<br />
<br />
\starttext foo\bluenote{bar} baz \bluenote{xyzzy} \stoptext<br />
</texcode><br />
<br />
(For more definite answers concerning the ''notes'' mechanism, use the<br />
source, Luke: {{src|strc-not.mkvi}}.)<br />
<br />
<br />
== Float Insertion Issues ==<br />
<br />
Floating objects can be tricky.<br />
Deciding where they fit best is hard enough, actually getting them<br />
there may be a lot tougher.<br />
Inserting a float will force a line break where the object is<br />
referenced in the source code.<br />
Thus, very long paragraphs may not leave an opportunity to inject the<br />
float if they cover the entire page.<br />
[http://archive.contextgarden.net/message/20120405.103626.a1349c1c.en.html]<br />
<texcode><br />
\starttext<br />
Cows make<br />
\placefigure[top]{A genuine Dutch cow.}{\externalfigure[cow]}<br />
great pets.<br />
\stoptext<br />
</texcode><br />
In these cases the ''postponing mechanism'' offers a reliable way out<br />
({{cmd|startpostponing}}).<br />
It lets you specify an offset (in pages) by which the content of the<br />
postponing environment will be delayed.<br />
In order to place a floating object at the top of the ''n''th page from<br />
the location it is encountered, its argument has needs to be<br />
<code>[+n]</code>.<br />
(Absolute pages can be specified as simply <code>[n]</code>.)<br />
E.&nbsp;g. to put the foat on the following page:<br />
<texcode><br />
\starttext<br />
\startpostponing[+1]<br />
\placefigure[top]{A genuine Dutch cow.}{\externalfigure[cow.pdf]}<br />
\stoppostponing<br />
\input knuth<br />
\page<br />
Cows make great pets.<br />
\stoptext<br />
</texcode><br />
<br />
Another solution can be the less-known ''hangaround environment''<br />
({{cmd|starthangaround}}, cf.<br />
[[Using_Graphics#Flow_text_around_a_picture|Hangaround]]).<br />
It lets the text of a given paragraph (the content of the environment)<br />
flow around a box (the first argument).<br />
In contrast to real floats it does not place a caption.<br />
This poses a problem in MkIV as the new code will not allow placing<br />
captions arbitrarily.<br />
[[http://repo.or.cz/w/context.git/blob/refs/heads/origin:/tex/context/base/strc-flt.mkvi#l257]]<br />
(If you desparately need separate captions please send a feature<br />
request to one of the<br />
[[ConTeXt_Mailing_Lists#Mailing Lists]]).<br />
<br />
<context source="yes" mode="mkii"><br />
\starttext<br />
\input dawkins<br />
<br />
\starthangaround{<br />
\framed[align=right,frame=off,width=.3\textwidth]{<br />
\externalfigure [cow] [width=.3\textwidth]\crlf<br />
%% NB the fake caption works *only in mkii*<br />
\placefloatcaption<br />
[figure]<br />
[ref:acow]<br />
{A smiling Dutch cow.<br />
{\italic Bos primigenius taurus}}<br />
}<br />
}<br />
\input dawkins<br />
\stophangaround<br />
<br />
\input dawkins<br />
\stoptext<br />
</context><br />
<br />
=== The “paragraph in a group” problem ===<br />
<br />
Another common issue with sidefloats is starting a paragraph in a group.<br />
<br />
<context source="yes" mode="mkiv"><br />
\placefigure[right,none]{}{\externalfigure[cow][width=0.25\textwidth]}<br />
Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br />
<br />
{\bf Oeps} \samplefile{lorem}<br />
</context><br />
As you can see the paragraph starting with “Oeps” just overflows into the picture.<br />
That is a well-known problem and there are posts about it on the mailing<br />
list every once in a while. The sidefigure mechanism uses <code>\parshape</code> to<br />
make the paragraph flow around the figure. The <code>\parshape</code> primitive only<br />
applies to a single paragraph, so ConTeXt communicates the current<br />
<code>\parshape</code> settings to the next paragraph using <code>\everypar</code>. However, when<br />
a new paragraph starts in a group, i.e.<br />
<texcode><br />
{\bf Oeps} ...<br />
</texcode><br />
TeX inserts the <code>\everypar</code> tokens inside that group because only the<br />
first letter starts the paragraph. That is to say is effectively looks<br />
like this<br />
<texcode><br />
% \everypar inserted inside the group<br />
% ~~~v<br />
{\bf \the\everypar Opes} ...<br />
% ~~~~~~~~~~~~~~~~~~~~~^<br />
% Setting of \everypar are discarded again when leaving the group and \parshape is lost.<br />
</texcode><br />
You have to explicitly start a new paragraph before opening a group.<br />
The easiest way to do this is<br />
<texcode><br />
\dontleavehmode{\bf Oeps} ...<br />
</texcode><br />
Now the <code>\everypar</code> tokens are inserted directly after {{cmd|dontleavehmode}}<br />
outside the group and the problem goes away.<br />
<br />
= Syntax =<br />
== Assignments ==<br />
<br />
In the most common form of key-value type arguments, ConTeXt will<br />
accept trailing commas or even empty items. For example, the following<br />
code shows this tolerance for the command {{cmd|definehighlight}}.<br />
<br />
<texcode><br />
\definehighlight [dontmiss] [<br />
color=red,<br />
,, %% empty option: do nothing<br />
style=bold, %% trailing delimiter<br />
]<br />
</texcode><br />
<br />
This is the syntax accepted e.g. by the majority of setups and<br />
[[Commands_with_KeyVal_arguments|<code>\getparameters</code>]].<br />
(For the parser code cf. {{src|syst-aux.mkiv}}.)<br />
<br />
There are, however, exceptions to this rule. A known case where<br />
options are processed in a less tolerant fashion is<br />
{{cmd|setuplabeltext}}.<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067585.html]<br />
Thus the following snippet will not compile, forcing ConTeXt to fail<br />
with a cryptic <code>Argument of ...</code> error message.<br />
<texcode><br />
\setuplabeltext<br />
[Nomen=nomen,<br />
Est=est,<br />
Omen=est,] %% <= fails!<br />
\setuplabeltext [Nomen=nomen, Est=est, Omen=omen] %% <= works<br />
\starttext<br />
\labeltext{Nomen}<br />
\labeltext{Est}<br />
\labeltext{Omen}<br />
\stoptext<br />
</texcode><br />
<br />
(A similar exception concerning {{cmd|definepalet}} has been migrated<br />
to the standard argument model but may still show the earlier behavior<br />
in not so recent installations.<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067673.html])<br />
<br />
<!--<br />
== \usepath ==<br />
Hans announced this one can be expected to be unified in the near<br />
future.<br />
[http://archive.contextgarden.net/message/20110929.151806.3ad6fbdd.en.html]<br />
<br />
What’s the status of this?<br />
--><br />
<br />
== Treacherous Dimensions ==<br />
<br />
At some places dimension-lookalikes are expected but they do not behave<br />
exactly as in TEX per se because they are evaluated differently.<br />
A very common example is the command {{cmd|setupbodyfont}} that is<br />
possibly called, albeit implicitly, in every production document.<br />
Its argument, the ''font size'', although it may look like an ordinary<br />
dimension expression, will not have the same result if it has zeros<br />
prepended or decimal places are specified.<br />
<br />
Suppose you want to set the main font to a very large size:<br />
<br />
<texcode><br />
\setupbodyfont[42pt]<br />
\starttext foobar \stoptext<br />
</texcode><br />
<br />
this works out well as long as you do not mistake the expression<br />
''42pt'' to be a real dimension.<br />
<br />
In TEX dimensions (which are really just integers) are treated the same<br />
irrespective of leading or trailing zeros used in the variable<br />
assignment.<br />
Thus the following are all equivalent:<br />
<br />
<texcode><br />
\newdimen\fortytwo\fortytwo=42pt<br />
\newdimen\fortytoo\fortytoo=042pt<br />
\newdimen\fortytww\fortytww=42.00pt<br />
<br />
\starttext<br />
\the\fortytwo\ \ifnum\fortytwo=\fortytoo\m{\top}\else\m{\bot}\fi\par<br />
\the\fortytoo\ \ifnum\fortytwo=\fortytww\m{\top}\else\m{\bot}\fi\par<br />
\the\fortytww\ \ifnum\fortytoo=\fortytww\m{\top}\else\m{\bot}\fi\par<br />
\stoptext<br />
</texcode><br />
<br />
However, this does not hold for the Context commands<br />
{{cmd|setupbodyfont}} and {{cmd|switchtobodyfont}}.<br />
With the latter macros, only the ''pure-integer'' specification<br />
(<code>42pt</code>) can be used reliably, everything else, even though it<br />
denotates the same TEX dimension, will result in a warning:<br />
<br />
<pre><br />
fonts > bodyfont 42.0pt is defined (can better be done global)<br />
</pre><br />
<br />
Additionally, if the code in question relies on font switching a lot<br />
(e.&nbsp;g. Lua snippets that calculcate font sizes from floating point<br />
numbers), there will be a ''huge'' perfomance penalty because everytime<br />
a font switch occurs, the font will be reloaded entirely.<br />
The reason for this is that the process of defining a font for the main<br />
text is accompanied by a myriad of secondary definitions for different<br />
relative font sizes ({{cmd|tfx|link=no}}, {{cmd|tfa|link=no}}<br />
[[Font_Switching#Font_sizes|and the likes]]) and shapes &ndash; the<br />
creation of the ''body font environment''.<br />
If the “size” requested by {{cmd|setupbodyfont}} cannot be found in the<br />
internal table, this environment will be rebuilt on the spot.<br />
<br />
''It is also not possible to catch these cases by predefining the corresponding bodyfont environments''<br />
by placing {{cmd|definebodyfontenvironment}} statements in the preamble.<br />
So if you have, say:<br />
<br />
<texcode><br />
\definebodyfontenvironment[42.0pt]<br />
\definebodyfontenvironment[042pt]<br />
\definebodyfontenvironment[042.0pt]<br />
\starttext<br />
\setupbodyfont[42.0pt] foo bar<br />
\setupbodyfont[042pt] foo bar<br />
\setupbodyfont[042.0pt] foo bar<br />
\stoptext<br />
</texcode><br />
<br />
the warning and slowdown will occur regardless.<br />
The only real option is to serve {{cmd|setupbodyfont}} and the likes<br />
natural integers only.<br />
<br />
Alternatively you can always employ raw font definitions, if there<br />
isn’t any need for the environment in the first place:<br />
<texcode><br />
\starttext<br />
\definedfont[file:iwona-regular.otf at 42.0pt] foo bar<br />
\definedfont[file:iwona-regular.otf at 042pt] foo bar<br />
\definedfont[file:iwona-regular.otf at 042.0pt] foo bar<br />
\stoptext<br />
</texcode><br />
Here the dimensions are ''real''.<br />
<br />
For further information see<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/067324.html this] and<br />
[http://www.ntg.nl/pipermail/ntg-context/2012/066940.html this]<br />
thread on the mailing list.<br />
<br />
<br />
= Multipass =<br />
<br />
In some circumstances, portions of code are evaluated two or more<br />
times.<br />
This can be disruptive in contexts where the order of actions is<br />
important.<br />
<br />
== Trialtypesetting ==<br />
<br />
Often the size of elements must be calculated prior to determining the<br />
optimal placements.<br />
Probably the most common example are tables:<br />
In order to align cells correctly the dimensions of later parts of the<br />
document must already be determined before anything is typeset.<br />
The stage during which this takes place is called *trial typesetting*.<br />
<br />
The system mode ''trialtypesetting'' allows fine-grained control over<br />
what code should be executed during what stage.<br />
For instance, the naive definition of a macro that increments and<br />
prints a counter register will behave erratically in tables:<br />
<br />
<context source="yes" mode="mkiv"><br />
\def \inccount {%<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]%<br />
}<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
To bypass the extra evaluation, wrap the incrementation part in an<br />
<code>\iftrialtypesetting</code> conditional.<br />
<br />
<context source="yes" mode="mkiv"><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\fi<br />
\getnumber [somecount]%<br />
}<br />
<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
Note that annoying as it may appear, the trial typesetting phase is<br />
essential for certain features to work, so take extra care when<br />
omitting it.<br />
In the example above the number itself must be present as placeholder<br />
during the first pass even though it has not been updated at this<br />
point.<br />
<br />
<texcode><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]% <= wrong!<br />
\fi<br />
}<br />
</texcode><br />
<br />
<context mode="mkiv" source="no"><br />
\def \inccount {%<br />
\iftrialtypesetting \else<br />
\incrementnumber [somecount]%<br />
\getnumber [somecount]%<br />
\fi<br />
}<br />
<br />
\definenumber [somecount]<br />
\setnumber [somecount] [42]<br />
<br />
\starttext<br />
<br />
before \inccount<br />
<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \inccount \eTD \bTD \inccount \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
<br />
after \inccount<br />
<br />
\stoptext<br />
</context><br />
<br />
<br />
== Tables ==<br />
<br />
In addition to trial typesetting Context also knows a ''table'' state:<br />
<br />
<context mode="mkiv" source="yes"><br />
\def \tablecheck {\ifintable In table. \else Outside table. \fi}<br />
<br />
\starttext<br />
\tablecheck<br />
\startplacetable[location=here]<br />
\bTABLE<br />
\bTR \bTD \tablecheck \eTD \bTD \tablecheck \eTD \eTR<br />
\eTABLE<br />
\stopplacetable<br />
\tablecheck %% decrement<br />
\stoptext<br />
</context><br />
<br />
== Metapost ==<br />
<br />
As with TeX, Metapost sometimes requires multiple passes,<br />
especially when processing text.<br />
In below snippet, the Metapost tracer reveals that the code is actually<br />
evaluated twice:<br />
<br />
<texcode><br />
\enabletrackers[metapost.showlog]<br />
\starttext<br />
\startMPcode<br />
show "This gets printed twice.";<br />
label (btex Some label text etex, (0,0));<br />
\stopMPcode<br />
\stoptext<br />
</texcode><br />
<br />
NB removing the <code>label</code> statement will result in the second<br />
pass being omitted.<br />
<br />
In [[Metafun]], the default Metapost format in Context, the booleans<br />
<code>mfun_first_run</code> and <code>mfun_trial_run</code> allow<br />
detecting the individual stages:<br />
<br />
<texcode><br />
\enabletrackers[metapost.showlog]<br />
\starttext<br />
\startMPcode<br />
if mfun_trial_run :<br />
show "This gets printed during the trial pass.";<br />
else :<br />
show "This gets printed during the final pass.";<br />
fi;<br />
label (btex Some label text etex, (0,0));<br />
\stopMPcode<br />
\stoptext<br />
</texcode></div>Henrihttps://wiki.contextgarden.net/index.php?title=Vim&diff=24045Vim2018-12-19T22:45:58Z<p>Henri: Typo in markup messed up the page</p>
<hr />
<div>< [[Text Editors]] | [[Related Programs]] ><br />
<br />
http://www.vim.org/<br />
<br />
This page is about editing ConTeXt source in Vim, gVim, MacVim, NeoVim, and other Vim clones.<br />
The page describes the scripts available with Vim v8.0.0055 or later. If you are using Vim 7, see<br />
''Using the scripts with an older Vim'' below.<br />
<br />
== Using ConTeXt in Vim ==<br />
<br />
Nikolai Weibull was the first one who wrote <tt>context.vim</tt> files and submitted them to the official Vim repository.<br />
They are part of the official Vim 7, and were expanded and improved in Vim 8.<br />
<br />
<b>If you feel that something is missing, please contribute!</b><br />
<br />
Information about providing feedback is in the header of the scripts.<br />
<br />
=== Asciicast ===<br />
<br />
[[File:context-in-vim.png]]<br />
<br />
This asciicast[https://asciinema.org/a/91111] gives you a taste of ConTeXt editing in Vim.<br />
<br />
=== Typesetting ===<br />
<br />
The recommended way to typeset a ConTeXt document is to use the <tt>:ConTeXt</tt> command. Just type:<br />
:ConTeXt<br />
to compile the document in the current buffer.<br />
Typesetting happens in the background if you are using Vim 8.0.0047 or later,<br />
so you may continue working on your document. If there are errors, the quickfix window opens automatically<br />
to show the errors (one per line). The cursor stays in the main document, so your typing workflow is not<br />
disrupted. You may use standard quickfix commands to jump between errors: <tt>:cfirst</tt>, <tt>:cprev</tt>,<br />
<tt>:cnext</tt>, etc… (see <tt>:help quickfix</tt>). See below for useful mappings for these commands.<br />
<br />
If your document is typeset without errors, <tt>Success!</tt> is printed at the bottom of the screen.<br />
<br />
The <tt>:ConTeXt</tt> command accepts an optional path, in case you want to typeset a document different<br />
from the current one (useful for big projects).<br />
<br />
You may check the status of your ConTeXt jobs with <tt>:ConTeXtJobStatus</tt>, and you may stop all<br />
running jobs with <tt>:ConTeXtStopJobs</tt> (these commands are available only in Vim 8.0.0047 or later).<br />
<br />
An alternative way to typeset a document is to use <tt>:make</tt>. Set the current working<br />
directory to the directory of the current buffer, then execute <tt>:make</tt>:<br />
:lcd /path/to/my/project<br />
:make<br />
If a <tt>Makefile</tt> exists in the working directory, it is used (see below for a sample Makefile).<br />
You may <tt>let g:context_ignore_makefile=1</tt> to ignore an existing Makefile.<br />
If no Makefile is found, <tt>mtxrun</tt> will be invoked directly.<br />
Note that <tt>:make</tt> always performs synchronous typesetting. Also, if there are<br />
errors, the quickfix list is populated, but you have to open it manually with <tt>:copen</tt>.<br />
<br />
It is recommended that you map the above commands. For example, you may add<br />
nnoremap <silent> <leader>tt :<c-u>update<cr>:ConTeXt<cr><br />
to your <tt>vimrc</tt>, or (better)<br />
nnoremap <buffer> <silent> <leader>tt :<c-u>update<cr>:ConTeXt<cr><br />
to <tt>~/.vim/after/ftplugin/context.vim</tt>, after which pressing <tt>\tt</tt> (where <tt>\</tt> is your leader key)<br />
will save and compile the file.<br />
<br />
You may customize the path to the <tt>mtxrun</tt> executable by setting <tt>g:context_mtxrun</tt>.<br />
For example, if you want to use your ConTeXt Beta installation at <tt>~/Applications/ConTeXt-Beta</tt>,<br />
and you are using macOS, you may set the variable as follows:<br />
let g:context_mtxrun = 'PATH=$HOME/Applications/ConTeXt-Beta/tex/texmf-osx-64/bin:$PATH mtxrun'<br />
<br />
You may enable synctex by setting <tt>g:context_synctex</tt> to <tt>1</tt> (the default is <tt>0</tt>):<br />
let g:context_synctex = 1<br />
<br />
You may pass <tt>mtxrun</tt> additional options by putting them in <tt>g:context_extra_options</tt>.<br />
For example:<br />
let g:context_extra_options = '--arrange --autopdf'<br />
The <tt>--autogenerate</tt>, <tt>--nonstopmode</tt> and <tt>--synctex</tt> options are always included in the<br />
command.<br />
<br />
Finally, for each of the above variables, a corresponding buffer-local variable with the same name<br />
may be defined, whose value takes precedence over the global value.<br />
<br />
=== Editing features ===<br />
<br />
You may use the following commands to quickly jump to different parts of your document:<br />
<br />
* <tt>[[</tt>: jump to the previous start of subject, section, chapter, part, component, or product;<br />
* <tt>]]</tt>: jump to the next start of subject, section, chapter, part, component, or product;<br />
* <tt>[]</tt>: jump to the previous end of section, chapter, etc…;<br />
* <tt>][</tt>: jump to the next end of section, chapter, etc…;<br />
* <tt>[{</tt>: jump to the previous <tt>\start…</tt> or <tt>\setup…</tt> command;<br />
* <tt>]}</tt>: jump to the next <tt>\stop…</tt> or <tt>\setup…</tt> command;<br />
<br />
Each of the above accepts an optional count. For example, you may type <tt>3[{</tt> to jump<br />
three <tt>\start…</tt> commands before.<br />
<br />
You may use the following ConTeXt-specific text objects, to be used in Visual or Operator-pending mode<br />
(see <tt>:help text-objects</tt>):<br />
<br />
* <tt>i$</tt>: inside <tt>$…$</tt> (dollars excluded);<br />
* <tt>a$</tt>: around <tt>$…$</tt> (dollars included);<br />
* <tt>tp</tt>: a ConTeXt paragraph.<br />
<br />
So, for example, you may copy (“yank” in Vim's jargon) a paragraph by typing <tt>ytp</tt> (“yank a TeX<br />
paragraph“), delete it with <tt>dtp</tt>, select it with <tt>vtp</tt>, reflow it with <tt>gqtp</tt>, etc…<br />
Similarly, you may yank a formula with <tt>vi$</tt> (or <tt>va$</tt>), and delete it, select it, etc…, in a<br />
similar fashion.<br />
<br />
If you have enabled the <tt>matchit</tt> plugin included in Vim (see <tt>:help matchit</tt>), you may also<br />
type <tt>%</tt> to jump between matching <tt>\start…</tt> and <tt>\stop…</tt> commands, or between<br />
matching parentheses.<br />
<br />
You may jump to a different file by positioning the cursor over the file name and typing <tt>gf</tt> (<tt>:help gf</tt>).<br />
For example, if you have the following in your document:<br />
\component my_component<br />
putting the cursor over <tt>my_component</tt> and pressing <tt>gf</tt> will open <tt>my_component.tex</tt>.<br />
<br />
Similarly, you may use <tt>[<c-i></tt> (this is square bracket followed by ctrl-i)<br />
to jump to the definition of the word under the cursor (even if it is in a different<br />
file), or <tt>[i</tt> to display the (first line of the) definition under the status line. For these and similar commands,<br />
see <tt>:help include-search</tt>.<br />
<br />
Vim searches for files in the locations specified by the <tt>path</tt> option. You may<br />
need to adjust the value of <tt>path</tt> for the above to work (see <tt>:help 'path'</tt>).<br />
<br />
=== Integration with MetaPost ===<br />
<br />
Vim offers excellent support for editing METAFONT and MetaPost documents (<tt>mf</tt> and <tt>mp</tt> filetypes).<br />
Most of the features of such filetypes work also inside ConTeXt's MetaPost environments,<br />
such as <tt>\startMPpage… \stopMPpage</tt>.<br />
<br />
In particular, Vim automatically highlights and indents MetaPost and MetaFun code inside a ConTeXt document.<br />
Besides, when you are inside a MetaPost environment, you may press CTRL-X followed by CTRL-O<br />
to complete a MetaPost/MetaFun keyword (see below for a list of several autocompletion plugins to streamline this).<br />
This works out of the box: no configuration is required. Watch the asciicast above for a demo.<br />
<br />
=== Integration with other languages ===<br />
<br />
Lua syntax highlighting is used inside <tt>\directlua{}</tt> and <tt>\ctxlua{}</tt> commands,<br />
and inside <tt>\startluacode… \stopluacode</tt>. XML highlighting is used inside <tt>\startXML… \stopXML</tt>.<br />
<br />
You may embed other filetypes. Just define <tt>g:context_include</tt> (or <tt>b:context_include</tt> for<br />
buffer-specific settings). For example, if you want to highlight C++ code inside, say, <tt>\startCPP… \stopCPP</tt>,<br />
define:<br />
let g:context_include = { 'cpp' : 'CPP' }<br />
The key is the name of the filetype and the corresponding value is name of the command.<br />
<br />
=== Using the scripts with an older Vim ===<br />
<br />
If you are using an older Vim, you may copy the following scripts from Vim's distribution <br />
(https://github.com/vim/vim) into corresponding<br />
folders in your <tt>.vim</tt> folder (so, for example <tt>runtime/ftplugin/context.vim</tt> must be copied into<br />
<tt>~/.vim/ftplugin/context.vim</tt>):<br />
<br />
runtime/autoload/context.vim<br />
runtime/autoload/contextcomplete.vim<br />
runtime/compiler/context.vim<br />
runtime/ftplugin/{context,mf,mp}.vim<br />
runtime/indent/{context,mf,mp}.vim<br />
runtime/syntax/{context,mf,mp}.vim<br />
<br />
If you get the following error when you open a ConTeXt or MetaPost document:<br />
<br />
E410: Invalid :syntax subcommand: iskeyword<br />
<br />
edit the syntax files and remove the <tt>syn iskeyword</tt> or <tt>syntax iskeyword</tt> line.<br />
Instead, put a corresponding command in <tt>~/.vim/after/ftplugin/context.vim</tt>:<br />
<br />
setlocal iskeyword=@,48-57,a-z,A-Z,192-255<br />
<br />
and in <tt>~/.vim/after/ftplugin/mp.vim</tt> for MetaPost:<br />
<br />
setlocal iskeyword=@,_<br />
<br />
Everything should work, at least with Vim 7.4.<br />
<br />
=== TODO ===<br />
<br />
* Extract data from texweb and create syntax highlighting definitions for ConTeXt.<br />
* Some essential math support.<br />
* Proper URL highlighting ('%' doesn't start a comment, ...) [request by VnPenguin].<br />
* Perhaps borrow something from https://github.com/lervag/vimtex or http://vim-latex.sourceforge.net/?<br />
<br />
== Filetype detection ==<br />
<br />
TeX (Plain TeX), LaTex and ConTeXt all use the <tt>.tex</tt> extension for files, which makes it difficult to detect the filetype based on the extension. From Vim 7 onwards, Vim does some intelligent checking to see it the file is <tt>plaintex</tt> or <tt>latex</tt> or <tt>context</tt>.<br />
<br />
If the first line of a <tt>*.tex</tt> file has the form <br />
%&<format><br />
then this determines the file type: <tt>plaintex</tt> (for Plain TeX), <tt>context</tt> (for<br />
ConTeXt), or <tt>tex</tt> (for LaTeX). Otherwise, the file is searched for keywords to<br />
choose <tt>context</tt> or <tt>tex</tt>. If no keywords are found, it defaults to <tt>plaintex</tt>.<br />
You can change the default by defining the variable <tt>g:tex_flavor</tt> to the format<br />
(not the file type) you use most. Use one of these: <br />
let g:tex_flavor = "plain"<br />
let g:tex_flavor = "context"<br />
let g:tex_flavor = "latex"<br />
Currently no other formats are recognized.<br />
<br />
* If you use ConTeXt most of the time, but occasionally use LaTeX or Plain TeX, you can add the following to your <tt>vimrc</tt><br />
let g:tex_flavor = "context"<br />
* If you only use ConTeXt, you can add the following lines to <tt>filetype.vim</tt>:<br />
" ConTeXt<br />
augroup filetypedetect<br />
au! BufRead,BufNewFile *.tex setfiletype context<br />
augroup END<br />
so the next time you open a <tt>*.tex</tt> file, Vim will always recognize it as a ConTeXt document.<br />
<br />
== Spell checking ==<br />
<br />
Vim 7 or later has a built-in spell checker. To enable it or disable it, use:<br />
:set spell<br />
or<br />
:set nospell<br />
respectively.<br />
To set the language to be used for spell checking, set the <tt>spelllang</tt> option accordingly. For example:<br />
:set spelllang=en_us<br />
Use lowercase letters (<tt>en_us</tt>, not <tt>en_US</tt>). When you set <tt>spelllang</tt>, Vim offers to<br />
download the language data into your <tt>.vim</tt> folder, if such language is not available.<br />
You can put the above settings in your <tt>vimrc</tt> if you like.<br />
<br />
== Powerful key mappings ==<br />
<br />
In the following, <tt><leader></tt> denotes your “leader” (<tt>:help mapleader</tt>), that is,<br />
the prefix for user-defined mappings.<br />
By default, the leader is the backslash character, but that may be changed by the user.<br />
For example, to use a comma as a leader, put this in your <tt>vimrc</tt>:<br />
map <leader> ,<br />
Rather than overriding the default leader, you may define an alternative key. The <tt><space></tt> is a good<br />
choice, because by default it has the same function as the <tt><right></tt> key, and it is comfortable to type:<br />
map <space> <leader> " Use <space> as an alternative leader (backslash can still be used)<br />
<br />
=== Clean up auxiliary files ===<br />
<br />
The following function can be used to clean up temporary files:<br />
fun! ConTeXtClean()<br />
let l:currdir = expand("%:p:h")<br />
let l:tmpdirs = ['out'] " Temporary directories<br />
let l:suffixes = ['aux', 'bbl', 'blg', 'fls', 'log', 'tuc'] " Suffixes of temporary files<br />
for ff in glob(l:currdir . '/*.{' . join(l:suffixes, ',') . '}', 1, 1)<br />
call delete(ff)<br />
endfor<br />
for dd in l:tmpdirs<br />
let l:subdir = l:currdir . '/' . dd<br />
if isdirectory(l:subdir)<br />
for ff in glob(l:subdir . '/*.{' . join(l:suffixes, ',') . '}', 1, 1)<br />
call delete(ff)<br />
endfor<br />
endif<br />
call delete(l:subdir) " Delete directory (only if empty)<br />
endfor<br />
echomsg "Aux files removed"<br />
endf<br />
Customize <tt>l:tmpdirs</tt> and <tt>l:suffixes</tt> to suit your needs.<br />
In Windows systems, you may have to replace each slash with a backslash, too.<br />
<br />
The following mapping allows you to remove auxiliary files by pressing <tt>\tc</tt>:<br />
nnoremap <silent><buffer> <leader>tc :<c-u>call ConTeXtClean()<cr><br />
<br />
=== Snippets ===<br />
<br />
Vim allows you to define abbreviations for frequently used pieces of text (see <tt>:help abbreviations</tt>).<br />
Here are a few examples:<br />
<pre><br />
fun! Eatchar(pat) " See :help abbreviations<br />
let c = nr2char(getchar(0))<br />
return (c =~ a:pat) ? '' : c<br />
endfun<br />
<br />
iab <buffer> ch- \startchapter[title={<c-o>ma}]<cr><c-o>mb<cr>\stopchapter<esc>`a`b<c-o>a<c-r>=Eatchar('\s')<cr><br />
iab <buffer> s- \startsection[title={<c-o>ma}]<cr><c-o>mb<cr>\stopsection<esc>`a`b<c-o>a<c-r>=Eatchar('\s')<cr><br />
iab <buffer> ss- \startsubsection[title={<c-o>ma}]<cr><c-o>mb<cr>\stopsubsection<esc>`a`b<c-o>a<c-r>=Eatchar('\s')<cr><br />
iab <buffer> sss- \startsubsubsection[title={<c-o>ma}]<cr><c-o>mb<cr>\stopsubsubsection<esc>`a`b<c-o>a<c-r>=Eatchar('\s')<cr><br />
iab <buffer> slide- \startslide[title={<c-o>ma}]<cr><c-o>mb<cr>\stopslide<esc>`a`b<c-o>a<c-r>=Eatchar('\s')<cr><br />
iab <buffer> fig- \startplacefigure<cr><tab>\externalfigure[<c-o>ma]%<cr>[]<c-o>mb<cr><c-d>\stopplacefigure<esc>`a`b<c-o>a<c-r>=Eatchar('\s')<cr><br />
iab <buffer> item- \startitemize<cr><cr>\stopitemize<up><tab>\item<br />
iab <buffer> enum- \startitemize[n]<cr><cr>\stopitemize<up><tab>\item<br />
iab <buffer> i- \item<br />
</pre><br />
<br />
Type the abbreviation followed by Space to expand the snippet, then continue typing normally.<br />
<br />
Inside the definition of an abbreviation, marks may be set (see <tt>:h m</tt>), which allow you to jump between the different<br />
parts of a snippet with TAB (CTRL-i) and CTRL-O (in Normal mode) after the abbreviation is expanded (see <tt>:h jump-motions</tt>).<br />
For example, after typing <tt>ch- </tt>, the cursor will be at the title's position. If you press <tt><esc><tab></tt> (or<br />
<tt><c-o><tab></tt> if you want to stay in Insert mode after the jump), you will jump between <tt>\startchapter</tt><br />
and <tt>\stopchapter</tt>.<br />
<br />
=== Buffer-local Insert-mode macros to speed up editing ===<br />
<br />
(By [[User:David antos|D.A.]] 19:52, 8 Jul 2005 (CEST))<br />
<br />
* I have remapped <leader> to comma (one hardly ever use commas just before a letter)<br />
* two types of mappings: stand-alone and changing the previous word<br />
* usage of mappings that change the previous word: type the name of the macro and ,ta (for tag, use your leader character instead of the comma); it created \start-\stop block of the macro<br />
* put the code into <code>.vim/after/plugin/context.vim</code><br />
<pre><br />
let maplocalleader = mapleader<br />
<br />
" Make start-stop block out of the previous word<br />
imap <buffer> <LocalLeader>ta \start<Cr>\stop<Cr><Esc>4bhdiw$pj$pO<br />
imap <buffer> <LocalLeader>tb \begin<Cr>\end<Cr><Esc>4bhdiw$pj$pO<br />
<br />
" Itemize<br />
imap <buffer> <LocalLeader>it \startitemize<Cr>\stopitemize<Esc>O\item<Space><br />
imap <buffer> <LocalLeader>en \startitemize[n]<Cr>\stopitemize<Esc>O\item<Space><br />
imap <buffer> <LocalLeader>i<Return> \item<Space><br />
<br />
" Font switching and emphasize<br />
imap <buffer> <LocalLeader>em {\em }<Left><br />
imap <buffer> <LocalLeader>sc {\sc }<Left><br />
<br />
" Define... and setup...<br />
imap <buffer> <LocalLeader>de \define<br />
imap <buffer> <LocalLeader>se \setup<br />
<br />
" Typing and type<br />
imap <buffer> <LocalLeader>ty \type{}<Left><br />
imap <buffer> <LocalLeader>typ typing<LocalLeader>ta<br />
<br />
" Quote and quotation<br />
imap <buffer> <LocalLeader>" \quotation{}<Left><br />
imap <buffer> <LocalLeader>' \quote{}<Left><br />
</pre><br />
<br />
=== Key mappings borrowed from SciTE ===<br />
<br />
If you use the stand-alone distribution for Windows/Linux.<br />
You can reset the key mapping to speed ConTeXt compiling.<br />
<br />
Just add the following code to your <tt>_vimrc</tt> (or <tt>.vimrc</tt> file under Linux) file:<br />
<pre><br />
"run setup and complie, then open the result pdf file<br />
map <F5> <Esc><Esc>:sil ! "D:\context\tex\setuptex.bat && texmfstart texexec.pl --autopdf --pdf '%'"<CR><CR><br />
<br />
"view the corresponding pdf file<br />
map <F6> <Esc><Esc>:sil ! D:\"Program Files"\Adobe\Acrobat\Acrobat.exe %:p:r.pdf<CR><CR><br />
<br />
"run setup and make purge<br />
map <F7> <Esc><Esc>:sil ! "D:\context\tex\setuptex.bat && texmfstart texutil.pl --purge"<CR><CR><br />
<br />
"run setup and make list of the current file<br />
map <F8> <Esc><Esc>:sil ! "D:\context\tex\setuptex.bat && texmfstart texexec.pl --autopdf --pdf --list --result=%:p:r_list %"<CR><CR><br />
</pre><br />
<br />
=== Quickfix mappings ===<br />
<br />
It is useful to define mappings for quickfix commands, to be able to navigate among ConTeXt errors.<br />
For example:<br />
nnoremap <silent> ]q :<c-u><c-r>=v:count1<cr>cnext<cr>zz<br />
nnoremap <silent> [q :<c-u><c-r>=v:count1<cr>cprevious<cr>zz<br />
nnoremap <silent> ]Q :<c-u>clast<cr>zz<br />
nnoremap <silent> [Q :<c-u>cfirst<cr>zz<br />
Or install Tim Pope's <i>unimpaired</i> plugin.<br />
<br />
== Makefiles ==<br />
<br />
For your ConTeXt document, you can prepare a Makefile like this one (Contributed by [[User:Buggs|Buggs]]):<br />
<br />
# An example Makefile to compile a context file, paper.tex<br />
paper.pdf: paper.tex<br />
context paper<br />
<br />
test:<br />
xpdf paper.pdf<br />
<br />
clean:<br />
rm *.aux *.bbl *.blg *.log *.tuc<br />
<br />
If you put these mappings to your <code>vimrc</code> file, you can then compile the document with F9 and preview it with F8:<br />
<br />
" map ":make" to the F9 key<br />
imap <F9> <ESC>:exe "lcd" fnameescape(expand("%:p:h"))<CR>:make<CR><br />
nmap <F9> :exe "lcd" fnameescape(expand("%:p:h"))<CR>:make<CR><br />
<br />
"map ":make test" to the F8 key<br />
imap <F8> <ESC>:exe "lcd" fnameescape(expand("%:p:h"))<CR>:make test<CR><br />
nmap <F8> :exe "lcd" fnameescape(expand("%:p:h"))<CR>:make test<CR><br />
<br />
== Other useful Vim plugins ==<br />
<br />
=== Autocompletion ===<br />
<br />
Vim offers a rich completion mechanism (<tt>:help ins-completion</tt>), but there are several plugins<br />
that improve on it, in particular, to provide automatic completion of keywords:<br />
<br />
* µcomplete[https://github.com/lifepillar/vim-mucomplete]<br />
* Completor[https://github.com/maralla/completor.vim]<br />
* NeoComplete[https://github.com/Shougo/neocomplete.vim]<br />
* Deoplete (for NeoVim)[https://github.com/Shougo/deoplete.nvim]<br />
* YouCompleteMe[https://github.com/Valloric/YouCompleteMe]<br />
* AutoComplPop[https://github.com/vim-scripts/AutoComplPop]<br />
* SuperTab[https://github.com/ervandew/supertab]<br />
<br />
In the asciicast at the top of this page µcomplete was used.<br />
<br />
=== UltiSnips ===<br />
<br />
UltiSnips[https://github.com/SirVer/ultisnips] is a sophisticated snippets manager.<br />
Here are a few examples of useful UltiSnips snippets for ConTeXt:<br />
<br />
snippet "s(tart)?" "start / stop" br<br />
\start${1:something}$2<br />
${3:${VISUAL}}<br />
\stop$1<br />
endsnippet<br />
<br />
snippet enum "Enumerate" b<br />
\startitemize[n]<br />
\item ${0:${VISUAL}}<br />
\stopitemize<br />
endsnippet<br />
<br />
snippet item "Itemize" b<br />
\startitemize<br />
\item<br />
${0:${VISUAL}}<br />
\stopitemize<br />
endsnippet<br />
<br />
snippet it "Individual item" b<br />
\item<br />
${0:${VISUAL}}<br />
endsnippet<br />
<br />
snippet fig "External figure" b<br />
\startplacefigure<br />
\externalfigure[${1:${VISUAL}}][$2]<br />
\stopplacefigure<br />
endsnippet<br />
<br />
Save the above text into <tt>~/.vim/UltiSnips/context.snippets</tt>. <br />
Click on the asciicast linked at the top of this document to see UltiSnips snippets in action.<br />
<br />
=== Outline of a document ===<br />
<br />
Tagbar[https://github.com/majutsushi/tagbar] is a useful plugin to display an outline or a table of contents of a document.<br />
It uses Ctags, which you must install, too. Ctags does not support ConTeXt out of the box, but it is easy to extend.<br />
Create a <tt>.ctags</tt> file in your home directory, then copy and paste the following:<br />
<br />
--langdef=context<br />
--regex-context=/^<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\\startsection<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\<nowiki>[[</nowiki>^<nowiki>]]</nowiki>*title<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*=<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\{<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*(.+)\}/\. \1/s,section/<br />
--regex-context=/^<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\\startsubsection<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\<nowiki>[[</nowiki>^<nowiki>]]</nowiki>*title<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*=<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\{<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*(.+)\}/\.\. \1/s,subsection/<br />
--regex-context=/^<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\\startsubsubsection<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\<nowiki>[[</nowiki>^<nowiki>]]</nowiki>*title<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*=<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\{<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*(.+)\}/\.\.\. \1/s,subsubsection/<br />
--regex-context=/^<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\\startchapter<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\<nowiki>[[</nowiki>^<nowiki>]]</nowiki>*title<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*=<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\{<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*(.+)\}/\1/c,chapter/<br />
--regex-context=/^<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\\startsubject<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\<nowiki>[[</nowiki>^<nowiki>]]</nowiki>*title<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*=<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\{<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*(.+)\}/SUBJ \1/c,subject/<br />
--regex-context=/^<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\\startpart<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\<nowiki>[[</nowiki>^<nowiki>]]</nowiki>*title<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*=<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*\{<nowiki>[[</nowiki>:space:<nowiki>]]</nowiki>*(.+)\}/\1/p,part/<br />
<br />
Put this in your <tt>vimrc</tt>:<br />
let g:tagbar_type_context = {<br />
\ 'ctagstype': 'context',<br />
\ 'kinds': [<br />
\ 'p:parts',<br />
\ 'c:chapters',<br />
\ 's:sections'<br />
\ ],<br />
\ 'sort': 0<br />
\ }<br />
<br />
That's it! See the image at the top of this document for an example.<br />
<br />
=== Using LaTeX-Suite ===<br />
<br />
[http://vim-latex.sourceforge.net/ latex-suite] currently doesn't support ConTeXt, but if you use it, here's what you have to do to compile ConTeXt documents:<br />
<br />
1. After downloading and installing latex-suite, locate the file "texrc" (usually located in <code>~/.vim/ftplugin/latex-suite</code>). Copy this file to <code>~/.vim/ftplugin/tex/texrc</code><br />
<br />
2. Open this copy in your favorite editor (vim comes to mind...)<br />
<br />
3. After line 80 in this file, there is a series of "Compiler rules." Just add this line to the section:<br />
<br />
TexLet g:Tex_CompileRule_cont = 'texexec --pdf --nonstopmode $*'<br />
<br />
This will add compilation for ConTeXT. In order to use it:<br />
<br />
4. When you're in vim normal mode, run this command:<br />
<br />
TGTarget cont [that's "colon TGTarger cont"] <br />
<br />
5. Edit your TeX-files, save the changes; when you want to compile, switch to normal mode and just type <code>\ll</code> (that's '' 'backslash el el' '')<br />
<br />
Voila, compilation should start. You'll have to specify this compiler target every timeI you open a TeX-file in Vim. If you want to make this the default compiler, you should have this line in your texrc:<br />
<br />
TexLet g:Tex_DefaultTargetFormat = 'cont' <br />
<br />
{{Installation navbox}}<br />
<br />
[[Category:Text Editors]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Wishes_for_Latin_Modern&diff=23464Wishes for Latin Modern2017-08-29T22:39:33Z<p>Henri: Fix broken formatting</p>
<hr />
<div>< [[Latin Modern]] | [[Fulfilled or rejected wishes for Latin Modern]] ><br />
<br />
This list contains wishes for future versions of the [[Latin Modern]] font family.<br />
<br />
In de.comp.text.tex, there has been a discussion about the [[Latin Modern]] font family that is developed by '''Bogusław Jackowski''' aka Jacko, B.Jackowski@gust.org.pl, and '''Janusz M. Nowacki''', jnowacki@uck.uni.torun.pl.<br />
<br />
''The content was moved from http://www.tug.org/tex-archive/info/lmodern/lmodern.html to this page with agreement with '''Harald Harders''' ([mailto:h.harders@tu-bs.de h.harders@tu-bs.de]) who kindly maintained that page during the most active years of developent of [[Latin Modern]] and was now looking for a new maintainer. Hopefully this wiki can offer a good-enough shelter for comments and proposals how to make the [[Latin Modern]] font family even better than it already is.''<br />
<br />
"Anyone" can add items on this list, you can also upload figures and/ore use <context>embded \TEX\ code</context> to ilustrate your wish (see [[Help:Editing]]). This list of already fulfilled and rejected wishes is kept here: [[Fulfilled or rejected wishes for Latin Modern]].<br />
<br />
== New items ==<br />
<br />
* Ǝ for XeTeX<br />
* assign "U+2423 OPEN BOX" to "visiblespace"<br />
* move IJ ligature to language-specific features<br />
<br />
== Kerning ==<br />
<br />
* '''Jacko/Janusz (2004-04-16)''': All kerning has been prepared from scratch.<br />
<br />
* [mailto:ralf.stubner@physik.uni-erlangen.de Ralf Stubner], [mailto:h.harders@tu-bs.de Harald Harders] (2004-07-19): Kerning around quotation marks is problematic, see [http://www.tug.org/tex-archive/info/lmodern/lm-kerning-092.pdf lm-kerning-092.pdf] and [http://www.tug.org/tex-archive/info/lmodern/lm-kerning.tex lm-kerning.tex]. Note the large corrections needed for <code>quotedblleft</code> when it is used as German style ''right'' quotation mark. This is caused by the horizontally not centered <code>quotedblleft</code>. There is a simple solution by using <code>quotedblleft.alt</code> etc. which are horizontally centered. We do not see any disadvantage in using these, even not for English texts.<br />
<br />
* [mailto:olli@sopos.org Oliver Heins] (2004-11-26): Kerning between the bold and roman letters ‘t’ and ‘l’ seems to be too big. Especially the bold version is very ugly. Both italic and bold-italic are okay. See [http://www.tug.org/tex-archive/info/lmodern/lmodern-tl.pdf lmodern-tl.pdf] and [http://www.tug.org/tex-archive/info/lmodern/lmodern-tl.tex lmodern-tl.tex].<br />
<br />
== Text fractions ==<br />
<br />
* [mailto:h.harders@tu-bs.de Harald Harders]: Superior and inferior digits, comma, and period for arbitrary textfractions similar to textcomp's <code>\textonehalf</code> should be added. The solidus exists called ‘fraction’ (Thanks to [mailto:moho01ab@student.cbs.dk Morten Høgholm]).<br />
**'''Jacko/Janusz (2004-04-16)''': ''Not touched yet.''<br />
<br />
* [mailto:moho01ab@student.cbs.dk Morten Høgholm] (2004-04-16): It would be great if the ‘solidus’ could have a fake lenght so that you wouldn't need to kern all the time; just like it is in the Adobe fonts.<br />
<br />
== Single glyphs/ligatures ==<br />
<br />
* [h.harders@tu-bs.de Harald Harders]: I like the μ that is a mixture from the u and the p, as it is in cm-super (with serifs), more than the Latin Modern μ which does not have serifs at all. But this topic seems to be controversial. [stefan-ulrich.nntp@zen.co.uk Stefan Ulrich] does not agree. He thinks that most greek fonts don't have a serif at the descender of the <code>\textmu</code>.<br />
**'''Jacko/Janusz (2004-04-16)''': ''Not touched yet.''<br />
<br />
* [mailto:kirpal@rz.uni-leipzig.de Gerrit Kirpal]: The degree symbol <code>\textdegree</code> should have the same size as the degree sign in degree celsius <code>\textcelsius</code>. It should be slightly larger than used in <code>\textcelsius</code> but much smaller than in <code>\textdegree</code>. A ratio of 2/5 between the diameter and the height of capitals would be nice (in <code>\textcelsius</code>, it is 1/3 while it is 1/2 in <code>\textdegree</code>).<br />
**[mailto:h.harders@tu-bs.de Harald Harders]: I fully agree. The <code>\textdegree</code> really is ugly in [[Latin Modern]]. In addition, the outline of the ball in <code>\textdegree</code> is too thin.<br />
**'''Jacko/Janusz (2004-04-16)''': We also agree that the present state of the art is unacceptable. Will be touched as soon as possible.<br />
<br />
* [mailto:kirpal@rz.uni-leipzig.de Gerrit Kirpal]: The circled text symbols are better than in cm-super, but they have too thin outlines.<br />
**'''Jacko/Janusz (2004-04-16)''': ''Not touched yet.''<br />
<br />
* [mailto:h.harders@tu-bs.de Harald Harders]: The <code>\pm</code> is ugly. The original CM version is much nicer. At least, the ‘+’ part of the sign should be symmetrical.<br />
** '''Jacko/Janusz (2004-04-16)''': ''Hardly implementable to full extent. Knuth constructs plusminus by shifting plus so that its bottom touches the baseline and next places a bar (minus) on the baseline. This works for circa half of the LM family. In the rest of fonts the glyph would be too high (most notably in LMBX5, LMBX6, LMSSQBX8 and LMSSQBO8). We decided that the resulting glyph should not be higher than ascender height; if it would, we decreased its height par force.''<br />
<br />
* [mailto:blacktrash@gmx.net Christian Ebert (2004-01-16)]: Some design sizes are not displayed correctly in Acrobat Reader (at least version x86 linux 5.0.5), e.g., the ‘A’ in 10pt is printed below the baseline ([http://www.tug.org/tex-archive/info/lmodern/lm10pt.tex lm10pt.tex], [http://www.tug.org/tex-archive/info/lmodern/lm10pt.png lm10pt.png]); the ‘i’ in 11pt is printed above the baseline ([http://www.tug.org/tex-archive/info/lmodern/lm11pt.tex lm11pt.tex], [http://www.tug.org/tex-archive/info/lmodern/lm11pt.png lm11pt.png]).<br />
** [mailto:andreas.lobinger@netsurf.de Andreas Lobinger (2004-01-16)]: This may occur due to wrong hinting.<br />
** '''Jacko/Janusz (2004-04-16)''': ''Not touched yet.''<br />
<br />
* [mailto:ralf.stubner@physik.uni-erlangen.de Ralf Stubner (2004-03-12)]: The umlauts in ä, ö, and ü as well as in Ä, Ö, and Ü should be at the same height as in the EC fonts. This height is a compromise between the default placement in the CM fonts and the placement in the CM fonts with (n)german. Example: [http://www.tug.org/tex-archive/info/lmodern/umlauts.pdf umlauts.pdf], [http://www.tug.org/tex-archive/info/lmodern/umlauts.tex umlauts.tex].<br />
**'''Jacko/Janusz (2004-04-16)''': ''Not touched yet. We wanted to consult the matter with Hermann Zapf (there was a little chance) but we haven't managed to arrange the meeting.''<br />
<br />
* Arni Magnusson (2004-04-16): Thanks for creating the lmodern fonts. Icelandic LaTeX users have been using cm-super to render the Þ (thorn) and Ð (eth) characters in type 1, and although cm-super does a fine job, lmodern seems like a cleaner solution to the Þ and Ð problem.<br>I understand you are still working on the fonts, and I'd like to offer my comments on issues specific to Icelandic characters. If you open the three attached PDF documents (not provided here, Jacko does have the examples), you will notice mainly three differences:<br />
#the upper case Þ should carry its belly higher in lmodern,<br />
#the comma over the ú should have a lower angle, and<br />
#the neck of the ð should be bent further down.<br />
:Knuth's bitmaps and cm-super look similar to books printed in Iceland.<br />
:The kerning is also an issue, in light of Knuth's original goal, described in the TUGboat 21(2): ''"the rendering [should] be the same in ten years [...] on everybody's machine it [should] come out the same, not only now but in the future."'' An ambitious goal, but at any rate, the smaller the kerning differences, the better.<br />
<br />
* Morten Høgholm (2004-06-11): At this years BachoTeX I talked to Boguslaw about adding some more ligatures to Latin Modern, as we in Danish really need fj. At http://www.eur.nl/fw/staff/lokhorst/metafont.html a lot of ligatures are shown, although not all of them are particular nice. He promised to look at it. (When you have the standard fi and ij ligatures, you would also think there should be an fij, right? In polish they have a common flower named ‘fijolet’ making Boguslaw even more eager to add it... The Dutch use it in common words as ‘fijn’ as well.) I guess this calls for a special fontencoding for Danish users. Harald Harders: There are some good ligatures. But for example the fff ligature is useless in German. You should be careful in adding new ligatures.<br />
<br />
* Martín Darío Safe (2004-07-05): When using the lm package version 0.92, almost all occurrences of ‘ij’ and ‘IJ’ in your document will output ij and IJ Dutch digraphs. This seems inadequate for all European languages but Dutch. Also, this behaviour can prevent you from copying and pasting, searching, and indexing words containing ‘ij’ on PDF files for non-Dutch texts. More description about that topic at http://www.mdsafe.com.ar/ijdigraphissue.htm.<br />
<br />
* [mailto:eckhard.neber@web.de Eckhard Neber] (2004-07-09): I asked on dctt why the glyphs of scedilla and tcedilla are different from the others and was pointed to http://www.tug.org/tug2003/preprints/Jackowski/jackowski.pdf It says that this is a feature following the rules of the Romanian language, but referring to http://www.evertype.com/alphabets/turkish.pdf it is handled differently in Turkish. Is there a possibility to have both variants?<br />
<br />
* [mailto:ralf.stubner@physik.uni-erlangen.de Ralf Stubner] (2004-07-17): Similar to [sS]cedilla, [tT]cedilla should really be a [tT] with cedilla below. Both, [sS]cedilla and [tT]cedilla should be used in T1/Cork encoding, as the turkish [sS]cedilla would not be available otherwise, and using [sS]cedilla and [tT]commacent at the same time would be inconsistent. [sS]commaacent and [tT]commacent are still available via the QX encoding. Also, the EC fonts, which can be seen as reference implementation of the T1/Cork encoding, use [sS]cedilla and [tT]cedilla.<br />
<br />
* Ramón Casares (2005-06-01): The Latin Modern fonts are really needed in Spanish, so I am following its development with much interest. One thing I have notice, comparing last year printings – from August to be more precise – with printings done with the new version, is the horizontal placement of the acute accent. In the last year printing, the acute accent was a little bit to the right, but acceptable. The current version is too much to the left. And, in the case of the í, is imposible for me not to notice it every time I read it. So I would suggest to use the Computer Modern model to place the acute accent, which is just where it should.<br />
<br />
* Stephan Hennig (2005-03-08): In thread "Italicalized old-style figures" from 2004-09-08 on comp.text.tex there has been some agreement to the opinion CM's old-style figures do look ugly. Is it possible for LM to provide nicer old-style figures?<br>As I'm completely ignorant about font design I don't really know what makes CM's old-style figures look so boring. And I don't know if a complete redesign would be necessary to get nicer ones. Maybe just slanting the current old-style digits slightly could make the single digits look more individual and less obstrusive?<br />
**[mailto:h.harders@tu-bs.de Harald Harders]: I think only a complete new design would help. For instance, the 1 and 3 normally really look different in lining and old-style figures which they don't for LM. Slanting is wrong in my opinion.<br />
<br />
* Thomas Zell (2010-06-22): The hinting of the capital "W" seems to be broken for example in lmr10. Acrobat Reader paints the diagonal lines way too thick. I edited the font in FontForge and removed all of the horizontal hints which seemed oddly placed to me (leaving only one at the bottom) and the "W" looked fine. Could this be due to a bug in Metatype1?<br />
<br />
== General things ==<br />
<br />
* [mailto:h.harders@tu-bs.de Harald Harders]: Virtual fonts or font encodings for usage of old-style digits (similar to the eco package). Small Caps should either use old-style digits or get extra lining digits with a height that fits to the ‘minuscles’.<br />
** '''Jacko/Janusz (2004-04-16)''': ''Not touched yet. Help is welcome. But remember that each new encoding means a new set of TFM files.''<br />
<br />
* [mailto:h.harders@tu-bs.de Harald Harders]: I would like proportional digits in addition to the table digits with same width which are provided up to now.<br />
** '''Jacko/Janusz (2004-04-16)''': ''Not touched yet.''<br />
<br />
* [mailto:h.harders@tu-bs.de Harald Harders]: I think [[Latin Modern]] should have a full set of Small Caps fonts including bold series, italic/slanted shape as well as the sans serif and type writer families.<br>For the roman (serif) family of Latin Modern, the bold extended small caps font shapes are missing (‘LMCaps##-Bold’ and ‘LMCaps##-BoldItalic’).<br />
**'''Jacko/Janusz (2004-04-16)''': Nice idea, although it would require a lot of work (see the remarks concerning the preparing of the bold typewriter variant). But it should be considered seriously, as Knuthian small caps are hardly usable in the context of [[OpenType]] fonts (see below). So, perhaps adding alternative small caps makes sense.<br />
<br />
* [mailto:h.harders@tu-bs.de Harald Harders]: The slanted small caps font shape ‘LMCaps##-Italic’ is present, but it is not prepared to be used by LaTeX. With the package [ftp://ftp.dante.de/tex-archive/macros/latex/contrib/slantsc.zip slantsc.sty], slanted small capitals can be used, if the corresponding <code>fd</code> files contain entries for font shapes <code>scsl</code> and <code>scit</code> for slanted and italic font shapes, respectively. <code>t1lmr.fd</code> already includes the font lmr/m/scsl (Normal weighted slanted small capitals). For the italic shape, a substitution could be defined:<br />
<texcode><br />
\DeclareFontShape{T1}{lmr}{m}{scit}{<->ssub * lmr/m/scsl}{}.<br />
</texcode><br />
:The same should be done for new small caps shapes (sans serif, bold, etc.).<br />
:*'''Jacko/Janusz (2004-04-16)'': ''Not touched yet. We'll try to prepare the relevant files in the next release.''<br />
* [h.harders@tu-bs.de Harald Harders]: Cpa files for supporting the package pdfcprot should be added (2003-11-26).<br />
** '''Jacko/Janusz (2004-04-16)'': ''Not touched yet. Help welcome.''<br />
<br />
* [mailto:zedler@ei.tum.de Michael Zedler] (2004-01-15): Build an [[OpenType]] version of [[Latin Modern]]. Then, SC, OSF, special ligatures etc. were included and accessable from DTP programmes.<br />
**'''Jacko/Janusz (2004-04-16)''': We work on it, but the task is not trivial. For example, metric files for cmr10 and cmcsc10 differ significantly. Compare the two excerpts from AFM files:<br />
:cmr10.afm:<br />
C 65 ; WX 750 ; N A ; B 32 0 717 716 ;<br />
C 66 ; WX 708.333 ; N B ; B 36 0 651 683 ;<br />
C 67 ; WX 722.222 ; N C ; B 56 -22 665 705 ;<br />
:cmcsc10.afm:<br />
C 65 ; WX 813.879 ; N A ; B 48 0 765 716 ;<br />
C 66 ; WX 770.824 ; N B ; B 58 0 698 683 ;<br />
C 67 ; WX 786.102 ; N C ; B 72 -22 713 705 ;<br />
:Small caps are circa 10% wider; therefore, cmcsc10 and cmr10 cannot just be joined into a single [[OpenType]] font with small caps available through the ‘smcp’ feature.<br />
:* Peter Dyballa (2004-11-25): Will Robertson has prepared an OpenType version of the [[Latin Modern]] fonts (for usage with [[XeTeX]]): http://www.mecheng.adelaide.edu.au/~will/tex/<br />
<br />
* Make [[Latin Modern]] fonts usable with Mac computers (2004-01-16).<br />
** '''Jacko/Janusz (2004-04-16)'': Once we have OpenType fonts the problem will be solved, will it not? Needs time, however. (I don't know if this is an official work.)<br />
* [mailto:h.harders@tu-bs.de Harald Harders] (2004-07-09): The lmodern.sty style file should get the same version number and date as the [[Latin Modern]] fonts and a description what it does, e.g.,<br />
<texcode><br />
\ProvidesPackage{lmodern}[2004/04/14 v0.92 Latin Modern fonts]<br />
</texcode><br />
<br />
* [http://iki.fi/juhtolv Juhapekka Tolvanen] (2004-08-24): It would be nice, if [[Latin Modern]] would include also those fonts of Computer Modern Bright. Right now the only free (in the sense of freedom) version of Computer Modern Bright in Type 1 format is in that awfully big cm-super package and hfbright package.<br />
<br />
[[Category:Fonts]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=System_Macros/Branches_and_Decisions&diff=23427System Macros/Branches and Decisions2017-07-24T21:02:41Z<p>Henri: https://mailman.ntg.nl/pipermail/ntg-context/2017/089239.html</p>
<hr />
<div>< '''Prev:''' [[System Macros/Definitions and Assignments|Definitions & Assignments]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Loops_and_Recursion|Loops and Recursion]] ><br />
<br />
=== Introduction ===<br />
<br />
This page describes the conditional expressions available in ConTeXt.<br />
<br />
See also: {{cmd|doif...}}<br />
<br />
=== \doifnextcharelse ===<br />
<br />
When Pragma ADE started using TeX in the late eighties, their first experiences with programming concerned a simple shell around LaTeX. The commands probably used most at Pragma ADE are the itemizing ones. One of those initial shell commands took care of an optional argument, that enabled the specification of the item symbol to be used. Without understanding anything they were able to locate a LaTeX macro that could be used to inspect the next character.<br />
<br />
It is that macro that the ancester of the next one presented here. It executes one of two actions, dependant of the next character. Disturbing spaces and line endings, which are normally interpreted as spaces too, are skipped.<br />
<br />
<texcode><br />
\doifnextcharelse {char} {then ...} {else ...}<br />
</texcode><br />
<br />
=== \doifundefined, \doifdefined, etc. ===<br />
<br />
The standard way of testing if a macro is defined is comparing its meaning with another undefined one, aptly named <code>\undefined</code>. To guarantee correct working of this set of macros, <code>\undefined</code> may '''never''' be defined by a user!<br />
<br />
<texcode><br />
\doifundefined {string} {...}<br />
\doifdefined {string} {...}<br />
\doifundefinedelse {string} {then ...} {else ...}<br />
\doifdefinedelse {string} {then ...} {else ...}<br />
\doifalldefinedelse {commalist} {then ...} {else ...}<br />
</texcode><br />
<br />
=== \doif, \doifnot, \doifelse ===<br />
Programming in TeX differs from programming in procedural languages like Modula. This means that one --- well, let me speek for myself --- tries to do the things in the well known way. Therefore the next set of <code>\ifthenelse</code> commands were between the first ones we needed. A few years later, the opposite became true: when programming in Modula, I sometimes miss handy things like grouping, runtime redefinition, expansion etc. While Modula taught me to structure, TeX taught me to think recursive.<br />
<br />
<texcode><br />
\doif {string1} {string2} {...}<br />
\doifnot {string1} {string2} {...}<br />
\doifelse {string1} {string2} {then ...}{else ...}<br />
</texcode><br />
<br />
These macros test string equality of the (expanded) first two arguments.<br />
<br />
=== \doifempty, \doifnotempty, \doifemptyelse ===<br />
We complete our set of conditionals with:<br />
<br />
<texcode><br />
\doifempty {string} {...}<br />
\doifnotempty {string} {...}<br />
\doifemptyelse {string} {then ...} {else ...}<br />
</texcode><br />
<br />
This time, the string is not expanded. Remember to expand it yourself where needed.<br />
<br />
=== \doifinset, \doifnotinset, \doifnotinsetelse ===<br />
We can check if a string is present in a comma separated set of strings. Depending on the result, some action is taken.<br />
<br />
<texcode><br />
\doifinset {string} {string,...} {...}<br />
\doifnotinset {string} {string,...} {...}<br />
\doifinsetelse {string} {string,...} {then ...} {else ...}<br />
</texcode><br />
<br />
The second argument is the comma separated set of strings. If the first string expands 'empty', it is considered to be '''not''' in the set. The comma separated set is not expanded.<br />
<br />
=== \doifcommon, \doifnotcommon, \doifcommonelse ===<br />
Probably the most time consuming tests are those that test for overlap in sets of strings.<br />
<br />
<texcode><br />
\doifcommon {string,...} {string,...} {...}<br />
\doifnotcommon {string,...} {string,...} {...}<br />
\doifcommonelse {string,...} {string,...} {then ...} {else ...}<br />
</texcode><br />
<br />
=== \doifsamestringelse,\doifsamestring,\doifnotsamestring ===<br />
<br />
The next comparison macro converts the arguments into<br />
expanded strings. This command can be used to compare for<br />
instance <code>\jobname</code> with a name stored in a macro.<br />
<br />
=== \doifinstringelse,\doifincsnameelse ===<br />
<br />
We can check for the presence of a substring in a given sequence of characters.<br />
<br />
<texcode><br />
\doifinstringelse {substring} {string} {then ...} {else ...}<br />
</texcode><br />
<br />
The next alternative proved to be upto twice as fast on tasks like checking reserved words in pretty verbatim typesetting. This is mainly due to the fact that passing (expanded) strings is much slower that passing a macro.<br />
<br />
<texcode><br />
\doifincsnameelse {substring} {\string} {then ...} {else ...}<br />
</texcode><br />
<br />
Where <code>\doifinstringelse</code> does as much expansion as possible, the latter alternative does minimal (one level) expansion.<br />
<br />
=== \doifnumberelse ===<br />
The next macro executes a command depending of the outcome of a test on numerals.It checks only the first character of string.<br />
<br />
<texcode><br />
\doifnumberelse {string} {then ...} {else ...}<br />
</texcode><br />
<br />
The macro accepts <code>123</code>, <code>abc</code>, <code>{}</code>, <code>\anumber</code> and <code>\the\count...</code>.<br />
<br />
The definition of this macro is extremly ugly, or extremely beautiful, depending on how you feel about TeX macro expansion. It is the first of only a few that will actually appear in this series of articles, I promise.<br />
<br />
<texcode><br />
\long\def\doifnumberelse#1%<br />
{\ifcase0\ifcase1#1\or\or\or\or\or\or\or\or\or\else1\fi\space<br />
\expandafter\secondoftwoarguments<br />
\else<br />
\expandafter\firstoftwoarguments<br />
\fi}<br />
</texcode><br />
<br />
=== \doifassignmentelse ===<br />
<br />
A lot of ConTeXt commands take optional arguments, for<br />
instance:<br />
<br />
<texcode><br />
\dothisorthat[alfa,beta]<br />
\dothisorthat[first=foo,second=bar]<br />
\dothisorthat[alfa,beta][first=foo,second=bar]<br />
</texcode><br />
<br />
Although a combined solution is possible, we prefer a<br />
seperation. The next command takes care of propper<br />
handling of such multi-faced commands.<br />
<br />
<texcode><br />
\doifassignmentelse {...} {then ...} {else ...}<br />
</texcode><br />
<br />
=== \doiftext, \doiftextelse ===<br />
<br />
See https://www.mail-archive.com/ntg-context@ntg.nl/msg73506.html for details.<br />
<br />
\define\CustomHeader{%<br />
\cap{\ss{\| %<br />
\doiftextelse{\getmarking[chapter]}%<br />
{\getmarking[chapter]}%<br />
{Contents}%<br />
}}<br />
}<br />
<br />
\setupheadertexts[\CustomHeader{}][][][\CustomHeader{}]<br />
<br />
<br />
< '''Prev:''' [[System Macros/Definitions and Assignments|Definitions & Assignments]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Loops and Recursion|Loops & Recursion]] ><br />
<br />
[[Category:System Macros]]<br />
[[Category:ConTeXt programming]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/setuptype&diff=23421Command/setuptype2017-07-11T22:04:37Z<p>Henri: </p>
<hr />
<div>{{Reference<br />
|name=setuptype<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setuptype<span class="first" >[...,...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...,...]</td><br />
<td>[[Command/value:IDENTIFIER|IDENTIFIER]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:option|option]]</td><br />
<td>[[Command/value:mp|mp]] [[Command/value:lua|lua]] [[Command/value:xml|xml]] [[Command/value:parsed-xml|parsed-xml]] [[Command/value:nested|nested]] [[Command/value:tex|tex]] [[Command/value:context|context]] [[Command/value:none|none]] [[Command/value:NAME|NAME]]</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:command|command]]</td><br />
<td>[[Command/value:CSNAME|CSNAME]]</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:left|left]]</td><br />
<td>[[Command/value:COMMAND|COMMAND]]</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:right|right]]</td><br />
<td>[[Command/value:COMMAND|COMMAND]]</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:tab|tab]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:NUMBER|NUMBER]]</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:compact|compact]]</td><br />
<td>[[Command/value:absolute|absolute]] [[Command/value:last|last]] [[Command/value:all|all]]</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:escape|escape]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:TEXT|TEXT]] [[Command/value:TEXT|PROCESSOR->TEXT]]</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Command/value:STYLE COMMAND|STYLE COMMAND]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:color|color]]</td><br />
<td>[[Command/value:COLOR|COLOR]] </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:lines|lines]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:normal|normal]] [[Command/value:hyphenated|hyphenated]]</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[[Command/keyword:space|space]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] [[Command/value:normal|normal]] [[Command/value:fixed|fixed]] [[Command/value:stretch|stretch]] </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
Text can be displayed in verbatim (typed) form. For inline typed text the command {{cmd|type}} is available.<br />
<br />
== Example ==<br />
<!-- Please fill in an example if you can --><br />
<context source="yes"><br />
For reasons of readability you can also use other characters than<br />
\type!{! and \type!}! as outer parenthesis. You can choose your own<br />
non||active (a non||special) character, for example: \type+like this+<br />
or \type-like that-.<br />
</context><br />
<br />
== See also ==<br />
* {{cmd|type}}<br />
* {{cmd|starttyping}}<br />
* [[Verbatim]]<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Verbatim Text|setuptype]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=SlideWithSteps&diff=23420SlideWithSteps2017-07-03T22:44:59Z<p>Henri: \eject doesn't work in MKIV</p>
<hr />
<div>< [[Main Page]] | [[Presentations]] ><br />
<br />
These macros were written by Otared Kavian:<br />
[[http://archive.contextgarden.net/message/20041103.083500.43ac3121.html]]<br />
<br />
Please see the [[http://mhd.selfip.info/tex/ Raw steps module]] on the author's side (this page hasn't been updated yet).<br />
<br />
==Commands==<br />
<br />
<table><br />
<tr><th>Command</th><th>Description</th></tr><br />
<tr><td>\SlideWithSteps{''n''}{... slide content ...}</td><td>''n'' - the overall number of steps on this slide</td></tr><br />
<tr><td>\Step{''n''}{... content ...}</td><td>content appears on step ''n''</td></tr><br />
<tr><td>\StepBefore{''n''}{... content ...}</td><td>content disappears on step ''n''</td></tr><br />
<tr><td>\OnlyStep{''n''}{... content ...}</td><td>content appears on step ''n'' only</td></tr><br />
<tr><td>\StepBetween[''n'',''m'']{... content ...}</td><td>content appears between steps ''n'' and ''m'' only</td></tr><br />
<tr><th>Other Commands</th><th>Description</th></tr><br />
<tr><td>\the\StepCounter</td><td>step number</td></tr><br />
<tr><td>\SteppingSlidetrue</td><td>for screen presentations</td></tr><br />
<tr><td>\SteppingSlidefalse</td><td>for printed material (full content on one page)</td></tr><br />
</table><br />
<br />
See the following example as a reference.<br />
<br />
==Code==<br />
<br />
<texcode><br />
<br />
%%%%%%%%%%%% begin test-step-ok.tex<br />
%%K test-step-ok.tex<br />
<br />
%%K Here we use the plain \TeX\ command \phantom{} in order to have<br />
%%K some material appear step by step.<br />
%%K The structure is quite simple, but since I am not very<br />
%%K familiar with ConTeXt, I cannot write elegant code as does<br />
%%K Hans Hagen...<br />
%%K<br />
%%K An advantage is that the code can be used also in<br />
%%K plain TeX, in LaTeX and other macro-packages.<br />
%%K<br />
<br />
\newif\ifSteppingSlide<br />
\SteppingSlidetrue %%K this is when you want a step by step presentation<br />
%\SteppingSlidefalse %%K this is when you want to print the slides<br />
%<br />
\newcount\StepsCounter<br />
\StepsCounter=0<br />
%<br />
\newcount\NumberOfSteps<br />
\NumberOfSteps=10<br />
%<br />
\newcount\BeforeStepNumber<br />
\BeforeStepNumber=0<br />
%<br />
%%K StepBetween[number1,number2]{material} will make "material"<br />
%%K appear between steps "number1" and "number2"<br />
\def\StepBetween[#1,#2]#3{%<br />
\ifSteppingSlide<br />
\ifnum#1>\StepsCounter \phantom{#3}<br />
\else<br />
\ifnum#2<\StepsCounter \phantom{#3}<br />
\else \relax #3<br />
\fi<br />
\fi<br />
\else {#3}<br />
\fi}<br />
%<br />
%%K Step{number1}{material} will make "material"<br />
%%K appear beginning with step "number1" until "NumberOfSteps"<br />
\def\Step#1#2{\StepBetween[#1,\NumberOfSteps]{#2}}<br />
%<br />
%%K OnlyStep{number1}{material} will make "material"<br />
%%K appear only on step "number1"<br />
\def\OnlyStep#1#2{\StepBetween[#1,#1]{#2}}<br />
%<br />
%%K StepBefore{number1}{material} will make "material"<br />
%%K appear only on all steps before "number1"<br />
\def\StepBefore#1#2{<br />
\global\BeforeStepNumber=#1<br />
\StepBetween[0,\BeforeStepNumber]{#2}}<br />
%<br />
\long\def\SlideWithSteps#1#2{<br />
\ifSteppingSlide<br />
\global\StepsCounter=0<br />
\global\NumberOfSteps=#1<br />
\MakeSteps{#2}<br />
\else #2<br />
\fi}<br />
%<br />
\long\def\MakeSteps#1{\loop #1<br />
\ifnum\StepsCounter<\NumberOfSteps<br />
\global\advance\StepsCounter by 1\vfill\page<br />
\repeat<br />
\vfill\page}<br />
%<br />
<br />
<br />
%%K This is the end of the macros<br />
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br />
<br />
% \endinput<br />
<br />
%%K Here is a sample of how you can use these macros<br />
%%K<br />
\starttext<br />
<br />
\startitemize<br />
<br />
\SlideWithSteps{8}{<br />
\item Consider the following nonlinear equation:<br />
$$\Step{8}{{\partial u \over \partial t}} \Step{1}{-\Delta u + |u|^{p-1}u} \Step{2}{=} \Step{3}{f} \Step{4}{+{\rm div}(g)} \Step{5}{+|\nabla u|{\Step{6}{^2}}}$$<br />
\StepBetween[3,5]{\item This line appears only between steps 3 and 5}<br />
\Step{8}{\item The equation may be parabolic.}<br />
\StepBefore{4}{\item This line appears only before step 4.}<br />
\OnlyStep{4}{\item This line appears only at step 4.}<br />
\vfill (Here you see step number \the\StepsCounter)<br />
} % end of \SlideWithSteps<br />
<br />
\stopitemize<br />
\page<br />
<br />
\stoptext<br />
<br />
</texcode></div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/getmarking&diff=23419Command/getmarking2017-07-02T02:39:06Z<p>Henri: current does exist, but it's unclear what it is doing.</p>
<hr />
<div>{{Reference<br />
|name=getmarking<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\getmarking<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>first last top bottom previous next both all </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
Marks are somewhat special in the sense that they can be loners or part of a chain (chapter-section-...) with special reset requirements.<br />
<br />
As TeX’s natural model has some limitations, in mkIV we do things a bit different (but rather well defined). When a set of marks on a page is identified, the following keywords can be used:<br />
<br />
previous : last before sync<br />
next : first after sync<br />
<br />
top : first in sync<br />
bottom : last in sync<br />
<br />
first : first not top in sync<br />
last : last not bottom in sync<br />
<br />
both : equivalent to first + last<br />
all : equivalent to previous + first + last<br />
<br />
current : ?<br />
<br />
When the chain is to be ignored, one can append ":nocheck" to the keyword. There’s also a 'current' method.<br />
<br />
<br />
== Example ==<br />
Example of usage for each column in columnsets:<br />
<texcode><br />
<br />
\startsetups S<br />
[p=(\getmarking[M][1][previous])<br />
f=(\getmarking[M][1][first])<br />
l=(\getmarking[M][1][last])]\quad<br />
[p=(\getmarking[M][2][previous])<br />
f=(\getmarking[M][2][first])<br />
l=(\getmarking[M][2][last])]\quad<br />
[p=(\getmarking[M][3][previous])<br />
f=(\getmarking[M][3][first])<br />
l=(\getmarking[M][3][last])]<br />
\global\mofcolumns\plusone<br />
\stopsetups<br />
<br />
\setupheadertexts[\setups{S}]<br />
<br />
\definecolumnset[C][n=3]<br />
<br />
\definemarking[M]<br />
<br />
\startbuffer<br />
\section{Knuth}<br />
[k1]\marking[M]{k1}<br />
[k2]\marking[M]{k2}<br />
\input knuth<br />
\section{Zapf}<br />
[z]\marking[M]{z}<br />
\input zapf<br />
\stopbuffer<br />
<br />
\starttext<br />
<br />
\startcolumnset[C]<br />
\dorecurse{10}{\getbuffer}<br />
\stopcolumnset<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
<br />
== Example ==<br />
<br />
<texcode><br />
\definemarking[M]<br />
<br />
\startsetups S<br />
default=(\getmarking[M])~<br />
first=(\getmarking[M][first])~<br />
last=(\getmarking[M][last])~<br />
previous=(\getmarking[M][previous])~<br />
both=(\getmarking[M][both])~<br />
all=(\getmarking[M][all])~<br />
current=(\getmarking[M][current])<br />
\stopsetups<br />
<br />
\setupheadertexts[text]<br />
[\setups{S}][]<br />
[\setups{S}][]<br />
<br />
\setuppagenumbering[location=footer]<br />
<br />
\starttext<br />
<br />
\startbuffer<br />
\section{Knuth}<br />
[k1]\marking[M]{k1}[k2]\marking[M]{k2}<br />
\input knuth<br />
\section{Zapf}<br />
[z]\marking[M]{z}<br />
\input zapf<br />
\stopbuffer<br />
<br />
\dorecurse{10}{\getbuffer}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== See also ==<br />
{{cmd|definemarking}}<br />
{{cmd|marking}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Marking|getmarking]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/getmarking&diff=23418Command/getmarking2017-07-02T02:35:58Z<p>Henri: Description for both and all; current doesn't exist (anymore?)</p>
<hr />
<div>{{Reference<br />
|name=getmarking<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\getmarking<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>first last top bottom previous next both all </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
<br />
Marks are somewhat special in the sense that they can be loners or part of a chain (chapter-section-...) with special reset requirements.<br />
<br />
As TeX’s natural model has some limitations, in mkIV we do things a bit different (but rather well defined). When a set of marks on a page is identified, the following keywords can be used:<br />
<br />
previous : last before sync<br />
next : first after sync<br />
<br />
top : first in sync<br />
bottom : last in sync<br />
<br />
first : first not top in sync<br />
last : last not bottom in sync<br />
<br />
both : equivalent to first + last<br />
all : equivalent to previous + first + last<br />
<br />
When the chain is to be ignored, one can append ":nocheck" to the keyword. There’s also a 'current' method.<br />
<br />
<br />
== Example ==<br />
Example of usage for each column in columnsets:<br />
<texcode><br />
<br />
\startsetups S<br />
[p=(\getmarking[M][1][previous])<br />
f=(\getmarking[M][1][first])<br />
l=(\getmarking[M][1][last])]\quad<br />
[p=(\getmarking[M][2][previous])<br />
f=(\getmarking[M][2][first])<br />
l=(\getmarking[M][2][last])]\quad<br />
[p=(\getmarking[M][3][previous])<br />
f=(\getmarking[M][3][first])<br />
l=(\getmarking[M][3][last])]<br />
\global\mofcolumns\plusone<br />
\stopsetups<br />
<br />
\setupheadertexts[\setups{S}]<br />
<br />
\definecolumnset[C][n=3]<br />
<br />
\definemarking[M]<br />
<br />
\startbuffer<br />
\section{Knuth}<br />
[k1]\marking[M]{k1}<br />
[k2]\marking[M]{k2}<br />
\input knuth<br />
\section{Zapf}<br />
[z]\marking[M]{z}<br />
\input zapf<br />
\stopbuffer<br />
<br />
\starttext<br />
<br />
\startcolumnset[C]<br />
\dorecurse{10}{\getbuffer}<br />
\stopcolumnset<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
<br />
== Example ==<br />
<br />
<texcode><br />
\definemarking[M]<br />
<br />
\startsetups S<br />
default=(\getmarking[M])~<br />
first=(\getmarking[M][first])~<br />
last=(\getmarking[M][last])~<br />
previous=(\getmarking[M][previous])~<br />
both=(\getmarking[M][both])~<br />
all=(\getmarking[M][all])~<br />
current=(\getmarking[M][current])<br />
\stopsetups<br />
<br />
\setupheadertexts[text]<br />
[\setups{S}][]<br />
[\setups{S}][]<br />
<br />
\setuppagenumbering[location=footer]<br />
<br />
\starttext<br />
<br />
\startbuffer<br />
\section{Knuth}<br />
[k1]\marking[M]{k1}[k2]\marking[M]{k2}<br />
\input knuth<br />
\section{Zapf}<br />
[z]\marking[M]{z}<br />
\input zapf<br />
\stopbuffer<br />
<br />
\dorecurse{10}{\getbuffer}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== See also ==<br />
{{cmd|definemarking}}<br />
{{cmd|marking}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Marking|getmarking]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/definedfont&diff=23392Command/definedfont2017-04-04T04:54:32Z<p>Henri: Created \definedfont</p>
<hr />
<div>{{Reference<br />
|name=definedfont<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definefont<span class="first" >[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>identifier</td><br />
</tr><br />
</table><br />
<br />
<br />
== Description == <br />
This macro loads the font given in the identifier and immediately switches to that font. The identifier works in the same way as the second argument to {{cmd|definefontsynonym}}: you can use either a font synonym or a real font.<br />
<br />
== Example ==<br />
<texcode><br />
\definedfont[file:texgyrepagella-regular.otf at 72pt] Hello World!<br />
</texcode><br />
<br />
== See also ==<br />
* {{cmd|definefont}}<br />
* {{cmd|definefontsynonym}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Fonts|definedfont]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/setupenumerations&diff=23130Command/setupenumerations2016-08-16T08:21:13Z<p>Henri: Typo (which prevented typesetting)</p>
<hr />
<div>{{Reference<br />
|name=setupenumerations<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupenumerations<span class="first" style="color:red;">[...,...,...]</span><span class="second" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...,...,...]</td><br />
<td>name of an enumeration (defined with {{cmd|defineenumeration}})</td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...,...=...,...]</td><br />
<td>see {{cmd|setupdescriptions}} </td><br />
</tr><br />
</table><br />
<br />
<br />
== Description ==<br />
Set up the appearance and behaviour of an enumeration. Enumeration environments are actually special description environments, so the keys are described at {{cmd|setupdescriptions}}.<br />
<br />
== Example ==<br />
<context source=yes text="This gives:"><br />
\defineenumeration[Potato]<br />
<br />
\Potato <br />
One potato<br />
<br />
\setupenumerations[Potato][location=left]<br />
% In mkiv one would use `alternative=left`.<br />
<br />
\Potato <br />
Two potato<br />
<br />
</context><br />
<br />
The before and after keys control the spacing around enumerations. It you want to achieve something similar to the itemize-option "packed" then use: (MKIV example)<br />
<br />
<context source=yes text="This gives:"><br />
\defineenumeration[Packed]<br />
<br />
\setupenumerations<br />
[Packed]<br />
[text=,<br />
headstyle=normal,<br />
alternative=left,<br />
distance=0pt,<br />
width=13pt,<br />
stopper=\high{o},<br />
before={\blank[small]},<br />
after={\blank[small]},<br />
inbetween=]<br />
<br />
<br />
\Packed<br />
First issue<br />
<br />
\Packed<br />
Second issue<br />
<br />
</context><br />
== See also ==<br />
* {{cmd|defineenumeration}} for creating new kinds of numbered objects.<br />
* {{cmd|setupenumerations}} for setting up looks and behaviour.<br />
* {{cmd|enumeration}} for single-paragraph numbered objects.<br />
* {{cmd|startenumeration}} for multiple-paragraph numbered objects.<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Numbered objects|setupenumerations]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/localheadsetup&diff=23125Command/localheadsetup2016-08-09T08:59:23Z<p>Henri: Redirected page to Command/headsetupspacing</p>
<hr />
<div>#REDIRECT [[Command/headsetupspacing]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/definefontalternative&diff=23124Command/definefontalternative2016-08-09T08:34:46Z<p>Henri: </p>
<hr />
<div>{{Reference<br />
|name=definefontalternative<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definefontalternative<span class="first" >[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>IDENTIFIER</td><br />
</tr><br />
</table><br />
<br />
== Description ==<br />
<br />
Predefined font alternatives in {{src|font-pre.mkiv}} are<br />
<pre><br />
tf bf it sl bs bi sc<br />
</pre><br />
Using {{cmd|definefontalternative}} one can define extra ones.<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Fonts|definefontalternative]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/definefontalternative&diff=23119Command/definefontalternative2016-08-09T08:27:11Z<p>Henri: moved definefontalternative to Command/definefontalternative</p>
<hr />
<div>{{Reference<br />
|name=definefontalternative<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definefontalternative<span class="first" >[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>IDENTIFIER</td><br />
</tr><br />
</table><br />
<br />
== Description ==<br />
<br />
Predefined font alternatives in {{src|font-pre.mkiv}} are<br />
<pre><br />
tf bf it sl bs bi sc<br />
</pre><br />
Using {{cmd||definefontalternative}} one can define extra ones.<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Fonts|definefontalternative]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/headsetupspacing&diff=23116Command/headsetupspacing2016-08-09T08:24:03Z<p>Henri: </p>
<hr />
<div>{{Reference<br />
|name=headsetupspacing<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\headsetupspacing</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
This macro is to be used inside custom defined section commands to propagate the options set in {{cmd|setuphead}}. The options which are set locally by {{cmd|headsetupspacing}} are<br />
<span class="cmd">[[Command/keyword:align|align]]</span>,<br />
<span class="cmd">[[Command/keyword:tolerance|tolerance]]</span>, and<br />
<span class="cmd">[[Command/keyword:strut|strut]]</span>.<br />
The values for these are inherited from {{cmd|setuphead}}.<br />
<br />
The definition of {{cmd|headsetupspacing}} is found in {{src|strc-ren.mkiv}}. There one can also find the historic synonym {{cmd|localheadsetup}}. The name {{cmd|localheadsetup}} might vanish in the future; don't use it!<br />
<br />
== Example ==<br />
<br />
In this example we use {{cmd|showstruts}} to emphasize that even though we set <code>strut=no</code> it is not forwarded and struts still appear. If we use {{cmd|headsetupspacing}}, however, the struts are gone.<br />
<br />
<context mode=mkiv source="yes"><br />
\showstruts<br />
<br />
\setuphead<br />
[section]<br />
[<br />
strut=no,<br />
command=\printsection,<br />
]<br />
<br />
\starttext<br />
<br />
\define[2]\printsection{#1 #2}<br />
\section{First}<br />
<br />
\define[2]\printsection{\headsetupspacing #1 #2}<br />
\section{Second}<br />
<br />
\stoptext<br />
</context><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Sections|headsetupspacing]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/headsetupspacing&diff=23115Command/headsetupspacing2016-08-09T08:21:51Z<p>Henri: Created page with "{{Reference |name=headsetupspacing |attributes= }} == Syntax == <table cellspacing="4" cellpadding="2" class="cmd"> <tr> <td colspan="2" class="cmd">\he..."</p>
<hr />
<div>{{Reference<br />
|name=headsetupspacing<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\headsetupspacing</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
This macro is to be used inside custom defined section commands to propagate the options set in {{cmd||setuphead}}. The options which are set locally by {{cmd||headsetupspacing}} are<br />
<span class="cmd">[[Command/keyword:align|align]]</span>,<br />
<span class="cmd">[[Command/keyword:tolerance|tolerance]]</span>, and<br />
<span class="cmd">[[Command/keyword:strut|strut]]</span>.<br />
The values for these are inherited from {{cmd||setuphead}}.<br />
<br />
The definition of {{cmd||headsetupspacing}} is found in {{src|strc-ren.mkiv}}. There one can also find the historic synonym {{cmd||localheadsetup}}. The name {{cmd||localheadsetup}} might vanish in the future; don't use it!<br />
<br />
== Example ==<br />
<br />
In this example we use {{cmd||showstruts}} to emphasize that even though we set <code>strut=no</code> it is not forwarded and struts still appear. If we use {{cmd||headsetupspacing}}, however, the struts are gone.<br />
<br />
<context mode=mkiv source="yes"><br />
\showstruts<br />
<br />
\setuphead<br />
[section]<br />
[<br />
strut=no,<br />
command=\printsection,<br />
]<br />
<br />
\starttext<br />
<br />
\define[2]\printsection{#1 #2}<br />
\section{First}<br />
<br />
\define[2]\printsection{\headsetupspacing #1 #2}<br />
\section{Second}<br />
<br />
\stoptext<br />
</context><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Sections|headsetupspacing]]</div>Henrihttps://wiki.contextgarden.net/index.php?title=Command/definefontalternative&diff=23113Command/definefontalternative2016-08-08T07:55:24Z<p>Henri: Created page with "{{Reference |name=definefontalternative |attributes= }} == Syntax == <table cellspacing="4" cellpadding="2" class="cmd"> <tr> <td colspan="2" class="cmd..."</p>
<hr />
<div>{{Reference<br />
|name=definefontalternative<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\definefontalternative<span class="first" >[...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>IDENTIFIER</td><br />
</tr><br />
</table><br />
<br />
== Description ==<br />
<br />
Predefined font alternatives in {{src|font-pre.mkiv}} are<br />
<pre><br />
tf bf it sl bs bi sc<br />
</pre><br />
Using {{cmd||definefontalternative}} one can define extra ones.<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Fonts|definefontalternative]]</div>Henri