https://wiki.contextgarden.net/api.php?action=feedcontributions&user=Owenh&feedformat=atomWiki - User contributions [en]2024-03-29T13:19:48ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Registers&diff=25457Registers2020-01-05T07:23:17Z<p>Owenh: /* Individual Entries */ Spelling fix</p>
<hr />
<div>< [[Structurals]] | [[References]] > (It's also in the manual at "Registers")<br />
<br />
=Basics=<br />
<br />
Use indexes as follows:<br />
<br />
* To add the word "word", use: {{cmd|index}}<tt>{word}</tt><br />
* To sort a word (such as "ConTeXt" under "C"), use: {{cmd|index}}<tt>[CONTEXT]{\ConTeXt}</tt><br />
* To use multi-levels (up to three), use a plus symbol: {{cmd|index}}<tt>{beans+baked}</tt><br />
* To cross-reference items, use {{cmd|seeindex}}: {{cmd|seeindex}}<tt>[CONTEXT]{\ConTeXt}{\TeX}</tt><br />
* To include the index without a title, use: {{cmd|placeindex}}<br />
* To include the index with a title, use: {{cmd|completeindex}}<br />
<br />
Note that the {{cmd|completeindex}} command might not work correctly. In such situations you can use: {{cmd|subject}}<tt>{Index}</tt> {{cmd|placeindex}}<br />
<br />
==Example==<br />
<br />
<texcode><br />
My \index{dog}dog is a \index{dog+bullterrier}bullterrier named \seeindex{Dolly}{Underware}Dolly.<br />
He doesn't like \index{cat}cats.<br />
There are a lot of \index{cat+stray}stray cats, but only a few of them are \index{cat+Siamese}Siamese.<br />
<br />
\placeindex<br />
</texcode><br />
<context><br />
\tfx<br />
My \index{dog}dog is a \index{dog+bullterrier}bullterrier named \seeindex{Dolly}{Underware}Dolly.<br />
He doesn't like \index{cat}cats. There are a lot of \index{cat+stray}stray cats, but only a few of them are \index{cat+Siamese}Siamese.<br />
<br />
\placeindex<br />
</context><br />
<br />
=Styling the Index=<br />
<br />
Registers consist of three text elements that can be styled<br />
independently:<br />
the sections headings, the entry text, and a page number (reference).<br />
For formatting purposes each has its own key so it can be referred to<br />
consistently:<br />
<br />
* <tt>style</tt> refers to the style of ''headings''; ordinarily these are the letters of the alphabet.<br />
* <tt>textstyle</tt> refers to the typeset content of an entry;<br />
* <tt>pagestyle</tt> refers to the typeset page number of an entry;<br />
* page numbers are references so their appearance depends on the [[Interaction|interaction]] settings as well.<br />
<br />
== MkIV ==<br />
<br />
=== General Setup ===<br />
The appearance of a register can be configured with {{cmd|setupregister}}.<br />
An example setup for the register ''entity'' could look like:<br />
<br />
<texcode><br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
style=sansbold, %% headings<br />
textstyle=slanted, %% entries<br />
pagestyle=bolditalic, %% page refs<br />
n=1, %% columns<br />
]<br />
</texcode><br />
<br />
This typesets sections in bold face sans serif, entries with slant, and<br />
page references in italic.<br />
Also, the register will use a single column.<br />
<br />
In MkIV {{cmd|setupregister}} is consistent with the common interface<br />
to [[Style_Alternatives|text style]].<br />
Thus for every <tt>style</tt> there is a corresponding <tt>color</tt><br />
option (''color'', ''textcolor'', and ''pagecolor''):<br />
<br />
<texcode><br />
\setupregister [entity] [<br />
color=red,<br />
textcolor=green,<br />
pagecolor=blue,<br />
]<br />
</texcode><br />
<br />
Naturally, self-defined alternatives are valid as well:<br />
<br />
<texcode><br />
\definefontfeature [textfigures] [onum=yes]<br />
<br />
\definealternativestyle [reg:bigbold] [\bfc] []<br />
\definealternativestyle [reg:tinybold] [\bfxx] []<br />
\definealternativestyle [reg:bignum] [\tfc\addff{textfigures}] []<br />
<br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
style=reg:bigbold,<br />
textstyle=reg:tinybold,<br />
pagestyle=reg:bignum,<br />
]<br />
</texcode><br />
<br />
Use with care!<br />
<br />
=== Processors ===<br />
<br />
The [[Registers#Individiual_Entries|traditional approach]] to<br />
fine-tuning entries has not (yet?) been implemented in MkIV<br />
[http://www.ntg.nl/pipermail/ntg-context/2013/070961.html].<br />
Instead, there is a new mechanism called ''processors'' available that<br />
has a similar effect<br />
[http://www.ntg.nl/pipermail/ntg-context/2010/049493.html].<br />
<br />
Processors are created via {{cmd|defineprocessor}}:<br />
<br />
<texcode><br />
\defineprocessor [relevant] [style=italic]<br />
</texcode><br />
<br />
To apply it to a register entry, we employ the <tt>-&gt;</tt> operator:<br />
<texcode><br />
Text \entity{foo}text.<br />
Text \entity{relevant->bar}text.<br />
Text \entity{baz}text.<br />
</texcode><br />
<br />
This will render ''bar''’s entry in the register ''entity'' in italic<br />
font, while the other two entries remain unchanged.<br />
<br />
<context mode=mkiv source=no><br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
style=sansbold,<br />
textstyle=normal,<br />
pagestyle=bolditalic,<br />
n=1,<br />
]<br />
<br />
\defineprocessor [relevant] [style=italic]<br />
<br />
\starttext<br />
\placeentity \page<br />
<br />
Text before.<br />
Text \entity{foo}text.<br />
Text \entity{relevant->bar}text.<br />
Text \entity{baz}text.<br />
Text after.<br />
\stoptext<br />
</context><br />
<br />
A processor is not local to a specific register (as it was in MkII).<br />
Once defined it can be applied to different registers, yielding the<br />
same effect:<br />
<br />
<texcode><br />
\defineregister [first]<br />
\defineregister [second]<br />
\defineregister [third]<br />
\defineprocessor [relevant] [style=italic,color=blue]<br />
\starttext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br />
\placefirst \placesecond \placethird \page<br />
Text before.<br />
Text \first {foo} \first {relevant->bar 1} \first {baz}text.<br />
Text \second{foo} \second{relevant->bar 2} \second{baz}text.<br />
Text \third {foo} \third {relevant->bar 3} \third {baz}text.<br />
Text after.<br />
\stoptext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br />
</texcode><br />
<br />
The same processor can be applied to to both entries and page numbers.<br />
(Another difference from MkII.)<br />
For page numbers, apply the <tt>-&gt;</tt> operator on the optional<br />
first argument:<br />
<br />
<texcode><br />
\entity[relevant->]{foo}<br />
</texcode><br />
<br />
Note that <code>\entity[weird]{foo}</code> is not enough.<br />
Without the <tt>-&gt;</tt>, the first argument is interpreted as sort<br />
key.<br />
However, if in addition to the page number processor you wish to supply<br />
a custom sort key, then the sort key must follow the processor:<br />
<br />
<texcode><br />
\entity[relevant->baz]{foo}<br />
</texcode><br />
<br />
In this example, the page number will be displayed using the processor<br />
''relevant'' and the entity ''foo'' will be treated like the string<br />
''baz'' for sorting purposes.<br />
Of course, page number and text formatting can be combined:<br />
<br />
<texcode><br />
\entity[relevant->]{relevant->foo}<br />
</texcode><br />
<br />
Processors work well with multi-level indices:<br />
<br />
<texcode><br />
\entity {relevant->foo}<br />
\entity {relevant->foo+bar}<br />
\entity {relevant->foo+bar+baz}<br />
</texcode><br />
<br />
''Applying multiple processors to a single entry has no effect.''<br />
Context will ignore any other processor after the first.<br />
(This is probably a feature, as there is no need to repeat the<br />
processor with every entry.)<br />
However, different entries in the page reference list can be formatted<br />
differently:<br />
<br />
<context mode=mkiv source=yes><br />
\setupcolor[rgb]<br />
\defineregister [stuff] [style=sansbold,pagestyle=italic,n=1]<br />
\defineprocessor [relevant] [style=bold,color=red]<br />
\defineprocessor [irrelevant] [color=darkgray]<br />
<br />
\starttext<br />
\placestuff<br />
<br />
\page Text \stuff {relevant->foo} text.<br />
\page Text \stuff {foo} text.<br />
\page Text \stuff [relevant->] {foo} text.<br />
\page Text \stuff {irrelevant->foo} text. %% no effect!<br />
\page Text \stuff [irrelevant->] {foo} text.<br />
\stoptext<br />
</context><br />
<br />
=== Examples ===<br />
==== Simple Setup ====<br />
<br />
<context mode=mkiv source=yes><br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
style=sansbold,<br />
textstyle=slanted,<br />
pagestyle=bolditalic,<br />
n=1,<br />
]<br />
<br />
\starttext<br />
<br />
\placeentity \page<br />
<br />
Text before.<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{baz} text.\page<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{xyzzy} text.\page<br />
Text after.<br />
<br />
\stoptext<br />
</context><br />
<br />
==== Colorful Setup ====<br />
<br />
<context mode=mkiv source=yes><br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
color=red,<br />
textcolor=green,<br />
pagecolor=blue,<br />
n=1,<br />
]<br />
<br />
\starttext<br />
<br />
\placeentity \page<br />
<br />
Text before.<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{baz} text.\page<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{xyzzy} text.\page<br />
Text after.<br />
<br />
\stoptext<br />
</context><br />
<br />
==== Setup with Alternatives ====<br />
<br />
<context mode=mkiv source=yes><br />
\definefontfeature [textfigures] [onum=yes]<br />
<br />
\definealternativestyle [reg:bigbold] [\bfc] []<br />
\definealternativestyle [reg:tinybold] [\bfxx] []<br />
\definealternativestyle [reg:bignum] [\tfc\addff{textfigures}] []<br />
<br />
\defineregister [entity]<br />
\setupregister [entity] [<br />
style=reg:bigbold,<br />
textstyle=reg:tinybold,<br />
pagestyle=reg:bignum,<br />
]<br />
<br />
\starttext<br />
<br />
\placeentity \page<br />
<br />
Text before.<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{baz} text.\page<br />
Text \entity{foo} \entity{bar} text.\page<br />
Text \entity{foo} \entity{xyzzy} text.\page<br />
Text after.<br />
<br />
\stoptext<br />
</context><br />
<br />
==== Complex Setup ====<br />
<br />
<texcode><br />
\definefontfeature [textfigures] [onum=yes]<br />
<br />
\definealternativestyle [reg:heada] [\WORD\ssa\bold]<br />
\definealternativestyle [reg:headb] [\word\tfb\sc]<br />
\definealternativestyle [reg:pageno] [\addff{textfigures}\italic]<br />
<br />
\defineregister [entity] [style=reg:heada,pagestyle=normal,n=3]<br />
\defineregister [object] [style=reg:headb,pagestyle=reg:pageno,n=2]<br />
<br />
\defineprocessor [relevant] [style=italic]<br />
\defineprocessor [weird] [style=italic,color=red]<br />
\defineprocessor [striking] [style=bold,color=blue]<br />
<br />
\starttext<br />
<br />
\placeentity \blank[3*big] \placeobject \page<br />
<br />
\dorecurse{3}{<br />
Text before.<br />
\page Text \entity {foo} text.<br />
Text \object {striking->bar} text.<br />
Text \entity {baz+foo} text.<br />
Text \object {foo+bar} text.<br />
\page Text \entity[relevant->] {weird->foo} text.<br />
\page Text \entity {weird->bar} text.<br />
Text \object[weird->] {foo} text.<br />
Text \object {baz} text.<br />
\page Text \entity[weird->foo] {foo} text.<br />
\page Text \entity[weird->] {baz} text.<br />
Text \object {baz} text.<br />
Text \object {bar+baz} text.<br />
Text \entity[weird->] {baz} text.<br />
Text \entity {baz+miranda} text.<br />
Text \entity {baz+xyzzy} text.<br />
Text \object {foo} text.<br />
\page Text \entity {weird->foo} text.<br />
Text \object[striking->] {bar+baz} text.<br />
Text \object {foo} text.<br />
Text \entity[relevant->] {baz+xyzzy} text.<br />
\page Text \entity[weird->foo] {foo} text.<br />
Text \object {bar+xyzzy} text.<br />
Text \object {baz} text.<br />
Text \object {foo} text.<br />
Text \entity[weird->] {baz+xyzzy+meh} text.<br />
\page Text \entity[weird->] {weird->foo} text.<br />
Text \object[striking->] {foo} text.<br />
Text \object {xyzzy} text.<br />
Text \entity {baz+xyzzy} text.<br />
Text after.<br />
}<br />
<br />
\stoptext<br />
</texcode><br />
<br />
<br />
== MkII ==<br />
<br />
=== General Setup ===<br />
The interface for register styling is {{cmd|setupregister}}.<br />
For settings that apply to the register as a whole use the two-argument<br />
version:<br />
<br />
<texcode><br />
\defineregister[thing][stuff]<br />
\setupregister[thing][<br />
style=boldslanted, %% headings<br />
textstyle=bold, %% items<br />
pagestyle=slanted, %% page numbers<br />
]<br />
</texcode><br />
<br />
Here we first initialize a register ''thing''.<br />
Then we assign a different<br />
[[Style_Alternatives|style]]<br />
to each of the three elements:<br />
the option ''style'' refers to index section headings (letters), which<br />
will be typeset in bold slanted;<br />
''textstyle'' means the item (indexed string, here bold);<br />
finally, ''pagestyle'' sets the page number references (slanted).<br />
<br />
=== Individual Entries ===<br />
Better granularity regarding the formatting of individual entries can<br />
be achieved through the ''three-argument'' version of<br />
{{cmd|setupregister}}.<br />
Its second argument is an identifier by means of which a sub-style can<br />
be applied later.<br />
<br />
<texcode><br />
\setupregister[thing][important] [textstyle=bold, pagestyle=boldslanted]<br />
\setupregister[thing][nonsense] [textstyle=\tfxx, pagestyle=\tfd]<br />
</texcode><br />
<br />
This creates the substyles ''important'' and ''nonsense'' for the<br />
register ''thing''.<br />
To apply a sub-style, it has to be specified when an entry is added to<br />
the register.<br />
If we wanted to highlight an entry as important, we would call the<br />
macro {{cmd|thing|link=no}} as follows:<br />
<br />
<texcode><br />
text before \thing{important::entry} text after<br />
</texcode><br />
<br />
Note the double colon (<tt>::</tt>) that serves as delimiter between<br />
style directive (left hand side) and entry text (right).<br />
To highlight the page number instead:<br />
<br />
<texcode><br />
text before \thing[important::]{entry} text after<br />
</texcode><br />
<br />
Note that the '''<tt>::</tt> is non-optional'''!<br />
If the double colon is omitted, ''important'' would instead refer to<br />
the string used for register sorting.<br />
Of course, both elements can be styled at once:<br />
<br />
<texcode><br />
text before \thing[important::]{nonsense::entry} text after<br />
</texcode><br />
<br />
This produces an entry whose text is highlighted according to the<br />
definition of ''nonsense'' with a pagenumber styled as ''important''.<br />
<br />
The syntax for an MkII-style register entry has the schematic:<br />
<br />
<pre><br />
\<registercmd> [<pagestyle>::<sortkey>] {<textstyle>::<category>+<entry>}<br />
</pre><br />
<br />
where only <code><entry></code> is mandatory.<br />
<br />
=== Example ===<br />
<br />
A complete working example demonstrating the highlighting capabilities:<br />
<br />
<texcode><br />
\defineregister[thing][things]<br />
%%% 2-arg<br />
\setupregister[thing][<br />
style=boldslanted,<br />
textstyle=normal,<br />
pagestyle=slanted,<br />
]<br />
<br />
%%% 3-arg<br />
\setupregister[thing][important] [textstyle=bold, pagestyle=boldslanted]<br />
\setupregister[thing][nonsense] [textstyle=\tfxx, pagestyle=\tfd]<br />
<br />
<br />
\starttext<br />
Ordinary entries: \thing{one}\thing{two}<br />
<br />
Just a \thing {important::three}test. %% text -> “important”<br />
Yet another \thing {nonsense::four}test. %% text -> “nonsense”<br />
Again, nothing but a \thing [important::] {five}test. %% page -> “important”<br />
Old story: this is a \thing [important::] {important::five}test. %% both -> “important”<br />
Get it? A \thing [important::] {important::six}test. %% both -> “important”<br />
Plain and simple: \thing [nonsense::] {nonsense::seven}test. %% both -> “nonsense”<br />
<br />
\placething<br />
\stoptext<br />
</texcode><br />
category>+<br />
/context><br />
<br />
==== Colorful Setup ====<br />
<br />
=More Registers=<br />
<br />
<cmd>index</cmd> is only one special case of <cmd>register</cmd>. You can define as much different registers as you like:<br />
<br />
<cmd>defineregister</cmd><tt>[singular name][plural name]</tt>, e.g. <br />
<texcode><br />
\defineregister[mouse][mice]<br />
\setupregister[mouse][style=\ss]<br />
<br />
\mouse{rat}<br />
<br />
\placemouse<br />
</texcode><br />
<br />
(Don't know if the plural form is used anywhere...)<br />
<br />
=Tricks=<br />
<br />
* A register per chapter: {{cmd|placeregister}}<tt>[index][criterium=chapter]</tt><br />
* Uppercase-letter index heads: {{cmd|setupregister}}<tt>[index][n=2,command=\Word,style=normal]</tt><br />
* Place a word in text ''and'' index: <tt>\def\Tindex#1{\index{#1}#1}</tt> -- Please someone enhance this to get space correction, [] sorting etc.!<br />
* {{cmd|writetoregister}} (sometimes needed to avoid macro expansion issues, '''MkII only''')<br />
<br />
<br />
== Collapse Page Numbers ==<br />
<br />
Often index entries like "mouse 2,3,4,5" aren’t desired, instead ConTeXt should shorten it to "mouse 2–5". This is called collapsing.<br />
There are two ways to collapse page numbers:<br />
<br />
# {{cmd|setupregister}}[compress=yes]<br />
<br />
# Enclose several pages in {{cmd|startregister}} … {{cmd|stopregister}}:<br />
<br />
<texcode><br />
\startregister[index][Keycode1]{Keyword}<br />
% lots of text<br />
\stopregister[index][Keycode1]<br />
</texcode><br />
<br />
The first parameter of {{cmd|startregister}} is the name of the index – "index" is the default index, but you might use your self defined registers as well.<br />
<br />
The second parameter is a keyword to distinguish several overlapping range-entries.<br />
<br />
It’s also possible to use the sorting parameter:<br />
<br />
<texcode><br />
\startregister[index][levi][Levi-Strauss]{Lévi|-|Strauss}<br />
% lots of text<br />
\stopregister[index][levi]<br />
</texcode><br />
<br />
This will create a range with the key <tt>levi</tt> which will put the entry "Lévi-Strauss" in the register "index" (the "normal" register) and sort it under "Levi-Strauss."<br />
<br />
== Rename Register Heading ==<br />
<br />
Change the {{cmd|completeregister}} heading using the {{cmd|setupheadtext}} command. For example:<br />
<br />
<context source="yes"><br />
\defineregister[photographer][]<br />
<br />
\setupregister[photographer][<br />
indicator=no,<br />
]<br />
<br />
\setupheadtext[photographer=Credits]<br />
<br />
\starttext <br />
\photographer{Yousuf Karsh}<br />
<br />
\completephotographer<br />
\stoptext <br />
</context><br />
<br />
== Alphabetical Headers == <br />
<br />
The letters of the alphabet can be disabled by {{cmd|setupregister}}<tt>[register][indicator=no]</tt>.<br />
<br />
The vertical spaces between the entry groups for subsequent letters is governed by the parameter <tt>before</tt> in the same command (default: <tt>\blank</tt>, change to <tt>before={}</tt> to get no additional space).<br />
<br />
=Sorting=<br />
<br />
The sorting of the index is influenced by the current [[Language Codes|language]]. You can override that with the {{key|language}} key of {{cmd|setupregister}}.<br />
There are a few additional "languages" for sorting, as defined in {{src|sort-lan.mkiv}}:<br />
* <tt>DIN 5007-1</tt> (German) normal sorting, ß = ss<br />
* <tt>DIN 5007-2</tt> (German) phonebook sorting, ä = ae, ö = oe, ü = ue, ß = ss<br />
* <tt>Duden</tt> (German) ß = s<br />
* <tt>de-AT</tt> (Austrian German) phonebook sorting; umlauts after base vocal (a, ä, o, ö, u, ü) <br />
* <tt>cu</tt> (Church Slavonic)<br />
* <tt>ocs-scn</tt> (Scientific Old Slavonic transcription)<br />
* <tt>ru-iso9</tt> (Russian transcription)<br />
<br />
Additionally, there’s the {{key|method}} key that influences the order of upper-/lowercase and diacritics:<br />
<br />
The details lay in a rather obscure set of methods (see {{src|sort-ini.lua|source}}), for which the following presets are defined:<br />
<br />
* {{key|default}} = {{key|"zc,pc,zm,pm,uc"}} (uppercase like lowercase, diacritics separate)<br />
* {{key|before}} = {{key|"mm,mc,uc"}} (upper before lower, diacritics ignored)<br />
* {{key|after}} = {{key|"pm,mc,uc}} (lower before upper, diacritics ignored)<br />
* {{key|first}} = {{key|"pc,mm,uc"}} (lower before upper, diacritics separate)<br />
* {{key|last}} = {{key|"mc,mm,uc"}} (upper before lower, diacritics separate)<br />
* If you don’t set the sorting method, the preset "first" ist used (and not "default").<br />
* There’s no preset for the combination "uppercase like lowercase, diacritics ignored", try {{key|"zm,pm,zc,zm,uc"}}.<br />
* The sorting is also influenced by the current language or the language setting in {{cmd|setupregister}}.<br />
<br />
e.g.<br />
<texcode><br />
\setupregister[index][<br />
n=1,<br />
language=Duden,<br />
method={zm,pm,zc,zm,uc},<br />
]<br />
</texcode><br />
<br />
=Coupled Registers=<br />
<br />
This is a special feature for documents that are only used on screen: Make a word clickable to jump to the index, the first or last occurrence.<br />
<br />
Enable it with {{cmd|setupregister}}<tt>[index][coupling=yes]</tt>.<br />
Substitute {{cmd|index}} with {{cmd|coupledindex}} and enjoy!<br />
<br />
=Impact on vertical spacing=<br />
<br />
In some situations, placing an {{cmd|index}} (or related command) might affect vertical spacing and the page-breaking mechanism. In those situations it is advisable to wrap the command in a {{cmd|doflushatpar}} as shown below (needs a ConTeXt version dated after 14th Dec 2005):<br />
<br />
<texcode><br />
\starttext<br />
\section{Tufte}<br />
\dorecurse{4}{\input tufte \par}<br />
\section{Knuth}<br />
\doflushatpar{\index{Knuth}}<br />
\input knuth \par<br />
\stoptext<br />
</texcode><br />
<br />
This will stop bad-page breaking between the section title and the following para, for example.<br />
<br />
==Technical note==<br />
<br />
The above command is defined as follows:<br />
<br />
<texcode><br />
\long\def\doflushatpar#1%<br />
% {\dogotopar{\dontleavehmode#1}} % this one can introduce empty lines<br />
{\dogotopar{#1\ifvmode\nobreak\fi}} % while this one can mess up vertical space<br />
</texcode><br />
<br />
Note the two possible definitions, and the pitfalls with each one. If you are still having trouble with specific {{cmd|index}} commands, try using the alternative definition. When they are used in the right context, these three possible ways of placing an index term (the plain {{cmd|index}}, or it wrapped in one of the two possible {{cmd|doflushatpar}}s, should solve any problem.<br />
<br />
=Impact on hyphenation, and on line breaking as a consequence=<br />
<br />
{{cmd|index}} is attached to a word, so it modifies the word boundaries. That influences its hyphenation and likely the paragraph's line breaking. To prevent that, you can write:<br />
<br />
<texcode><br />
This is an indexed term\wordboundary\index{Term}. % instead of simply ... term\index{Term}.<br />
</texcode><br />
<br />
That way, ConTeXt knows that the word "term" is ended by the "m" and not by something attached to it by {{cmd|index}}, and the effect on hyphenation and line breaking is the same as if we wrote:<br />
<br />
<texcode><br />
This is an indexed term.<br />
</texcode></div>Owenhhttps://wiki.contextgarden.net/index.php?title=Imposition&diff=25450Imposition2020-01-02T21:29:54Z<p>Owenh: Add section for adding signature pages</p>
<hr />
<div>< [[Structurals]] | [[Visuals]] ><br />
<br />
To impose means to place pages on a bigger sheet in such a way that one can fold and cut the sheet to get a booklet or something similar. Here are some examples:<br />
<br />
* Placing four A5 pages on both sides of an A4 sheet: 1 and 4 on the back, 2 and 3 on the front.<br />
* Placing 64 inner pages of a book on one printing sheet, to produce one signature.<br />
* One of those brochures made by folding an A4 sheet into three pieces. One could typeset this brochure as two pages with three columns each, or once could make six pages and impose them.<br />
* Printing address labels on an A4 sheet, eight labels per sheet.<br />
<br />
In general, imposition is accessed in ConTeXt using {{cmd|setuparranging}}, or from the command line as follows (mkiv and mkii, respectively):<br />
<pre><br />
context --pdfarrange=...<br />
texexec --pdfarrange=...</pre><br />
<br />
== Imposition schemas ==<br />
<br />
=== Default schemas ===<br />
<br />
ConTeXt has some built-in imposition schemas (see "arranging pages" in the manual):<br />
<br />
* 2UP : 2 pages next to each other, n sheets arranged for a single booklet<br />
* 2DOWN : 2 pages above each other, n sheets arranged for a single booklet<br />
* 2SIDE : 2 pages per form, side by side in pagination order, single sided only (no real imposition, only paper saving)<br />
* 2TOP : 2 pages above each other, single sided only<br />
* 2TOPSIDE: 2 odd pages on one side, two even pages verso, above each other<br />
* 2*2 : section: one sheet 2 x 2 pages = 4 pages (2 pages per form, for single sheets with front and back)<br />
* 2**2 : section: one sheet 2 x 2 pages = 4 pages (2 pages per form, for book ordering)<br />
* 2*4 : section: one sheet 2 x 4 pages = 8 pages (4 pages per form, 2x2 pages head to head)<br />
* 2*8 : section: one sheet 2 x 8 pages = 16 pages<br />
* 2*16 : section: one sheet 2 x 16 pages = 32 pages<br />
* 2*4*2 : section of 16 pages: 2 sheets, 4 pages front and backside<br />
* 2*2*4 : section of 16 pages: 4 sheets, 2 pages front and backside<br />
* XY : one sheet with x rows and y columns, you can control the number with {{cmd|setuppaper}}[nx=...,ny=...,dx=...,dy=...]<br />
<br />
"form" means "one side of a sheet".<br />
<br />
{{todo|some graphical examples}}<br />
<br />
===XY schema===<br />
<br />
Beware, you need to set up your XY arranging in the right order:<br />
<br />
<texcode><br />
\setuppapersize[A7][A4,landscape]<br />
\setuppaper[nx=4, ny=2] % must come before \setuparranging!<br />
\setuplayout[page][location=middle, marking=on]<br />
\setuparranging [XY]<br />
</texcode><br />
<br />
Here’s an example for [[Labels]].<br />
<br />
===Testing schemas===<br />
<br />
Here's a convenient test file to help choose a schema or write a new one:<br />
(Note that background=screen is deprecated in MKIV and should be replaced by something like background=color,backgroundcolor=lightgray.)<br />
<br />
<context source=yes><br />
\setuppapersize[A9, landscape][A7, landscape] <br />
<br />
% the schema being tested<br />
\setuparranging [2*4] <br />
<br />
% text describing the schema being tested, to print on the pages<br />
\def\Style{[2*4]}<br />
<br />
% Visuals<br />
\setupbodyfont[ss,10pt]<br />
<br />
\setuplayout [margin=0pt, width=fit, header=2.8ex, footer=2.8ex] <br />
\setuppagenumbering [alternative=doublesided,location=footer]<br />
\setupheadertexts[\CONTEXT\ imposition test]<br />
<br />
\showframe<br />
\setupbackgrounds [text][text][background=screen,backgroundscreen=0.7] <br />
<br />
\setupcolors [state=start]<br />
% Where the block of pages is placed on the sheet <br />
% (Not relevant in this example, but relevant if there is space left over.)<br />
\setuplayout [location=middle,marking=on]<br />
<br />
\startbuffer[Fakepage]<br />
\strut<br />
\blank<br />
\midaligned{\Style}<br />
\vfill<br />
\midaligned{This is page \recurselevel}<br />
\vfill<br />
\stopbuffer<br />
<br />
\starttext<br />
\dorecurse{16}{\getbuffer[Fakepage]\page}<br />
\stoptext<br />
</context><br />
<br />
=== Rearranging existing PDF s===<br />
<br />
ConTeXt is also handy when you need to '''rearrange an existing pdf''' into a booklet. This is a trial-and-error solution by Mari for rearranging an A4 pdf file into 2*8 spreads on A3 sheet (-> A6 pages when printed and cut). <br />
Not sure about the margins on the final A6 pages (the original has equal left and right margins, some extra inside margin might be a good thing), but at least otherwise this seems to do the trick:<br />
<br />
<texcode><br />
\setuppapersize[A6][A3] %individual page A6 size, print size A3<br />
\setuparranging[2*8,rotated] %makes an 8 page gathering when folded (duplex printing!)<br />
\setuplayout<br />
[backspace=0pt,<br />
topspace=0pt,<br />
width=middle,<br />
height=middle,<br />
location=middle,<br />
header=0pt,<br />
footer=0pt]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\insertpages<br />
[original_file.pdf][width=0pt]<br />
<br />
\stoptext<br />
<br />
</texcode><br />
<br />
For proofing one sometimes wants to pick just some pages and when the original is A5, it is kind of handy to put them side-by-side for proofing. The command {{cmd|filterpages}} allows you to define exactly what pages are needed. Be warned, though, that the page numbers refer to the pages in the pdf file, not the page numbers. <br />
<br />
<texcode><br />
\setuppapersize[A5][A4] %individual page A5 size, print size A4<br />
\setuparranging[2SIDE,rotated] %2 pages side by side, rotated to landscape to fit portrait A4<br />
\setuplayout<br />
[backspace=0pt,<br />
topspace=0pt,<br />
width=middle,<br />
height=middle,<br />
location=middle,<br />
header=0pt,<br />
footer=0pt]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\filterpages<br />
[file.pdf][2,5,16:19][width=0pt] %picks pdf pages 2, 5, and 16-19.<br />
<br />
\stoptext<br />
</texcode><br />
<br />
For more information, see the article on [[Including pages from PDF documents]].<br />
<br />
=== Custom imposition schema===<br />
<br />
You can create a new imposition schema to meet your needs. To do so, take a look at the imposition definitions stored in <code>page-imp.mkiv</code> and find the closest one to work with. You can access the file online:<br />
<br />
https://source.contextgarden.net/?search=%5C%5Cdef%5C%5Csetuparranging<br />
<br />
Let's say we want this page arrangement on one sheet (R = page upside down):<br />
<br />
<pre>P4 P1<br />
R3 R2</pre><br />
<br />
This is a mirrored/reversed version of {{cmd|setuparranging}}<code>[1*4]</code>, which gives:<br />
<br />
<pre>R1 R4<br />
P2 P3</pre><br />
<br />
<context source=yes><br />
% Adapted from page-imp.mkiv<br />
<br />
\installpagearrangement 1*4*reversed<br />
{\dosetuparrangement{2}{2}{4}{3}{3}% X,Y,Total,hcutmarks,vcutmarks<br />
\pusharrangedpageFOURSINGLESIDEDFOLDEDREVERSED\poparrangedpagesTWO\relax}<br />
<br />
\def\pusharrangedpageFOURSINGLESIDEDFOLDEDREVERSED#1%<br />
{\advancearrangedpageN<br />
\reportarrangedpage\arrangedpageN<br />
\ifcase\arrangedpageN<br />
\or \handlearrangedpageXandY{#1}010\arrangedpageA % 1 rot,hskip,vskip<br />
\or \handlearrangedpageXandY{#1}111\arrangedpageA % 2<br />
\or \handlearrangedpageXandY{#1}101\arrangedpageA % 3<br />
\or \handlearrangedpageXandY{#1}000\arrangedpageA % 4<br />
\poparrangedpages<br />
\fi}<br />
<br />
\setuppapersize [A10][A8]<br />
\setuparranging [1*4*reversed]<br />
\setuplayout [margin=0pt, width=fit]<br />
<br />
\showframe<br />
<br />
\starttext<br />
\dorecurse{4}{\vbox to \textheight{\vfill\midaligned{\tfd ABC}\vfill}\page}<br />
\stoptext<br />
</context><br />
<br />
== Cut marks ==<br />
<br />
ConTeXt also allows to place cut marks. This can be controlled using the <tt>marking</tt> option of {{cmd|setuplayout}}; possible values are:<br />
<br />
* '''on''' show cut marks and page number<br />
* '''screen''' ditto, but also print a grey-scale colour bar<br />
* '''colour''' ditto, but also print a colour bar<br />
* '''text''' print a text, defaults to `empty`<br />
<br />
The default settings are<br />
<br />
<texcode><br />
\def\pagecutmarksymbol {\the\realpageno}<br />
\def\pagecutmarklength {.5cm}<br />
\let\pagecutmarktoptext \empty<br />
\let\pagecutmarkbottomtext \empty<br />
</texcode><br />
<br />
To obtain register marks (or also called registration marks) you can use the small [http://archive.contextgarden.net/message/20070417.212628.76134ff7.en.html <tt>crop</tt> module] which was posted to the mailing list.<br />
<br />
== Caveat: common troubles ==<br />
<br />
Note that some features (e.g. table of contents, internal references) are always disabled in imposition mode. So, they will not be included in the pdf if you ask for imposition.<br />
To get rid of this you can use the "arrange" key for texexec. <br />
<br />
<texcode><br />
texexec --arrange yourFilename<br />
</texcode><br />
<br />
This will run the document at first without page arrangement and impose the pages in a separate run after table of contents etc are created.<br />
<br />
In '''SciTe/WinConTeXt''' you can run this command by choosing ''Process and Arrange'' in the ''Tools'' menu in SciTe.<br />
<br />
== Getting the last page of a Booklet ==<br />
<br />
When you use imposition to print a booklet you want to put something on the very last page, the <code>quadruple</code> pagebreak did not always fill the remaining pages until you get a quadruple number of pages.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\startvariables all<br />
nextquadruple: nextquadruple<br />
\stopvariables<br />
<br />
\installpagebreakhandler \v!nextquadruple<br />
{\ifdoublesided<br />
\!!counta\realpageno<br />
\!!countb\realpageno<br />
\advance\!!counta 4<br />
\divide\!!counta 4<br />
\multiply\!!counta 4<br />
\advance\!!countb 1<br />
\advance\!!counta-\!!countb<br />
\executepagebreakhandler\v!yes<br />
\dorecurse\!!counta{\executepagebreakhandler\v!empty}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\setuppapersize[A5][A4]<br />
\setuparranging[2UP,rotated,doublesided]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\subject{Front Cover}<br />
<br />
\dorecurse{10}{\input tufte \par}<br />
<br />
\page[nextquadruple]<br />
<br />
Back Cover<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Getting to the Back Cover of a Booklet ==<br />
<br />
When using imposition to print an a5 booklet (a4 folded in half) John Devereux wanted to specify content for the back cover, independently of the actual number of pages in the booklet. Here is a way that worked (thanks to Wolfgang Schuster on the mailing list). \page[beforequadruple] gets to the inside back cover. Another \page gets to the outside back cover.<br />
<br />
<texcode><br />
\unprotect<br />
<br />
\startvariables all<br />
beforequadruple: beforequadruple<br />
\stopvariables<br />
<br />
\installpagebreakhandler \v!beforequadruple<br />
{\ifdoublesided<br />
\!!counta\realpageno<br />
\!!countb\realpageno<br />
\advance\!!counta 5<br />
\divide\!!counta 4<br />
\multiply\!!counta 4<br />
\advance\!!countb 2<br />
\advance\!!counta-\!!countb<br />
\executepagebreakhandler\v!yes<br />
\dorecurse\!!counta{\executepagebreakhandler\v!empty}%<br />
\fi}<br />
<br />
\protect<br />
<br />
\setuppapersize[A5][A4]<br />
\setuparranging[2UP,rotated,doublesided]<br />
\setuppagenumbering[alternative=doublesided]<br />
<br />
\starttext<br />
<br />
\subject Front Cover<br />
<br />
\dorecurse{10}{\input tufte \par}<br />
<br />
\page[beforequadruple]<br />
<br />
Imprint<br />
<br />
\page<br />
<br />
Back Cover<br />
<br />
\stoptext<br />
</texcode><br />
<br />
== Adding pages for imposition signature ==<br />
<br />
With `\setuppagenumbering[alternative=doublesided`, there will always be an even number of pages. If you need to always have a multiple of four pages, use `\page[quadruple]` at the end of the document:<br />
<br />
<pre><br />
% Enable doublesided; there will always be an even number of pages<br />
\setuppagenumbering[alternative=doublesided,location=right]<br />
<br />
\starttext<br />
\completecontent<br />
\startchapter[title={A Chapter}]<br />
Text of chapter 1<br />
\stopchapter<br />
\startchapter[title={Another Chapter}]<br />
Text of chapter 2<br />
\stopchapter<br />
<br />
% Make sure there are a multiple of four pages in the document<br />
\page[quadruple]<br />
\stoptext<br />
</pre><br />
<br />
''Is there is a case where the complex solution in the next section would be necessary?''<br />
<br />
== Imposition by signatures ==<br />
<br />
Sometimes you want a booklet, but the pages are too many to be folded together. This is true especially when the number of pages rises above 80. So you need to pass the output PDF to an imposer, like pdfjam or psbook or pdfpages. The problem is that you need to get the "right" number of pages. <br />
<br />
E.g., if the original pages are 128, no problem, the signature is 64 and you can impose it without problems.<br />
<br />
But, if the original pages are 129, the optimal signature is 44, so<br />
you need to add 3 pages during the PDF compiling.<br />
<br />
First, create the following imposer.lua file<br />
<br />
<pre><br />
-- translated from perl to lua. Original code is in<br />
-- http://theanarchistlibrary.org/docs/altools-6.6.tar.gz<br />
<br />
local maxsignature = 80 -- define the maximum of the signature<br />
local minsignature = 20 -- define the minimum of the signature<br />
function optimize_signature(pages)<br />
local originalpages = pages<br />
-- be sure we don't mess up<br />
assert(numberpage ~= 0, "I can't work with 0 pages")<br />
<br />
--set needed pages to and and signature to 0<br />
local neededpages, signature = 0,0<br />
<br />
-- this means that we have to work with n*4, if not, add them to<br />
-- needed pages <br />
local modulo = pages % 4<br />
if modulo==0 then<br />
signature=pages<br />
else<br />
neededpages = 4 - modulo<br />
end<br />
<br />
-- add the needed pages to pages<br />
pages = pages + neededpages<br />
<br />
-- give a try with the signature<br />
signature = find_signature(pages)<br />
<br />
-- if the pages, are more than the max signature, find the right one<br />
if pages>maxsignature then<br />
while signature<minsignature do<br />
pages = pages + 4<br />
neededpages = 4 + neededpages<br />
signature = find_signature(pages)<br />
end<br />
end<br />
<br />
print("ImposerMessage:: Original pages: " .. originalpages .. "; " .. <br />
"Signature is " .. signature .. ", " ..<br />
neededpages .. " pages are needed, " .. <br />
pages .. " of output")<br />
-- let's do it<br />
tex.print("\\dorecurse{" .. neededpages .. "}{\\page[empty]}")<br />
<br />
end<br />
<br />
function find_signature(number)<br />
assert(number ~= 0, "I can't find the signature for 0 pages")<br />
assert((number % 4) == 0, "I suppose something is wrong, not a n*4")<br />
local i = maxsignature<br />
while i>0 do<br />
if (number % i) == 0 then<br />
return i<br />
end<br />
i = i - 4<br />
end<br />
end<br />
<br />
</pre><br />
<br />
The ImposerMessage is important if you want to pass the output of the ConTeXt run to a script to do the imposing.<br />
<br />
Then the master file<br />
<br />
<texcode><br />
\def\fillthesignature#1{<br />
\directlua{dofile("imposer.lua") <br />
optimize_signature(#1)}}<br />
\starttext<br />
<br />
\dorecurse{53}{<br />
\chapter{test}<br />
\input tufte<br />
\section{\the\realpageno}}<br />
<br />
<br />
\page[yes] % reset the page<br />
\fillthesignature{\the\realpageno}<br />
<br />
And this is the last page (the backcover)<br />
<br />
\stoptext<br />
<br />
</texcode><br />
<br />
You can find a complete script to emulate psbook (which needs a conversion from pdf to ps and back to pdf) and pdfbook (which use the latex package pdfpages) at http://gitorious.org/the-anarchist-library-tools/the-anarchist-library-tools/trees/master/context-imposition and consists of a perl script (with --help included), a ConTeXt module and an example.<br />
<br />
[[Category:ConTeXt-Issues]]<br />
<br />
{{Getting started navbox}}</div>Owenhhttps://wiki.contextgarden.net/index.php?title=Expressions&diff=25449Expressions2020-01-02T20:52:43Z<p>Owenh: Fix eTex Manual link</p>
<hr />
<div>< [[Main Page]] | [[Inside ConTeXt]] ><br />
<br />
ConTeXt implements extensions from eTeX including the evaluation of expressions<br />
(quoted from the [http://www.ntg.nl/maps/20/38.pdf eTeX manual]):<br />
<br />
== Expressions ==<br />
<br />
eTeX introduces the notion of expressions of type number, dimen, glue, or<br />
muglue, that can be used whenever a quantity of that type is needed. Such<br />
expressions are evaluated by eTeX's scanning mechanism; they are initiated<br />
by one of the commands <code>\numexpr</code>, <code>\dimexpr</code>,<br />
<code>\glueexpr</code>, or <code>\muexpr</code><br />
(determining the type <i>t</i>) and terminated by <code>\relax</code> (which<br />
will be absorbed by the scanning mechanism). An expression consists of one<br />
or more terms of the same type to be added or subtracted; a term of type <i>t</i><br />
consists of a factor of that type, optionally multiplied and/or<br />
divided by numeric factors; finally a factor of type <i>t</i> is either a<br />
parenthesized subexpression or a quantity (number, etc.) of that type.<br />
<br />
== Examples ==<br />
<br />
It has been pointed out that<br />
the only important thing for <code>\dimexpr</code> is to write the dimen value<br />
as first value after the <code>\dimexpr</code> command and then the numeric values.<br />
Notice that the following expression is also valid:<br />
<br />
<context source="yes"><br />
\setupexternalfigures[location={local,default}]<br />
\placesidebyside{\externalfigure[cow][width=.4\textwidth]}<br />
{\framed[width=.4\textwidth,height=\dimexpr.4\textwidth*200/275\relax]<br />
{\vbox{this is a cow-sized box}}}<br />
</context><br />
<br />
{{todo|Add some more illustrative examples.}}<br />
<br />
== More on evaluating expressions in ConTeXt ==<br />
<br />
Whereas the eTeX <code>\dimexpr</code> is quite useful,<br />
one must be aware of its limitations arising from how integer arithmetic is performed within TeX.<br />
Following a discussion on the ConTeXt mailing list,<br />
http://archive.contextgarden.net/thread/20090323.122228.af43852e.en.html<br />
this will be illustrated through a pedagogical example (including, as a bonus, a few handy tricks):<br />
<br />
----<br />
''Our question today is how to divide two dimension and compare their result with the result of another division. To do this, we first assign values to four dimensions. Then, we will try using eTeX functions with ConTeXt; the following example should work:''<br />
<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=30pt<br />
<br />
\ifdim\dimexpr\dimen0/\dimen2\relax<\dimexpr\dimen4/\dimen6\relax<br />
The second fraction is greater.<br />
\else<br />
The first fraction is greater.<br />
\fi<br />
</context><br />
<br />
''This appears to work, but does it really? What will be the result if the second fraction were to be greater:''<br />
<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
%\dimen6=30pt<br />
\dimen6=15pt<br />
<br />
\ifdim\dimexpr\dimen0/\dimen2\relax<\dimexpr\dimen4/\dimen6\relax<br />
The second fraction is now greater.<br />
\else<br />
The first fraction is still greater.<br />
\fi<br />
</context><br />
<br />
''What is going on here? The result is weird and unexpected. Why did this happen? Is TeX broken? Let's take a closer look at the real values of the dimensions and their results after division:''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\the\dimen0{}<br />
</context><br />
''which has a real internal value of''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\number\dimen0{}<br />
</context><br />
''in scaled points. Only the second integer value (in scaled points) is important for our calculation.''<br />
''We also need to know the internal value of the second dimension:''<br />
<context source="yes"><br />
\dimen2=20pt<br />
\number\dimen2<br />
</context><br />
''Finally, we would like to know the result of the division of these two numbers:''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\number\dimexpr\dimen0/\dimen2\relax<br />
</context><br />
<br />
''The result of the integer division is 1 (rather than the decimal 0.75); This illustrates that the result of dividing two numbers that are nearly equal within TeX is not very useful. We can get around this by multiplying the numerators by some large factor, assuring that the evaluated fractions remain integer:''<br />
<context source="yes"><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
%\dimen6=30pt<br />
\dimen6=15pt<br />
<br />
\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax<br />
The second fraction is now greater.<br />
\else<br />
The first fraction is still greater.<br />
\fi<br />
</context><br />
<br />
The important point to keep in mind is that TeX performs '''integer''' arithmetic in units of scaled points.<br />
Therefore, one must be careful, especially when using divisions that may lead to integer rounding.<br />
<br />
== LuaTeX ==<br />
<br />
''Alternatively, we can use luaTeX to reliably get the correct result. The <code>tex.dimen</code> command allows us to access the <code>\dimen</code> register from TeX in Lua.''<br />
<br />
<texcode><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=30pt<br />
<br />
\startluacode<br />
if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then<br />
tex.sprint("The second fraction is greater.")<br />
else<br />
tex.sprint("The first fraction is greater.")<br />
end<br />
\stopluacode<br />
</texcode><br />
<br />
<context><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=30pt<br />
<br />
\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax<br />
The second fraction is greater.<br />
\else<br />
The first fraction is greater.<br />
\fi<br />
</context><br />
<br />
''and''<br />
<br />
<texcode><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
%\dimen6=30pt<br />
\dimen6=15pt<br />
<br />
\startluacode<br />
if tex.dimen[0] / tex.dimen[2] < tex.dimen[4] / tex.dimen[6] then<br />
tex.sprint("The second fraction is now greater.")<br />
else<br />
tex.sprint("The first fraction is still greater.")<br />
end<br />
\stopluacode<br />
</texcode><br />
<br />
<context><br />
\dimen0=15pt<br />
\dimen2=20pt<br />
\dimen4=15pt<br />
\dimen6=15pt<br />
<br />
\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax<br />
The second fraction is now greater.<br />
\else<br />
The first fraction is still greater.<br />
\fi<br />
</context><br />
<br />
''The output is now correct in both cases without making use of any tricks.''<br />
<br />
<br />
[[Category:Inside ConTeXt]]<br />
[[Category:ConTeXt programming]]</div>Owenhhttps://wiki.contextgarden.net/index.php?title=ConTeXt_Standalone&diff=25447ConTeXt Standalone2020-01-02T07:02:18Z<p>Owenh: /* Disc space required */ Add missing parenthesis</p>
<hr />
<div>{{Installation navbox}}<br />
<br />
The '''ConTeXt suite''' is a complete, up-to-date ConTeXt distribution that can be upgraded efficiently. It can also be used in parallel with existing TeX installations such as MikTeX, TeXLive, and so forth. The suite does not include LaTeX packages and binaries.<br />
<br />
Sometimes ConTeXt beta releases have issues. The ConTeXt suite allows you to test the latest ConTeXt release without worrying whether upgrading will corrupt a critical project. Multiple ConTeXt suite installations are possible. This allows, for example, a stable version and a beta version to run in parallel on the same computer.<br />
<br />
ConTeXt is also included in TeXlive. The ConTeXt suite is updated continuously, whereas ConTeXt in TeXlive is updated less often. In particular, <code>luatex</code> and <code>metapost</code> are under active development and their binaries are updated frequently. ConTeXt follows these developments, indeed often drives development. As the binaries included in the TeXlive distribution are only updated yearly, ConTeXt on TeXlive will necessarily be less current than the ConTeXt suite. The ConTeXt suite is self-contained and can happily coexist alongside another installed TeX distribution.<br />
<br />
{{TOClimit|limit=1}}<br />
<br />
= General Information =<br />
<br />
== Supported platforms ==<br />
<br />
{| style="border:1px solid #DDDDDD;"<br />
|- align="left" <br />
! Platform<br />
! Short name<br />
! Notes<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Windows<br />
| mswin<br />
| from [http://w32tex.org W32TeX]<br />
|- align="left"<br />
! Windows/CygWin<br />
| cygwin<br />
| same binaries as mswin<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Windows, 32 bit<br />
| win32<br />
| Alias for mswin<br />
|- align="left"<br />
! Windows, 64 bit<br />
| win64<br />
| <br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Linux, 32-bit<br />
| linux<br />
| Debian 8<br />
|- align="left"<br />
! Linux, 64-bit<br />
| linux-64<br />
| Debian 8<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Linux, ARM (low end.)<br />
| linux-arm<br />
| Raspbian 8<br />
|- align="left"<br />
! Linux, musl<br />
| linuxmusl-64<br />
| Alpine<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Mac OS X, Intel (64-bit)<br />
| osx-64<br />
| Mac OS X 10.6<br />
|- align="left"<br />
! FreeBSD, 32-bit<br />
| freebsd<br />
|<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! FreeBSD, 64-bit<br />
| freebsd-amd64<br />
|<br />
|- align="left"<br />
! OpenBSD 6.4, 32-bit<br />
| openbsd6.4<br />
|<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! OpenBSD 6.4, 64-bit<br />
| openbsd6.4-amd64<br />
|<br />
|- align="left"<br />
! OpenBSD 6.5, 32-bit<br />
| openbsd6.5<br />
|<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! OpenBSD 6.5, 64-bit<br />
| openbsd6.5-amd64<br />
|<br />
|- align="left"<br />
! Solaris, Intel<br />
| solaris-intel<br />
| Solaris 10 on [http://www.opencsw.org/about/ OpenCSW]<br />
|- align="left" style="background-color:#EEEEEE;"<br />
! Solaris, Sparc<br />
| solaris-sparc<br />
| Solaris 10 on [http://www.opencsw.org/about/ OpenCSW]<br />
|}<br />
<br />
* If you run into problems installing, check the available architectures in the minimal’s [http://minimals.contextgarden.net/setup/ setup folder]!<br />
* OpenBSD 6.4 binaries are compiled but are missing in the setup folder ATM (2019-07)<br />
<br />
If you want to support a new platform, please write to the [[ConTeXt Mailing Lists]]<br />
<br />
== Dependencies ==<br />
* Rsync (The windows binary of rsync is distributed within the suite)<br />
<br />
<br />
The following programs are not required for running ConTeXt, but their installation adds additional functionality.<br />
<br />
* curl : for including remote content<br />
* ghostscript : for converting PostScript images to PDF<br />
* graphicsmagick (convert) : for converting GIF and TIFF images<br />
* inkscape : for converting SVG and compressed SVG<br />
* mupdf (mudraw) : for converting PDF to PNG (used for ePub covers)<br />
* pstoedit : for converting PostScript to MetaPost outlines<br />
* zint : for providing barcodes<br />
* zip or 7zip : for EPUB generation<br />
<br />
== Disc space required ==<br />
ConTeXt macro files are small (less than 10MB), but the suite comes with various free fonts which considerably increase the size of the distribution (to around 200MB).<br />
<br />
== Multiple instances of the installation ==<br />
Please note from the start that we recommend installing a complete ConTeXt installation for each project in a production environment. The installation tree is portable (see Moving the Installation Around, below) and can be located under the project's own directory. The advantage is to allow each project to use an instance of ConTeXt that is adapted to its coding and that only gets updated purposely. Since the ConTeXt Standalone is "bleeding edge" and subject to development, certain details in commands, syntax or rendering may evolve slightly. Having a vintage ConTeXt tree for each production project insures that one can come back years later and produce identical results.<br />
<br />
So as not to get carried away under this approach, one can eventually group projects by vintage, period or season, according to cycles of productivity.<br />
<br />
== Standalone ==<br />
<br />
* [[ConTeXt Standalone/FAQ|Standalone/FAQ]] <br />
* [[ConTeXt Standalone/Structure|Standalone/Structure]] <br />
* [[ConTeXt Standalone/Implementation|Standalone/Implementation]]<br />
* [[ConTeXt Standalone/TODO|Standalone/TODO]] <br />
* [[ConTeXt Standalone/Contents|Standalone/Contents]] <br />
* [[ConTeXt Standalone/TeX Live|Standalone/TeX Live]]<br />
* Browse the [http://minimals.contextgarden.net installation tree]<br />
<br />
<br />
<br />
= Unix-like platforms (Linux/MacOS X/FreeBSD/Solaris) =<br />
<br />
For Mac installation see also [http://wiki.contextgarden.net/Mac_Installation Mac installation page].<br />
<br />
== Single user installation ==<br />
<br />
Select a folder where you want to install ConTeXt. We recommend that you can use your <code>$HOME/context</code> directory. Create this folder. Then download and place it in <code>$HOME/context</code> directory. Open a terminal, then:<br />
<br />
<pre><br />
mkdir ~/context<br />
cd ~/context<br />
wget http://minimals.contextgarden.net/setup/first-setup.sh<br />
<br />
# Install the latest beta of ConTeXt<br />
# This takes a long time, so go have a coffee<br />
# Flags you can add to the first-setup.sh call:<br />
# --modules=all # Install all third-party modules<br />
# --context=current # Install latest stable version<br />
# --engine=luatex # Install only MkIV, leave out MkII<br />
# # This shrinks the install from 270 MB to 200 MB<br />
<br />
sh ./first-setup.sh --modules=all<br />
</pre><br />
<br />
== System-wide installation ==<br />
<br />
A system wide installation is recommended for users who are comfortable with the command line. Only the location of installing ConTeXt is different for a system wide installation.<br />
<br />
* on Linux you can use <code>/opt/context</code><br />
* on MacOS X you can use <code>/Applications/ConTeXt</code><br />
<br />
Note that, at present, while ''using'' MkIV, you need to have write permissions for the <code>$TEXMFCACHE</code> directory. This effectively means that only one user will be able to generate the formats unless you set the group permissions appropriately. For example:<br />
<br />
* <code>CONTEXT_HOME=/opt/context</code><br />
* <code>TEXMFCACHE=$CONTEXT_HOME/tex/texmf-cache</code><br />
* <code>chmod -R g+w $TEXMFCACHE</code><br />
<br />
<pre><br />
# Create the /opt/context directory -- change as appropriate or desired if you <br />
# want a different installation directory.<br />
cd /opt<br />
mkdir context<br />
<br />
cd context<br />
<br />
# Fetch the install script<br />
wget http://minimals.contextgarden.net/setup/first-setup.sh<br />
<br />
# Install the latest beta of ConTeXt<br />
# This takes a long time, so go have a coffee<br />
# Flags you can add to the first-setup.sh call:<br />
# --modules=all # Install all third-party modules<br />
# --context=current # Install latest stable version<br />
# --engine=luatex # Install only MkIV, leave out MkII<br />
# # This shrinks the install from 270 MB to 200 MB<br />
<br />
sh ./first-setup.sh --modules=all<br />
<br />
# change ownership to real rather than effective id<br />
chown -R `id -r -u`:`id -r -g` .<br />
</pre><br />
<br />
===Cache===<br />
<br />
To customize the cache directory and other options, see the [[Custom_Configuration|Custom Configuration]] page.<br />
<br />
===Font Directory===<br />
<br />
Add the OSFONTDIR into ./tex/setuptex. Go to under the line:<br />
<br />
# TODO: we could set OSFONTDIR on Mac for example<br />
<br />
(if you don't have the line above, go to the end of the file) and add there:<br />
<br />
export OSFONTDIR="/usr/local/share/fonts;$HOME/.fonts"<br />
<br />
For more information: [[Fonts in LuaTeX]]<br />
<br />
== Apache webserver installation ==<br />
<br />
Another common usecase is invoking ConTeXt from within a web application. Because web directories are often self-contained, and in the case of Apache under Ubuntu, ownership of the directory and its contents are assigned to a user and group without a login shell, e.g., <code>www-data:www-data</code> this prevents a web application from invoking a ConTeXt installation done using either the single-user or system-wide method listed above.<br />
<br />
In this case the solution is to install ConTeXt within the website tree, and ideally in the public sub-tree. The public sub-tree is commonly the home directory for the application and relative pathnames are resolved as if immediately below it.<br />
<br />
For example, in the case of the PHP web framework Laravel, ConTeXt can be installed alongside other assets in the <path-to-document-root>/public/context directory:<br />
<br />
<pre><br />
cd <path-to-document-root>/public<br />
mkdir context<br />
cd context<br />
wget http://minimals.contextgarden.net/setup/first-setup.sh<br />
<br />
# Install the latest beta of ConTeXt<br />
# This takes a long time, so go have a coffee<br />
# Flags you can add to the first-setup.sh call:<br />
# --modules=all # Install all third-party modules<br />
# --context=current # Install latest stable version<br />
# --engine=luatex # Install only MkIV, leave out MkII<br />
# # This shrinks the install from 270 MB to 200 MB<br />
<br />
sh ./first-setup.sh --modules=all<br />
</pre><br />
<br />
Once installed, you need to ensure that the permissions are correct for Apache to be able to access it (you will either need <code>sudo</code> privileges or root access):<br />
<br />
<pre><br />
$ cd <path-to-document-root>/public<br />
$ sudo chmod -R www-data:www-data context<br />
</pre><br />
<br />
Now as part of your application's invocation of ConTeXt, you will need to set up the shell environment. This is easily done by creating a simple BASH shell script, also to be installed in the public part of the document tree:<br />
<br />
<pre><br />
#!/usr/bin/env bash<br />
<br />
#<br />
# proccontext.sh<br />
#<br />
# To be installed in <path-to-document-root>/public/bin<br />
<br />
. <path-to-document-root>/public/context/tex/setuptex <path-to-document-root>/public/context/tex<br />
<br />
cd tex/spool<br />
context $1 > /tmp/context_run.log<br />
</pre><br />
<br />
Here the dynamically generated ConTeXt source file is expected to be found in the <code><path-to-document-root>/tex/spool</code> directory.<br />
<br />
Now within your application, you can invoke this shell script (in this case using PHP):<br />
<br />
<pre><br />
$cmd = "bin/proccontext.sh $input_filename";<br />
$last_line = system($cmd, $ret_val);<br />
</pre><br />
<br />
And the output will once again be found in <code><path-to-document-root>/tex/spool</code>.<br />
<br />
==Arch Linux==<br />
There’s a [https://aur.archlinux.org/packages/context-minimals-git PKGBUILD] in<br />
the AUR, provided by Aditya [https://github.com/adityam/context-pkgbuild].<br />
Install it using your favorite AUR frontend, e.g.<br />
<br />
<pre><br />
yaourt -S context-minimals-git<br />
</pre><br />
<br />
This will get you a fresh, up-to-date Context tree in<br />
<tt>/opt/context-minimals</tt>.<br />
<br />
== The funtoo way ==<br />
<br />
If you are using [http://funtoo.org funtoo] there are ebuilds that will make an installation as easy as installing any other package from portage. Take a look at the [[ConTeXt Standalone Funtoo]] Howto. This might also work for [http://www.gentoo.org gentoo], but is untested right now.<br />
<br />
== Proxy settings ==<br />
<br />
The installation script uses <code>rsync</code> to fetch the required files. So, if you are behind a proxy server, you need to tell the details to rsync. The easiest way to set this is to set <code>RSYNC_PROXY</code> variable in the terminal or your startup script (<code>.bashrc</code> or the corresponding file for your shell). Replace username, password, proxyhost and proxyport with the correct information<br />
<br />
export RSYNC_PROXY=username:password@proxyhost:proxyport<br />
<br />
Sometimes, when behind a firewall, port 873 may be closed for outgoing TCP connections. If port 22 is open for ssh connections, a trick that can be used is to connect to a computer located somewhere outside of the firewall and to tunnel port 873 (using the program <code>nc</code>).<br />
<br />
export RSYNC_CONNECT_PROG='ssh tunnelhost nc %H 873'<br />
<br />
where <code>tunnelhost</code> is the machine outside of the firewall on which you have <code>ssh</code> access. Of course, this machine must have <code>nc</code> and port 873 open for outgoing TCP connections.<br />
<br />
== Usage ==<br />
<br />
ConTeXt suite works in a non-interfering manner because it does not put anything in your <code>$PATH</code> and does not set any system variables. This in turn means that in order to use it, you need to do some initialization. An intialization script called <code>setuptex</code> is provided in <code>installation-dir/tex/</code>. <br />
<br />
=== Terminal/Command line ===<br />
<br />
To run context from a terminal, source <code>setuptex</code>:<br />
<br />
source /installation-dir/tex/setuptex<br />
<br />
=== Exclusive usage ===<br />
<br />
If you always use ConTeXt suite and '''never''' use LaTeX or plain TeX provided by another TeX distribution, you can add the following line to the startup script of your shell (For bash, the startup script is <code>$HOME/.bashrc</code>; for zsh it is <code>HOME/.zshrc</code>).<br />
<br />
source /installation-dir/tex/setuptex<br />
<br />
Then <code>setuptex</code> will always be sourced in your terminal.<br />
<br />
=== Integrating with an editor ===<br />
<br />
The easiest way to run ConTeXt from an editor is to open a terminal, source {{code|setuptex}} in the terminal, and then open your editor '''from the same terminal'''. <br />
<br />
Another option is to add {{code|/installation-dir/tex/texmf-<platform>/bin}} to the {{code|$PATH}} that the editor searches. The details vary depending on the editor. See [[Text Editors]] for instructions on integrating ConTeXt with various editors. <br />
<br />
For information about configuring [http://smultron.sourceforge.net/ Smultron] and [http://www.uoregon.edu/~koch/texshop/obtaining.html TeXShop] (which are popular TeX editors on Mac) see [[ConTeXt Standalone/Mac Installation]].<br />
<br />
<br />
== Updating ==<br />
<br />
For updating the ConTeXt suite, <br />
first update <code>first-setup.sh</code>, then run it. You could<br />
also create an alias or a little script “ctx-update”<br />
with the following example contents:<br />
<pre><br />
cd /opt/context<br />
rsync -ptv rsync://contextgarden.net/minimals/setup/first-setup.sh .<br />
sh ./first-setup.sh --modules=all<br />
</pre><br />
<br />
To update retain currently-installed modules:<br />
<pre><br />
sh ./first-setup.sh --keep<br />
</pre><br />
<br />
== Uninstalling ==<br />
<br />
ConTeXt suite does not touch anything outside its installation folder. So to uninstall it, you can simply remove the installation folder.<br />
<br />
== Remaking formats ==<br />
<br />
Normally, the update script should create the formats for you. If for some reason you need to recreate the formats, you can do the following:<br />
<br />
* For making MKII format.<br />
<br />
mktexlsr<br />
texexec --make --all <br />
<br />
* For making XeTeX format<br />
<br />
mktexlsr<br />
texexec --make --xtx --all <br />
<br />
* For making MKIV format<br />
<br />
mtxrun --generate<br />
context --make<br />
<br />
= Windows =<br />
<br />
If you want to use ConTeXt suite alongside MikTeX/TeXLive (needed if you also run LaTeX), follow the command-line installation method. <br />
<br />
== Installation ==<br />
<br />
=== Command line method ===<br />
Download [http://minimals.contextgarden.net/setup/context-setup-mswin.zip context-setup-mswin.zip] or [http://minimals.contextgarden.net/setup/context-setup-win64.zip context-setup-win64.zip], and unzip to a directory where you want to install ConTeXt. It is recommended that you choose a directory that does not have a space in its full path. Then open <code>cmd.exe</code>, go to the installation directory and run<br />
<br />
first-setup.bat<br />
<br />
This takes a long time, so go have a coffee. <br />
<br />
By default, the suite installs ConTeXt beta. If you want the stable version of ConTeXt, you can use <br />
<br />
first-setup.bat --context=current<br />
<br />
By default, the suite does ''not'' install modules and other third party content. If you want the modules (and have the bandwidth), you can use<br />
<br />
first-setup.bat --modules=all<br />
<br />
<br />
If the above installation instructions don't seem to answer your questions, see page [[Windows_Installation:_ConTeXt_Suite_with_SciTe| Windows Installation: ConTeXt Suite with SciTe]] for more detailed information.<br />
<br />
<br />
== Proxy settings ==<br />
<br />
The installation script uses <code>rsync</code> to fetch the required files. So, if you are behind a proxy server, you need to tell the details to rsync. The easiest way to set this is to set <code>RSYNC_PROXY</code> variable in the terminal as (replace username, password, proxyhost and proxyport with the correct information)<br />
<br />
set RSYNC_PROXY=username:password@proxyhost:proxyport<br />
<br />
or set the variable permanently as a Windows environment variable.<br />
<br />
Sometimes, when behind a firewall, port 873 may be closed for outgoing TCP connections. If port 22 is open for ssh connections, a trick that can be used is to connect to a computer located somewhere outside of the firewall and to tunnel port 873 (using the program <code>nc</code>).<br />
<br />
export RSYNC_CONNECT_PROG='ssh tunnelhost nc %H 873'<br />
<br />
where <code>tunnelhost</code> is the machine outside of the firewall on which you have <code>ssh</code> access. Of course, this machine must have <code>nc</code> and port 873 open for outgoing TCP connections.<br />
<br />
== Usage ==<br />
<br />
Before running ConTeXt, you need to run <code>setuptex.bat</code> which is provided in <code>installation-dir\tex\</code>. This can be done by typing<br />
<br />
installation-dir\tex\setuptex.bat<br />
<br />
on cmd.exe before you run ConTeXt. To avoid always having to type this, you can create a shortcut to cmd.exe and edit the command line to read (assuming you installed the suite in <code>C:\Programs</code>; otherwise replace <code>C:\Programs\</code> with your installation directory)<br />
<br />
C:\WINDOWS\System32\cmd.exe /k C:\Programs\context\tex\setuptex.bat<br />
<br />
This starts up a new command shell with the environment pre-loaded. Within the new shell you can just type <code>context</code> to run ConTeXt. E.g.<br />
<br />
C:\> context --version<br />
<br />
to check that you are running the version you think you're running.<br />
<br />
=== Use ConTeXt with Cygwin ===<br />
After installing the ConTeXt suite, you can run it under Cygwin. With Cygwin, you may use gmake and other Unix tools for your automated workflow.<br />
<br />
# Run <code>setuptex.bat</code> in DOS command prompt<br />
# In the same DOS prompt, enter Cygwin by running <code>cygwin.bat</code> (in your Cygwin installation directory)<br />
# Under Cygwin prompt, run <code> context.cmd test.tex </code>. Note that the <code>.cmd</code> extension is needed under Cygwin.<br />
<br />
== Updating ==<br />
<br />
If you used the command line method, just run <code>first-setup.bat</code> again to update the suite.<br />
<br />
<br />
== Uninstallation ==<br />
<br />
If you used the command-line installer, you can just delete the installation directory to uninstall the suite.<br />
<br />
<br />
== Troubleshooting ==<br />
<br />
* rsync sometimes has problems with paths with uppercase letters (like <code>c:\Temp</code> or <code>C:\Documents and Settings</code>). Installing into all-lowercase paths without spaces sometimes helps.<br />
* Directory-name length may also have an effect, due to Windows's 8.3 filename conventions. An indicator is if running "texexec --lua" on a file produces missing-file warnings containing Windows-created 8-character directory names, such as "C:\CONTEX~1\tex", where your ConTeXt directory is really "C:\context_minimals\tex". Be conservative and choose a short name like "C:\ctm\tex". Also, this may even work when an 8-character-or-less directory name like "C:\ctexmin\tex" doesn't.<br />
* If you're behind firewall and rsync times out, you need to open port 873 for outgoing TCP connections.<br />
* If you update luaTeX occasionally you may get something like <br />
<br />
<code>engine mismatch (luv: This is LuaTeX, Version beta-<version>-<date1> (TeX Live 2013/dev)(rev <number1>) <> bin: This is LuaTeX, Version beta-<version>-<date1> (TeX Live 2012/W32TeX)(rev <number2>)), forcing remake</code><br />
<br />
In which case your format will be remade every time you compile a file. In /texmf-mswin make sure that luatex.exe and texlua.exe have the same date; then also delete luatex.dll. This usually solves the problem.<br />
<br />
= Installing third party modules =<br />
<br />
The ConTeXt suite only comes with Taco's [[Bibliography|t-bib]] module. If you want to install [http://modules.contextgarden.net/ a new module], say Wolfgang's [[Letter|t-letter]] module, you can use<br />
first-setup.sh --modules="t-letter"<br />
<br />
If you want to install more than one extra module, you can separate them by commas. So, to install the t-letter and t-mathsets module, do<br />
sh ./first-setup.sh --modules="t-letter,t-mathsets"<br />
<br />
If you want to install all extra modules at once, do<br />
sh ./first-setup.sh --modules=all<br />
<br />
= Reverting to an older installation =<br />
<br />
If, for some reason, you want to revert to an older installation, you can do that by<br />
<br />
sh ./first-setup.sh --context=date<br />
<br />
where <code>date</code> is the date of one of the stable releases of ConTeXt. The complete list of old releases that are available is [http://minimals.contextgarden.net/current/context/ here].<br />
<br />
<br />
= Moving the installation tree around = <br />
<br />
According to this post, http://archive.contextgarden.net/message/20101129.144331.d721372f.en.html it's safe to move the installation tree across directory or machines (say you don't have broadband access). You just have to clean and regenerate the cache (./tex/texmf-cache/luatex-cache) with <br />
mtxrun --generate<br />
<br />
= Notes =<br />
<references/><br />
<br />
{{Getting started navbox}}<br />
[[Category:Installation]]<br />
[[Category:Standalone]]</div>Owenhhttps://wiki.contextgarden.net/index.php?title=Command/setupregister&diff=25446Command/setupregister2020-01-02T06:45:51Z<p>Owenh: /* See also */ Add \register command</p>
<hr />
<div>{{Reference<br />
|name=setupregister<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>setupregister</syntax><br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupregister<span class="first" >[...]</span><span class="second" style="color:red;">[...]</span><span class="third" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>singular </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:n|n]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:balance|balance]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pagestyle|pagestyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:textstyle|textstyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:indicator|indicator]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:coupling|coupling]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:check|check]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr> <tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:sectionnumber|sectionnumber]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:criterium|criterium]]</td><br />
<td>[[Command/value:section|section]] [[Command/value:local|local]] [[Command/value:all|all]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:symbol|symbol]]</td><br />
<td>1 2 ... [[Command/value:n|n]] [[Command/value:a|a]] ... [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:interaction|interaction]]</td><br />
<td>[[Command/value:pagenumber|pagenumber]] [[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:expansion|expansion]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:referencing|referencing]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:location|location]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:middle|middle]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:maxwidth|maxwidth]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:unknownreference|unknownreference]]</td><br />
<td>[[Command/value:empty|empty]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:alternative|alternative]]</td><br />
<td>[[Command/value:a|a]] [[Command/value:b|b]] [[Command/value:A|A]] [[Command/value:B|B]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:prefix|prefix]]</td><br />
<td>[[Command/value:both|both]] [[Command/value:first|first]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pagecommand|pagecommand]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:textcommand|textcommand]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:compress|compress]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:text|text]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:language|language]]</td><br />
<td>[[Command/value:language|language code]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:method|method]]</td><br />
<td>[[Command/value:default|default]] [[Command/value:before|before]] [[Command/value:after|after]] [[Command/value:first|first]] [[Command/value:last|last]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pageleft|pageleft]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pageright|pageright]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
The options are as follows:<br />
<br />
<table cellspacing="4" cellpadding="2"><br />
<tr><br />
<th>Option</th><br />
<th>Description</th><br />
</tr><br />
<tr><br />
<td>n</td><br />
<td>number of columns</td><br />
</tr><br />
<tr><br />
<td>balance</td><br />
<td>balance columns?</td><br />
</tr><br />
<tr><br />
<td>align</td><br />
<td>balance related (it’s difficult; try which combination suits you)</td><br />
</tr><br />
<tr><br />
<td>style</td><br />
<td>style of the indicator letters</td><br />
</tr><br />
<tr><br />
<td>pagestyle</td><br />
<td>style of page number</td><br />
</tr><br />
<tr><br />
<td>textstyle</td><br />
<td>style of index word</td><br />
</tr><br />
<tr><br />
<td>indicator</td><br />
<td>create letter sections?</td><br />
</tr><br />
<tr><br />
<td>coupling</td><br />
<td>special feature for screen documents (no effect in MkIV?)</td><br />
</tr><br />
<tr><br />
<td>check</td><br />
<td>set {{cmd|seeindex}} entry as entered without verifying. Default no.</td><br />
</tr><br />
<tr><br />
<td>(section)number</td><br />
<td>print part/... numbers?</td><br />
</tr><br />
<tr><br />
<td>criterium</td><br />
<td>for part/chapter/section registers</td><br />
</tr><br />
<tr><br />
<td>distance</td><br />
<td>between text and pagenumber as well as indentation of nested entries</td><br />
</tr><br />
<tr><br />
<td>symbol</td><br />
<td>for pagenumber (a=a,b,c; n=1,2,3; 1=dots; 2=blocks)</td><br />
</tr><br />
<tr><br />
<td>interaction</td><br />
<td>which part should be clickable?</td><br />
</tr><br />
<tr><br />
<td>expansion</td><br />
<td>When the entry is a command, it is expanded before writing to the register</td><br />
</tr><br />
<tr><br />
<td>referencing</td><br />
<td>create references for letter sections (like "index:a")?</td><br />
</tr><br />
<tr><br />
<td>textcommand</td><br />
<td>custom command for index word</td><br />
</tr><br />
<tr><br />
<td>pagecommand</td><br />
<td>custom command for page number</td><br />
</tr><br />
<tr><br />
<td>location</td><br />
<td>?</td><br />
</tr><br />
<tr><br />
<td>compress</td><br />
<td>collapse page numbers (i.e. make “10–13” from “10,11,12,13”); “<tt>text</tt>” (new in April 2019) makes “10ff.”. You can configure the latter via {{cmd|setuplabeltext}}<tt>[en][following:singular=f.,following:plural=ff.]</tt></td><br />
</tr><br />
<tr><br />
<td>maxwidth</td><br />
<td>Set the maximum length for the text of the index entry in the registerlist (the command uses {{cmd|limitatetext}} to do this)</td><br />
</tr><br />
<tr><br />
<td>unknownreference</td><br />
<td>insert a horizontal space before and after the reference in the text if you use interactive mode to move from one entry in the text to next or previous one and there is no previous or next reference.</td><br />
</tr><br />
<tr><br />
<td>alternative</td><br />
<td>?</td><br />
</tr><br />
<tr><br />
<td>language</td><br />
<td>language code like in {{cmd|language}}, influences sorting; see definitions in {{src|sort-lan.mkiv}}</td><br />
</tr><br />
<tr><br />
<td>method</td><br />
<td>sets up the sorter used for {{cmd|placeregister}}, explained at [[Command/keyword:method]]</td><br />
</tr><br />
<tr><br />
<td>pageleft</td><br />
<td>custom command before the first page number</td><br />
</tr><br />
<tr><br />
<td>pageright</td><br />
<td>custom command after the last page number</td><br />
</tr><br />
</table><br />
<br />
Some options don’t seem to have any effect, at least in MkIV.<br />
<br />
== Example ==<br />
<br />
Here is an example for MkII:<br />
<br />
<context source="yes" text="yields"><br />
\defineregister[nickname][nicknames]<br />
<br />
\setupregister [nickname]<br />
[partnumber=no,alternative=A,criterium=all,n=3,balance=yes,pagestyle=normal]<br />
\setupregister [nickname][foto][pagestyle=bold]<br />
<br />
\starttext<br />
<br />
Text about Mamut\nickname{Mamut}.<br />
\placefigure[]<br />
{Kuba\nickname[foto::]{Kuba} on the photo.}<br />
{\externalfigure[kuba][width=0.2\textwidth]}<br />
<br />
\page<br />
And text about Kuba\nickname{Kuba}.<br />
<br />
\completenickname<br />
\stoptext <br />
<br />
</context><br />
<br />
<br />
I found it safer to put \register command after punctuation e.g.: Mamut.\nickname{Mamut} [P.K.]<br />
<br />
For the MkIV version of setting the pagestyle, and more, see the material on {{cmd|defineprocessor}} that is on [[Registers#Processors|this page]].<br />
<br />
== pageleft and pageright ==<br />
<br />
They were introduced in ConTeXt MkIV version 1.02 (2018.05.12 00:07).<br />
<br />
You can use them, for example, to move the page numbers to the right, with:<br />
<br />
<pre><br />
\setupregister[index][pageleft=\wordright\bgroup,pageright=\egroup]<br />
</pre><br />
<br />
See [http://www.mail-archive.com/ntg-context@ntg.nl/msg87812.html this thread]<br />
on the mailing list.<br />
<br />
== See also ==<br />
<br />
* {{cmd|index}}<br />
* {{cmd|register}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Registers|setupregister]]</div>Owenhhttps://wiki.contextgarden.net/index.php?title=Command/setupregister&diff=25445Command/setupregister2020-01-02T06:44:42Z<p>Owenh: Add \index command to "See also" section</p>
<hr />
<div>{{Reference<br />
|name=setupregister<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>setupregister</syntax><br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupregister<span class="first" >[...]</span><span class="second" style="color:red;">[...]</span><span class="third" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>singular </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:n|n]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:balance|balance]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pagestyle|pagestyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:textstyle|textstyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:indicator|indicator]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:coupling|coupling]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:check|check]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr> <tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:sectionnumber|sectionnumber]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:criterium|criterium]]</td><br />
<td>[[Command/value:section|section]] [[Command/value:local|local]] [[Command/value:all|all]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:symbol|symbol]]</td><br />
<td>1 2 ... [[Command/value:n|n]] [[Command/value:a|a]] ... [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:interaction|interaction]]</td><br />
<td>[[Command/value:pagenumber|pagenumber]] [[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:expansion|expansion]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:referencing|referencing]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:location|location]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:middle|middle]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:maxwidth|maxwidth]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:unknownreference|unknownreference]]</td><br />
<td>[[Command/value:empty|empty]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:alternative|alternative]]</td><br />
<td>[[Command/value:a|a]] [[Command/value:b|b]] [[Command/value:A|A]] [[Command/value:B|B]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:prefix|prefix]]</td><br />
<td>[[Command/value:both|both]] [[Command/value:first|first]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pagecommand|pagecommand]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:textcommand|textcommand]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:compress|compress]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:text|text]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:language|language]]</td><br />
<td>[[Command/value:language|language code]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:method|method]]</td><br />
<td>[[Command/value:default|default]] [[Command/value:before|before]] [[Command/value:after|after]] [[Command/value:first|first]] [[Command/value:last|last]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pageleft|pageleft]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pageright|pageright]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
The options are as follows:<br />
<br />
<table cellspacing="4" cellpadding="2"><br />
<tr><br />
<th>Option</th><br />
<th>Description</th><br />
</tr><br />
<tr><br />
<td>n</td><br />
<td>number of columns</td><br />
</tr><br />
<tr><br />
<td>balance</td><br />
<td>balance columns?</td><br />
</tr><br />
<tr><br />
<td>align</td><br />
<td>balance related (it’s difficult; try which combination suits you)</td><br />
</tr><br />
<tr><br />
<td>style</td><br />
<td>style of the indicator letters</td><br />
</tr><br />
<tr><br />
<td>pagestyle</td><br />
<td>style of page number</td><br />
</tr><br />
<tr><br />
<td>textstyle</td><br />
<td>style of index word</td><br />
</tr><br />
<tr><br />
<td>indicator</td><br />
<td>create letter sections?</td><br />
</tr><br />
<tr><br />
<td>coupling</td><br />
<td>special feature for screen documents (no effect in MkIV?)</td><br />
</tr><br />
<tr><br />
<td>check</td><br />
<td>set {{cmd|seeindex}} entry as entered without verifying. Default no.</td><br />
</tr><br />
<tr><br />
<td>(section)number</td><br />
<td>print part/... numbers?</td><br />
</tr><br />
<tr><br />
<td>criterium</td><br />
<td>for part/chapter/section registers</td><br />
</tr><br />
<tr><br />
<td>distance</td><br />
<td>between text and pagenumber as well as indentation of nested entries</td><br />
</tr><br />
<tr><br />
<td>symbol</td><br />
<td>for pagenumber (a=a,b,c; n=1,2,3; 1=dots; 2=blocks)</td><br />
</tr><br />
<tr><br />
<td>interaction</td><br />
<td>which part should be clickable?</td><br />
</tr><br />
<tr><br />
<td>expansion</td><br />
<td>When the entry is a command, it is expanded before writing to the register</td><br />
</tr><br />
<tr><br />
<td>referencing</td><br />
<td>create references for letter sections (like "index:a")?</td><br />
</tr><br />
<tr><br />
<td>textcommand</td><br />
<td>custom command for index word</td><br />
</tr><br />
<tr><br />
<td>pagecommand</td><br />
<td>custom command for page number</td><br />
</tr><br />
<tr><br />
<td>location</td><br />
<td>?</td><br />
</tr><br />
<tr><br />
<td>compress</td><br />
<td>collapse page numbers (i.e. make “10–13” from “10,11,12,13”); “<tt>text</tt>” (new in April 2019) makes “10ff.”. You can configure the latter via {{cmd|setuplabeltext}}<tt>[en][following:singular=f.,following:plural=ff.]</tt></td><br />
</tr><br />
<tr><br />
<td>maxwidth</td><br />
<td>Set the maximum length for the text of the index entry in the registerlist (the command uses {{cmd|limitatetext}} to do this)</td><br />
</tr><br />
<tr><br />
<td>unknownreference</td><br />
<td>insert a horizontal space before and after the reference in the text if you use interactive mode to move from one entry in the text to next or previous one and there is no previous or next reference.</td><br />
</tr><br />
<tr><br />
<td>alternative</td><br />
<td>?</td><br />
</tr><br />
<tr><br />
<td>language</td><br />
<td>language code like in {{cmd|language}}, influences sorting; see definitions in {{src|sort-lan.mkiv}}</td><br />
</tr><br />
<tr><br />
<td>method</td><br />
<td>sets up the sorter used for {{cmd|placeregister}}, explained at [[Command/keyword:method]]</td><br />
</tr><br />
<tr><br />
<td>pageleft</td><br />
<td>custom command before the first page number</td><br />
</tr><br />
<tr><br />
<td>pageright</td><br />
<td>custom command after the last page number</td><br />
</tr><br />
</table><br />
<br />
Some options don’t seem to have any effect, at least in MkIV.<br />
<br />
== Example ==<br />
<br />
Here is an example for MkII:<br />
<br />
<context source="yes" text="yields"><br />
\defineregister[nickname][nicknames]<br />
<br />
\setupregister [nickname]<br />
[partnumber=no,alternative=A,criterium=all,n=3,balance=yes,pagestyle=normal]<br />
\setupregister [nickname][foto][pagestyle=bold]<br />
<br />
\starttext<br />
<br />
Text about Mamut\nickname{Mamut}.<br />
\placefigure[]<br />
{Kuba\nickname[foto::]{Kuba} on the photo.}<br />
{\externalfigure[kuba][width=0.2\textwidth]}<br />
<br />
\page<br />
And text about Kuba\nickname{Kuba}.<br />
<br />
\completenickname<br />
\stoptext <br />
<br />
</context><br />
<br />
<br />
I found it safer to put \register command after punctuation e.g.: Mamut.\nickname{Mamut} [P.K.]<br />
<br />
For the MkIV version of setting the pagestyle, and more, see the material on {{cmd|defineprocessor}} that is on [[Registers#Processors|this page]].<br />
<br />
== pageleft and pageright ==<br />
<br />
They were introduced in ConTeXt MkIV version 1.02 (2018.05.12 00:07).<br />
<br />
You can use them, for example, to move the page numbers to the right, with:<br />
<br />
<pre><br />
\setupregister[index][pageleft=\wordright\bgroup,pageright=\egroup]<br />
</pre><br />
<br />
See [http://www.mail-archive.com/ntg-context@ntg.nl/msg87812.html this thread]<br />
on the mailing list.<br />
<br />
== See also ==<br />
<br />
* {{cmd|index}}<br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Registers|setupregister]]</div>Owenhhttps://wiki.contextgarden.net/index.php?title=Command/setupregister&diff=25443Command/setupregister2020-01-01T09:42:29Z<p>Owenh: Fix cross-reference</p>
<hr />
<div>{{Reference<br />
|name=setupregister<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>setupregister</syntax><br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupregister<span class="first" >[...]</span><span class="second" style="color:red;">[...]</span><span class="third" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>singular </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:n|n]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:balance|balance]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pagestyle|pagestyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:textstyle|textstyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:indicator|indicator]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:coupling|coupling]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:check|check]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr> <tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:sectionnumber|sectionnumber]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:criterium|criterium]]</td><br />
<td>[[Command/value:section|section]] [[Command/value:local|local]] [[Command/value:all|all]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:symbol|symbol]]</td><br />
<td>1 2 ... [[Command/value:n|n]] [[Command/value:a|a]] ... [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:interaction|interaction]]</td><br />
<td>[[Command/value:pagenumber|pagenumber]] [[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:expansion|expansion]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:referencing|referencing]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:location|location]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:middle|middle]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:maxwidth|maxwidth]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:unknownreference|unknownreference]]</td><br />
<td>[[Command/value:empty|empty]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:alternative|alternative]]</td><br />
<td>[[Command/value:a|a]] [[Command/value:b|b]] [[Command/value:A|A]] [[Command/value:B|B]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:prefix|prefix]]</td><br />
<td>[[Command/value:both|both]] [[Command/value:first|first]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pagecommand|pagecommand]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:textcommand|textcommand]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:compress|compress]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:text|text]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:language|language]]</td><br />
<td>[[Command/value:language|language code]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:method|method]]</td><br />
<td>[[Command/value:default|default]] [[Command/value:before|before]] [[Command/value:after|after]] [[Command/value:first|first]] [[Command/value:last|last]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pageleft|pageleft]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pageright|pageright]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
The options are as follows:<br />
<br />
<table cellspacing="4" cellpadding="2"><br />
<tr><br />
<th>Option</th><br />
<th>Description</th><br />
</tr><br />
<tr><br />
<td>n</td><br />
<td>number of columns</td><br />
</tr><br />
<tr><br />
<td>balance</td><br />
<td>balance columns?</td><br />
</tr><br />
<tr><br />
<td>align</td><br />
<td>balance related (it’s difficult; try which combination suits you)</td><br />
</tr><br />
<tr><br />
<td>style</td><br />
<td>style of the indicator letters</td><br />
</tr><br />
<tr><br />
<td>pagestyle</td><br />
<td>style of page number</td><br />
</tr><br />
<tr><br />
<td>textstyle</td><br />
<td>style of index word</td><br />
</tr><br />
<tr><br />
<td>indicator</td><br />
<td>create letter sections?</td><br />
</tr><br />
<tr><br />
<td>coupling</td><br />
<td>special feature for screen documents (no effect in MkIV?)</td><br />
</tr><br />
<tr><br />
<td>check</td><br />
<td>set {{cmd|seeindex}} entry as entered without verifying. Default no.</td><br />
</tr><br />
<tr><br />
<td>(section)number</td><br />
<td>print part/... numbers?</td><br />
</tr><br />
<tr><br />
<td>criterium</td><br />
<td>for part/chapter/section registers</td><br />
</tr><br />
<tr><br />
<td>distance</td><br />
<td>between text and pagenumber as well as indentation of nested entries</td><br />
</tr><br />
<tr><br />
<td>symbol</td><br />
<td>for pagenumber (a=a,b,c; n=1,2,3; 1=dots; 2=blocks)</td><br />
</tr><br />
<tr><br />
<td>interaction</td><br />
<td>which part should be clickable?</td><br />
</tr><br />
<tr><br />
<td>expansion</td><br />
<td>When the entry is a command, it is expanded before writing to the register</td><br />
</tr><br />
<tr><br />
<td>referencing</td><br />
<td>create references for letter sections (like "index:a")?</td><br />
</tr><br />
<tr><br />
<td>textcommand</td><br />
<td>custom command for index word</td><br />
</tr><br />
<tr><br />
<td>pagecommand</td><br />
<td>custom command for page number</td><br />
</tr><br />
<tr><br />
<td>location</td><br />
<td>?</td><br />
</tr><br />
<tr><br />
<td>compress</td><br />
<td>collapse page numbers (i.e. make “10–13” from “10,11,12,13”); “<tt>text</tt>” (new in April 2019) makes “10ff.”. You can configure the latter via {{cmd|setuplabeltext}}<tt>[en][following:singular=f.,following:plural=ff.]</tt></td><br />
</tr><br />
<tr><br />
<td>maxwidth</td><br />
<td>Set the maximum length for the text of the index entry in the registerlist (the command uses {{cmd|limitatetext}} to do this)</td><br />
</tr><br />
<tr><br />
<td>unknownreference</td><br />
<td>insert a horizontal space before and after the reference in the text if you use interactive mode to move from one entry in the text to next or previous one and there is no previous or next reference.</td><br />
</tr><br />
<tr><br />
<td>alternative</td><br />
<td>?</td><br />
</tr><br />
<tr><br />
<td>language</td><br />
<td>language code like in {{cmd|language}}, influences sorting; see definitions in {{src|sort-lan.mkiv}}</td><br />
</tr><br />
<tr><br />
<td>method</td><br />
<td>sets up the sorter used for {{cmd|placeregister}}, explained at [[Command/keyword:method]]</td><br />
</tr><br />
<tr><br />
<td>pageleft</td><br />
<td>custom command before the first page number</td><br />
</tr><br />
<tr><br />
<td>pageright</td><br />
<td>custom command after the last page number</td><br />
</tr><br />
</table><br />
<br />
Some options don’t seem to have any effect, at least in MkIV.<br />
<br />
== Example ==<br />
<br />
Here is an example for MkII:<br />
<br />
<context source="yes" text="yields"><br />
\defineregister[nickname][nicknames]<br />
<br />
\setupregister [nickname]<br />
[partnumber=no,alternative=A,criterium=all,n=3,balance=yes,pagestyle=normal]<br />
\setupregister [nickname][foto][pagestyle=bold]<br />
<br />
\starttext<br />
<br />
Text about Mamut\nickname{Mamut}.<br />
\placefigure[]<br />
{Kuba\nickname[foto::]{Kuba} on the photo.}<br />
{\externalfigure[kuba][width=0.2\textwidth]}<br />
<br />
\page<br />
And text about Kuba\nickname{Kuba}.<br />
<br />
\completenickname<br />
\stoptext <br />
<br />
</context><br />
<br />
<br />
I found it safer to put \register command after punctuation e.g.: Mamut.\nickname{Mamut} [P.K.]<br />
<br />
For the MkIV version of setting the pagestyle, and more, see the material on {{cmd|defineprocessor}} that is on [[Registers#Processors|this page]].<br />
<br />
== pageleft and pageright ==<br />
<br />
They were introduced in ConTeXt MkIV version 1.02 (2018.05.12 00:07).<br />
<br />
You can use them, for example, to move the page numbers to the right, with:<br />
<br />
<pre><br />
\setupregister[index][pageleft=\wordright\bgroup,pageright=\egroup]<br />
</pre><br />
<br />
See [http://www.mail-archive.com/ntg-context@ntg.nl/msg87812.html this thread]<br />
on the mailing list.<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Registers|setupregister]]</div>Owenhhttps://wiki.contextgarden.net/index.php?title=Command/setupregister&diff=25442Command/setupregister2020-01-01T09:20:17Z<p>Owenh: Undo revision 25441; the example is incorrect</p>
<hr />
<div>{{Reference<br />
|name=setupregister<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>setupregister</syntax><br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupregister<span class="first" >[...]</span><span class="second" style="color:red;">[...]</span><span class="third" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>singular </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:n|n]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:balance|balance]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pagestyle|pagestyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:textstyle|textstyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:indicator|indicator]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:coupling|coupling]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:check|check]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr> <tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:sectionnumber|sectionnumber]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:criterium|criterium]]</td><br />
<td>[[Command/value:section|section]] [[Command/value:local|local]] [[Command/value:all|all]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:symbol|symbol]]</td><br />
<td>1 2 ... [[Command/value:n|n]] [[Command/value:a|a]] ... [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:interaction|interaction]]</td><br />
<td>[[Command/value:pagenumber|pagenumber]] [[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:expansion|expansion]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:referencing|referencing]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:location|location]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:middle|middle]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:maxwidth|maxwidth]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:unknownreference|unknownreference]]</td><br />
<td>[[Command/value:empty|empty]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:alternative|alternative]]</td><br />
<td>[[Command/value:a|a]] [[Command/value:b|b]] [[Command/value:A|A]] [[Command/value:B|B]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:prefix|prefix]]</td><br />
<td>[[Command/value:both|both]] [[Command/value:first|first]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pagecommand|pagecommand]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:textcommand|textcommand]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:compress|compress]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:text|text]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:language|language]]</td><br />
<td>[[Command/value:language|language code]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:method|method]]</td><br />
<td>[[Command/value:default|default]] [[Command/value:before|before]] [[Command/value:after|after]] [[Command/value:first|first]] [[Command/value:last|last]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pageleft|pageleft]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pageright|pageright]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
The options are as follows:<br />
<br />
<table cellspacing="4" cellpadding="2"><br />
<tr><br />
<th>Option</th><br />
<th>Description</th><br />
</tr><br />
<tr><br />
<td>n</td><br />
<td>number of columns</td><br />
</tr><br />
<tr><br />
<td>balance</td><br />
<td>balance columns?</td><br />
</tr><br />
<tr><br />
<td>align</td><br />
<td>balance related (it’s difficult; try which combination suits you)</td><br />
</tr><br />
<tr><br />
<td>style</td><br />
<td>style of the indicator letters</td><br />
</tr><br />
<tr><br />
<td>pagestyle</td><br />
<td>style of page number</td><br />
</tr><br />
<tr><br />
<td>textstyle</td><br />
<td>style of index word</td><br />
</tr><br />
<tr><br />
<td>indicator</td><br />
<td>create letter sections?</td><br />
</tr><br />
<tr><br />
<td>coupling</td><br />
<td>special feature for screen documents (no effect in MkIV?)</td><br />
</tr><br />
<tr><br />
<td>check</td><br />
<td>set {{cmd|seeindex}} entry as entered without verifying. Default no.</td><br />
</tr><br />
<tr><br />
<td>(section)number</td><br />
<td>print part/... numbers?</td><br />
</tr><br />
<tr><br />
<td>criterium</td><br />
<td>for part/chapter/section registers</td><br />
</tr><br />
<tr><br />
<td>distance</td><br />
<td>between text and pagenumber as well as indentation of nested entries</td><br />
</tr><br />
<tr><br />
<td>symbol</td><br />
<td>for pagenumber (a=a,b,c; n=1,2,3; 1=dots; 2=blocks)</td><br />
</tr><br />
<tr><br />
<td>interaction</td><br />
<td>which part should be clickable?</td><br />
</tr><br />
<tr><br />
<td>expansion</td><br />
<td>When the entry is a command, it is expanded before writing to the register</td><br />
</tr><br />
<tr><br />
<td>referencing</td><br />
<td>create references for letter sections (like "index:a")?</td><br />
</tr><br />
<tr><br />
<td>textcommand</td><br />
<td>custom command for index word</td><br />
</tr><br />
<tr><br />
<td>pagecommand</td><br />
<td>custom command for page number</td><br />
</tr><br />
<tr><br />
<td>location</td><br />
<td>?</td><br />
</tr><br />
<tr><br />
<td>compress</td><br />
<td>collapse page numbers (i.e. make “10–13” from “10,11,12,13”); “<tt>text</tt>” (new in April 2019) makes “10ff.”. You can configure the latter via {{cmd|setuplabeltext}}<tt>[en][following:singular=f.,following:plural=ff.]</tt></td><br />
</tr><br />
<tr><br />
<td>maxwidth</td><br />
<td>Set the maximum length for the text of the index entry in the registerlist (the command uses {{cmd|limitatetext}} to do this)</td><br />
</tr><br />
<tr><br />
<td>unknownreference</td><br />
<td>insert a horizontal space before and after the reference in the text if you use interactive mode to move from one entry in the text to next or previous one and there is no previous or next reference.</td><br />
</tr><br />
<tr><br />
<td>alternative</td><br />
<td>?</td><br />
</tr><br />
<tr><br />
<td>language</td><br />
<td>language code like in {{cmd|language}}, influences sorting; see definitions in {{src|sort-lan.mkiv}}</td><br />
</tr><br />
<tr><br />
<td>method</td><br />
<td>sets up the sorter used for {{cmd|placeregister}}, explained at [[Command/keyword:method]]</td><br />
</tr><br />
<tr><br />
<td>pageleft</td><br />
<td>custom command before the first page number</td><br />
</tr><br />
<tr><br />
<td>pageright</td><br />
<td>custom command after the last page number</td><br />
</tr><br />
</table><br />
<br />
Some options don’t seem to have any effect, at least in MkIV.<br />
<br />
== Example ==<br />
<br />
Here is an example for MkII:<br />
<br />
<context source="yes" text="yields"><br />
\defineregister[nickname][nicknames]<br />
<br />
\setupregister [nickname]<br />
[partnumber=no,alternative=A,criterium=all,n=3,balance=yes,pagestyle=normal]<br />
\setupregister [nickname][foto][pagestyle=bold]<br />
<br />
\starttext<br />
<br />
Text about Mamut\nickname{Mamut}.<br />
\placefigure[]<br />
{Kuba\nickname[foto::]{Kuba} on the photo.}<br />
{\externalfigure[kuba][width=0.2\textwidth]}<br />
<br />
\page<br />
And text about Kuba\nickname{Kuba}.<br />
<br />
\completenickname<br />
\stoptext <br />
<br />
</context><br />
<br />
<br />
I found it safer to put \register command after punctuation e.g.: Mamut.\nickname{Mamut} [P.K.]<br />
<br />
For the MkIV version of setting the pagestyle, and more, see the material on {{cmd|defineprocessor}} that is on [[Registers#Prcoessors|this page]].<br />
<br />
== pageleft and pageright ==<br />
<br />
They were introduced in ConTeXt MkIV version 1.02 (2018.05.12 00:07).<br />
<br />
You can use them, for example, to move the page numbers to the right, with:<br />
<br />
<pre><br />
\setupregister[index][pageleft=\wordright\bgroup,pageright=\egroup]<br />
</pre><br />
<br />
See [http://www.mail-archive.com/ntg-context@ntg.nl/msg87812.html this thread]<br />
on the mailing list.<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Registers|setupregister]]</div>Owenhhttps://wiki.contextgarden.net/index.php?title=Command/setupregister&diff=25441Command/setupregister2020-01-01T09:16:05Z<p>Owenh: Add a pagecommand section with an example</p>
<hr />
<div>{{Reference<br />
|name=setupregister<br />
|attributes=<br />
}}<br />
<br />
== [[Help:Reference|Syntax]] (autogenerated) ==<br />
<syntax>setupregister</syntax><br />
<br />
== [[Help:Reference|Syntax]] ==<br />
<table cellspacing="4" cellpadding="2" class="cmd"><br />
<tr><br />
<td colspan="2" class="cmd">\setupregister<span class="first" >[...]</span><span class="second" style="color:red;">[...]</span><span class="third" >[...,...=...,...]</span></td><br />
</tr><br />
<tr valign="top" class="first"><br />
<td class="cmd">[...]</td><br />
<td>singular </td><br />
</tr><br />
<tr valign="top" class="second"><br />
<td class="cmd">[...]</td><br />
<td>name </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:n|n]]</td><br />
<td>[[Command/value:number|number]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:balance|balance]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:align|align]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:style|style]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pagestyle|pagestyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:textstyle|textstyle]]</td><br />
<td>[[Command/value:normal|normal]] [[Command/value:bold|bold]] [[Command/value:slanted|slanted]] [[Command/value:boldslanted|boldslanted]] [[Command/value:type|type]] [[Command/value:cap|cap]] [[Command/value:small...|small...]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:indicator|indicator]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:coupling|coupling]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:check|check]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr> <tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:sectionnumber|sectionnumber]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:criterium|criterium]]</td><br />
<td>[[Command/value:section|section]] [[Command/value:local|local]] [[Command/value:all|all]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:distance|distance]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:symbol|symbol]]</td><br />
<td>1 2 ... [[Command/value:n|n]] [[Command/value:a|a]] ... [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:interaction|interaction]]</td><br />
<td>[[Command/value:pagenumber|pagenumber]] [[Command/value:text|text]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:expansion|expansion]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:command|command]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:referencing|referencing]]</td><br />
<td>[[Command/value:on|on]] [[Command/value:off|off]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:location|location]]</td><br />
<td>[[Command/value:left|left]] [[Command/value:middle|middle]] [[Command/value:right|right]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:maxwidth|maxwidth]]</td><br />
<td>[[Command/value:dimension|dimension]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:unknownreference|unknownreference]]</td><br />
<td>[[Command/value:empty|empty]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:alternative|alternative]]</td><br />
<td>[[Command/value:a|a]] [[Command/value:b|b]] [[Command/value:A|A]] [[Command/value:B|B]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:prefix|prefix]]</td><br />
<td>[[Command/value:both|both]] [[Command/value:first|first]] [[Command/value:none|none]] </td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pagecommand|pagecommand]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:textcommand|textcommand]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:compress|compress]]</td><br />
<td>[[Command/value:yes|yes]] [[Command/value:no|no]] [[Command/value:text|text]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:language|language]]</td><br />
<td>[[Command/value:language|language code]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:method|method]]</td><br />
<td>[[Command/value:default|default]] [[Command/value:before|before]] [[Command/value:after|after]] [[Command/value:first|first]] [[Command/value:last|last]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pageleft|pageleft]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
<tr valign="top" class="third"><br />
<td class="cmd">[[Command/keyword:pageright|pageright]]</td><br />
<td>[[Command/value:command|command]]</td><br />
</tr><br />
</table><br />
<br />
== Description == <br />
<br />
The options are as follows:<br />
<br />
<table cellspacing="4" cellpadding="2"><br />
<tr><br />
<th>Option</th><br />
<th>Description</th><br />
</tr><br />
<tr><br />
<td>n</td><br />
<td>number of columns</td><br />
</tr><br />
<tr><br />
<td>balance</td><br />
<td>balance columns?</td><br />
</tr><br />
<tr><br />
<td>align</td><br />
<td>balance related (it’s difficult; try which combination suits you)</td><br />
</tr><br />
<tr><br />
<td>style</td><br />
<td>style of the indicator letters</td><br />
</tr><br />
<tr><br />
<td>pagestyle</td><br />
<td>style of page number</td><br />
</tr><br />
<tr><br />
<td>textstyle</td><br />
<td>style of index word</td><br />
</tr><br />
<tr><br />
<td>indicator</td><br />
<td>create letter sections?</td><br />
</tr><br />
<tr><br />
<td>coupling</td><br />
<td>special feature for screen documents (no effect in MkIV?)</td><br />
</tr><br />
<tr><br />
<td>check</td><br />
<td>set {{cmd|seeindex}} entry as entered without verifying. Default no.</td><br />
</tr><br />
<tr><br />
<td>(section)number</td><br />
<td>print part/... numbers?</td><br />
</tr><br />
<tr><br />
<td>criterium</td><br />
<td>for part/chapter/section registers</td><br />
</tr><br />
<tr><br />
<td>distance</td><br />
<td>between text and pagenumber as well as indentation of nested entries</td><br />
</tr><br />
<tr><br />
<td>symbol</td><br />
<td>for pagenumber (a=a,b,c; n=1,2,3; 1=dots; 2=blocks)</td><br />
</tr><br />
<tr><br />
<td>interaction</td><br />
<td>which part should be clickable?</td><br />
</tr><br />
<tr><br />
<td>expansion</td><br />
<td>When the entry is a command, it is expanded before writing to the register</td><br />
</tr><br />
<tr><br />
<td>referencing</td><br />
<td>create references for letter sections (like "index:a")?</td><br />
</tr><br />
<tr><br />
<td>textcommand</td><br />
<td>custom command for index word</td><br />
</tr><br />
<tr><br />
<td>pagecommand</td><br />
<td>custom command for page number</td><br />
</tr><br />
<tr><br />
<td>location</td><br />
<td>?</td><br />
</tr><br />
<tr><br />
<td>compress</td><br />
<td>collapse page numbers (i.e. make “10–13” from “10,11,12,13”); “<tt>text</tt>” (new in April 2019) makes “10ff.”. You can configure the latter via {{cmd|setuplabeltext}}<tt>[en][following:singular=f.,following:plural=ff.]</tt></td><br />
</tr><br />
<tr><br />
<td>maxwidth</td><br />
<td>Set the maximum length for the text of the index entry in the registerlist (the command uses {{cmd|limitatetext}} to do this)</td><br />
</tr><br />
<tr><br />
<td>unknownreference</td><br />
<td>insert a horizontal space before and after the reference in the text if you use interactive mode to move from one entry in the text to next or previous one and there is no previous or next reference.</td><br />
</tr><br />
<tr><br />
<td>alternative</td><br />
<td>?</td><br />
</tr><br />
<tr><br />
<td>language</td><br />
<td>language code like in {{cmd|language}}, influences sorting; see definitions in {{src|sort-lan.mkiv}}</td><br />
</tr><br />
<tr><br />
<td>method</td><br />
<td>sets up the sorter used for {{cmd|placeregister}}, explained at [[Command/keyword:method]]</td><br />
</tr><br />
<tr><br />
<td>pageleft</td><br />
<td>custom command before the first page number</td><br />
</tr><br />
<tr><br />
<td>pageright</td><br />
<td>custom command after the last page number</td><br />
</tr><br />
</table><br />
<br />
Some options don’t seem to have any effect, at least in MkIV.<br />
<br />
== Example ==<br />
<br />
Here is an example for MkII:<br />
<br />
<context source="yes" text="yields"><br />
\defineregister[nickname][nicknames]<br />
<br />
\setupregister [nickname]<br />
[partnumber=no,alternative=A,criterium=all,n=3,balance=yes,pagestyle=normal]<br />
\setupregister [nickname][foto][pagestyle=bold]<br />
<br />
\starttext<br />
<br />
Text about Mamut\nickname{Mamut}.<br />
\placefigure[]<br />
{Kuba\nickname[foto::]{Kuba} on the photo.}<br />
{\externalfigure[kuba][width=0.2\textwidth]}<br />
<br />
\page<br />
And text about Kuba\nickname{Kuba}.<br />
<br />
\completenickname<br />
\stoptext <br />
<br />
</context><br />
<br />
<br />
I found it safer to put \register command after punctuation e.g.: Mamut.\nickname{Mamut} [P.K.]<br />
<br />
For the MkIV version of setting the pagestyle, and more, see the material on {{cmd|defineprocessor}} that is on [[Registers#Prcoessors|this page]].<br />
<br />
== pagecommand ==<br />
<br />
A pagecommand can be used to move page numbers to the right in the index listing. It works for me even for entries where the text is long and has wrapped, unlike the pageleft/pageright example below.<br />
<br />
<pre><br />
\setupregister[index][pagecommand=\wordright]<br />
</pre><br />
<br />
== pageleft and pageright ==<br />
<br />
They were introduced in ConTeXt MkIV version 1.02 (2018.05.12 00:07).<br />
<br />
You can use them, for example, to move the page numbers to the right, with:<br />
<br />
<pre><br />
\setupregister[index][pageleft=\wordright\bgroup,pageright=\egroup]<br />
</pre><br />
<br />
See [http://www.mail-archive.com/ntg-context@ntg.nl/msg87812.html this thread]<br />
on the mailing list.<br />
<br />
== See also ==<br />
<!-- something like {{cmd|goto}} --><br />
<br />
== Help from ConTeXt-Mailinglist/Forum ==<br />
All issues with:<br />
{{Forum|{{SUBPAGENAME}}}}<br />
<br />
[[Category:Command/Registers|setupregister]]</div>Owenh