Changes

Jump to navigation Jump to search
2,505 bytes added ,  11:28, 30 August 2020
m
fix link to register command
< [[Structurals]] | [[References]] > (It's also in the manual at "Registers")
 
=Basics=
Use indexes as follows:
* To add the word "word", use: <{{cmd>|index</cmd>}}<tt>{word}word</tt>* To sort a word (such as <cmd>"ConTeXt</cmd> " under "C"), use: <{{cmd>|index</cmd>}}<tt>[CONTEXT]{\ConTeXt}</tt>* To use multi-levels (up to three), use a plus symbol: <{{cmd>|index</cmd>}}<tt>{beans+baked}</tt>* To cross-reference items, use <{{cmd>|seeindex</cmd>}}: <{{cmd>|seeindex</cmd>}}<tt>[CONTEXT]{\ConTeXt}{\TeX}</tt>* To include the index without a title, use: <{{cmd>|placeindex</cmd>}}* To include the index with a title, use: {{cmd|completeindex}} Note that the {{cmd|completeindex}} command might not work correctly. In such situations you can use: {{cmd|subject}}<cmdtt>completeindex{Index}</tt> {{cmd>|placeindex}}
==Example==
<context mode=mkiv source=yes>
\setuppapersize[A10][A7,landscape]
 
\setuppaper[nx=4, ny=2]
\setuplayout[location=middle,marking=on]
\setuparranging [XY]
 
\definefontfeature [textfigures] [onum=yes]
finally, ''pagestyle'' sets the page number references (slanted).
=== Individiual Individual Entries ===
Better granularity regarding the formatting of individual entries can
be achieved through the ''three-argument'' version of
=More Registers=
<{{cmd>|index</cmd> }} is only one special case of <cmd>{{gen|register</cmd>}}. You can define as much different registers as you like:
<{{cmd>|defineregister</cmd>}}<tt>[singular name][plural name]</tt>, e.g.
<texcode>
\defineregister[mouse][mice]
=Tricks=
* <A register per chapter: {{cmd>startregister</cmd><tt>[index][mymouse]{mouse|placeregister}}</tt> ... <cmd>stopregister</cmd><tt>[index][mymousecriterium=chapter]</tt>: to mark several pages for the same entry; becomes e.g. "mouse 12-* Uppercase-16". Note that if you have two or more of these ranges, you need them to have different <tt>[key]</tt> values to stop the system treating them as part of a great big range. So, use <cmd>startregister</cmd><tt>[letter index][mymouse1]heads: {{mouse}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse1]</tt> and then <cmd>startregister</cmd><tt>[index][mymouse2]{mouse|setupregister}</tt> ... <cmd>stopregister</cmd><tt>[index][mymouse2]</tt> to get two independent ranges in the list. <cmd>startregister</cmd> takes four arguments, of which two are mandatory: <cmd>startregister</cmd><tt>[NAME_OF_REGISTER]{ENTRY_NAME}</tt>. The other arguments are <tt>[KEY_FOR_RANGE]</tt> and <tt>[KEY_FOR_SORTING]</tt>. To give an example: <cmd>startregister</cmd><tt>[index][levi][Levi-Strauss]{Lévi|-|Strauss}</tt>. This will start 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." To mark the end of the rangen=2, you write <cmd>stopregister</cmd><tt>[index][levi]</tt>.* Automatically collapse page ranges: <cmd>placeindex[compresscommand=yes]</cmd>* <cmd>writetoregister</cmd> (sometimes needed to avoid macro expansion issues)* A register per chapter: <cmd>placeregister</cmd><tt>[index][criterium\Word,style=chapternormal]</tt>
* 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.!
* {{cmd|writetoregister}} (sometimes needed to avoid macro expansion issues, '''MkII only''')  == Collapse Page Numbers == 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.There are two ways to collapse page numbers: # {{cmd|setupregister}}[compress=yes] # Enclose several pages in {{cmd|startregister}} … {{cmd|stopregister}}: <texcode>\startregister[index][Keycode1]{Keyword} % lots of text\stopregister[index][Keycode1]</texcode> The first parameter of {{cmd|startregister}} is the name that of the index – "index" is the default index, but you will get in might use your self defined registers as well. The second parameter is a keyword to distinguish several overlapping range-entries. It’s also possible to use the head sorting parameter: <texcode>\startregister[index][levi][Levi-Strauss]{Lévi|-|Strauss} % lots of text\completeregister can be set with: \setupheadtextstopregister[register=My new index][levi]* Get uppercase-letter heads: <cmd/texcode> This will create a range with the key <tt>setupregisterlevi</tt> which will put the entry "Lévi-Strauss" in the register "index" (the "normal" register) and sort it under "Levi-Strauss." == Rename Register Heading == Change the {{cmd>|completeregister}} heading using the {{cmd|setupheadtext}} command. For example: <ttcontext source="yes">\defineregister[indexphotographer][] \setupregister[photographer][n indicator=2no,command=] \Word,stylesetupheadtext[photographer=normalCredits\starttext \photographer{Yousuf Karsh}  \completephotographer\stoptext </ttcontext>* == Alphabetical Headers ==  The headers in the registers (subsequent letters of the alphabet) can be disabled by <{{cmd>|setupregister</cmd>}}<tt>[register][indicator=no]</tt>; the . 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). =Sorting= The sorting of the index is influenced by the current [[Languages#Language_tags|language tag]]. You can override that with the {{key|language}} key of {{cmd|setupregister}}.There are a few additional "languages" for sorting, as defined in {{src|sort-lan.mkiv}}:* <tt>DIN 5007-1</tt> (German) normal sorting, ß = ss* <tt>DIN 5007-2</tt> (German) phonebook sorting, ä = ae, ö = oe, ü = ue, ß = ss* <tt>Duden</tt> (German) ß = s* <tt>de-AT</tt> (Austrian German) phonebook sorting; umlauts after base vocal (a, ä, o, ö, u, ü) * <tt>cu</tt> (Church Slavonic)* <tt>ocs-scn</tt> (Scientific Old Slavonic transcription)* <tt>ru-iso9</tt> (Russian transcription) Additionally, there’s the {{key|method}} key that influences the order of upper-/lowercase and diacritics: The details lay in a rather obscure set of methods (see {{src|sort-ini.lua|source}}), for which the following presets are defined: * {{key|default}} = {{key|"zc,pc,zm,pm,uc"}} (uppercase like lowercase, diacritics separate)* {{key|before}} = {{key|"mm,mc,uc"}} (upper before lower, diacritics ignored)* {{key|after}} = {{key|"pm,mc,uc}} (lower before upper, diacritics ignored)* {{key|first}} = {{key|"pc,mm,uc"}} (lower before upper, diacritics separate)* {{key|last}} = {{key|"mc,mm,uc"}} (upper before lower, diacritics separate)* If you don’t set the sorting method, the preset "first" ist used (and not "default").* There’s no preset for the combination "uppercase like lowercase, diacritics ignored", try {{key|"zm,pm,zc,zm,uc"}}.* The sorting is also influenced by the current language or the language setting in {{cmd|setupregister}}. e.g.<texcode>\setupregister[index][ n=1, language=Duden, method={zm,pm,zc,zm,uc},]</texcode>
=Coupled Registers=
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.
Enable it with <{{cmd>|setupregister</cmd>}}<tt>[index][coupling=yes]</tt>.Substitute <{{cmd>|index</cmd> }} with <{{cmd>|coupledindex</cmd> }} and enjoy!
=Impact on vertical spacing=
In some situations, placing an <{{cmd>|index</cmd> }} (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</cmd> }} as shown below (needs a ConTeXt version dated after 14th Dec 2005):
<texcode>
</texcode>
Note the two possible definitions, and the pitfalls with each one. If you are still having trouble with specific <{{cmd>|index</cmd> }} 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</cmd>}}, or it wrapped in one of the two possible <{{cmd>|doflushatpar</cmd>}}s, should solve any problem. =Impact on hyphenation, and on line breaking as a consequence= {{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: <texcode>This is an indexed term\wordboundary\index{Term}. % instead of simply ... term\index{Term}.</texcode> 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: <texcode>This is an indexed term.</texcode> [[Category:Basics]]

Navigation menu