References notes and floats/Registers and index/How-to guides/Sorting multilingual registers

From Wiki
Jump to navigation Jump to search


Indexes and registers in ConTeXt  ·  Overview  ·  Tutorial  ·  How-to guides  ·  Previous: Creating local and sectional registers  ·  Sorting multilingual registers  ·  Next: Typesetting bidirectional registers

🚧 This page is under construction. Feel free to correct, expand, and improve it; its structure and examples may still change.

1. Goal

Use this guide when an index or named register contains entries whose correct order depends on language, letter case, diacritics, transliteration, or a displayed form that is unsuitable for sorting.

By the end of the guide, you will be able to:

  • assign a sorting language to a register;
  • distinguish the language of the document from the language used to sort a register;
  • choose a general collation method;
  • provide an explicit sorting key for an exceptional entry;
  • decide when several language-specific registers are clearer than one mixed register;
  • test the resulting order with the exact ConTeXt version used for publication.

Sorting is not the same as typesetting

A register may be typeset in one language but sorted according to another language's conventions.

Likewise, language-sensitive sorting does not by itself change text direction, paragraph alignment, or the physical order of columns. Those questions are treated in Typesetting bidirectional registers.

2. Before you begin

You should already know how to:

  • create an ordinary index entry with \index;
  • provide an explicit sorting key;
  • configure a register with \setupregister;
  • place an index with \placeindex or \completeindex.

See:

Use UTF-8 source files and select fonts that contain all the characters required by the entries.

3. Understand the four relevant decisions

Multilingual register work usually involves four separate decisions.

Decision What it controls Typical mechanism
Main document language Labels, hyphenation, quotations, and other language-dependent document behaviour \mainlanguage[...]
Register sorting language The alphabet and language-sensitive collation rules used for the register language=... in \setupregister
Sorting method The general comparison strategy used within the selected language method=... in \setupregister
Entry-specific sorting key The position of one exceptional displayed entry Optional argument of the entry command

Do not solve every problem with an explicit key

An explicit sorting key is appropriate for an exceptional entry, such as a command name, a decorated form, or a personal name that must be sorted under a different element.

When an entire register follows one language's collation rules, configure the register's language and method instead of assigning a manual key to every entry.

4. Set the sorting language of a register

Configure the predefined index with:

\setupregister
  [index]
  [language=fr,
   method=default]

This tells ConTeXt to sort the register using the selected language and the default method available for that language.

The main language of the document may be set separately:

\mainlanguage[en]

\setupregister
  [index]
  [language=fr,
   method=default]

In this example, the document is principally English, while the index is sorted as French data.

Practical rule

Set the register language according to the language of the entries and the editorial sorting convention, not merely according to the language of the surrounding prose.

5. Test accents and letter case

Do not assume that an English test list is sufficient for a French, German, Czech, Russian, Greek, or other language-sensitive register.

Create a small diagnostic document containing:

  • unaccented and accented initial letters;
  • uppercase and lowercase forms;
  • composed characters used in the publication;
  • names beginning with particles;
  • entries containing punctuation or macros.

For example:

\setuppapersize[A6]

\mainlanguage[en]

\setupbodyfont
  [libertinus,10pt]

\setupregister
  [index]
  [language=fr,
   method=default,
   n=1]

\starttext

École\index{École}

Ecole\index{Ecole}

Étienne\index{Étienne}

Eugène\index{Eugène}

À propos\index{À propos}

Avenir\index{Avenir}

Œuvre\index{Œuvre}

Ouvrage\index{Ouvrage}

\subject{Index}

\placeindex

\stoptext

Compile the example and inspect:

  1. the order of accented and unaccented forms;
  2. the indicator under which each entry appears;
  3. the treatment of uppercase and lowercase;
  4. the position of ligatures and language-specific characters.

Use representative data

The exact result depends on the selected language, method, characters, and current ConTeXt implementation.

A diagnostic list should therefore be built from real names and terms taken from the publication rather than from a generic alphabet alone.

6. Supply an explicit sorting key for one entry

The optional argument separates the sorting form from the displayed form:

\index[CONTEXT]{\ConTeXt}

The reader sees \ConTeXt, while the entry is sorted under CONTEXT.

The same technique is useful when a displayed entry contains:

  • a formatting command;
  • punctuation that should not determine its position;
  • an abbreviation that should sort under an expanded form;
  • a personal name displayed in natural order but sorted by family name;
  • a title beginning with an article that should be ignored.

Examples:

\index[Plato, Republic]{Plato, \emph{Republic}}

\index[Republic, The]{\emph{The Republic}}

\index[Descartes, René]{René Descartes}

Displayed form and sorting form

The mandatory argument is the entry printed for the reader.

The optional argument is the normalized form used to determine its place in the register.

Changing the sorting key does not have to change the typography of the displayed entry.

7. Combine language settings and explicit keys

A language setting controls the general order of the register. Explicit keys handle exceptions within that order.

The following MWE combines both mechanisms:

\setuppapersize[A6]

\mainlanguage[en]

\setupbodyfont
  [libertinus,10pt]

\setupregister
  [index]
  [language=fr,
   method=default,
   n=1]

\starttext

René Descartes
  \index[Descartes, René]{René Descartes}

Émile Durkheim
  \index[Durkheim, Émile]{Émile Durkheim}

The \emph{Republic}
  \index[Republic, The]{\emph{The Republic}}

\ConTeXt
  \index[CONTEXT]{\ConTeXt}

Œuvre
  \index{Œuvre}

Écriture
  \index{Écriture}

\subject{Index}

\placeindex

\stoptext

In this example:

  • French language settings determine the general collation;
  • personal names are normalized as “family name, given name”;
  • the article in “The Republic” does not control the entry's position;
  • the macro \ConTeXt is sorted by a plain-text key.

8. Sort a named register independently

Each named register can have its own language and method.

For example:

\defineregister[persons]
\defineregister[works]

\setupregister
  [persons]
  [language=fr,
   method=default]

\setupregister
  [works]
  [language=en,
   method=default]

You can then add and place entries independently:

\persons[Descartes, René]{René Descartes}
\works[Republic, The]{\emph{The Republic}}

\placepersons
\placeworks

This is useful when a publication contains editorial categories governed by different conventions.

Prefer separate registers when their conventions differ

Separate registers are often clearer when personal names, titles, source passages, and technical terms require different sorting languages or normalization rules.

9. Decide how to handle several languages or scripts

A publication containing several languages does not automatically require one mixed register.

Choose among three strategies.

9.1. One register with one dominant collation

Use one register when:

  • all entries are expected to follow one editorial alphabet;
  • transliteration provides a common sorting basis;
  • occasional exceptional entries can be handled with explicit keys.

Example:

\index[Platon]{Πλάτων}
\index[Aristote]{Ἀριστοτέλης}

The Greek forms are displayed, while French transliterations determine their positions.

9.2. Separate registers for different languages or scripts

Use separate named registers when:

  • each language should follow its own alphabet;
  • readers are expected to consult language-specific lists;
  • mixing scripts would make indicators or ordering unclear.

For example:

\defineregister[latinterms]
\defineregister[greekterms]

\setupregister
  [latinterms]
  [language=la,
   method=default]

\setupregister
  [greekterms]
  [language=el,
   method=default]

9.3. One displayed register with editorially normalized keys

Use one register with normalized keys when the publication requires a single navigational sequence, but the displayed forms belong to several scripts.

This strategy is editorial rather than automatic: document the transliteration or normalization system and apply it consistently.

A mixed-script index has no neutral order

Putting entries from several writing systems into one register requires an editorial decision about their common order.

ConTeXt can apply the keys and language settings you supply, but it cannot decide whether Greek, Cyrillic, Hebrew, Arabic, Latin, or transliterated forms should govern the final sequence.

10. Keep transliteration and normalization consistent

When explicit keys are used for non-Latin scripts or decorated forms:

  1. choose one transliteration or normalization standard;
  2. preserve the same treatment of particles, articles, punctuation, and spaces;
  3. record the convention in the project environment or editorial documentation;
  4. review entries for duplicate concepts hidden behind variant keys;
  5. test that cross-references use compatible sorting forms.

A simple project convention might be documented as:

% Greek personal names:
% displayed in Greek;
% sorted by consistent Latin transliteration;
% accents omitted from sorting keys;
% family or conventional dictionary form used consistently.

For a multi-file publication, centralize register definitions and conventions as described in:

11. Troubleshooting

Problem Likely cause What to check
Accented entries appear in an unexpected position The register language does not match the entries, or the chosen method behaves differently from the expected editorial convention Check language, method, source normalization, and the current ConTeXt version
A macro-based entry sorts under punctuation or a command name The displayed form is being used as the sorting form Add an explicit plain-text sorting key
Personal names sort under given names The natural displayed form is also being used as the key Supply a “family name, given name” sorting key
The same term appears twice Variant spellings, composed characters, or inconsistent keys have created distinct entries Normalize the source and make sorting keys consistent
Entries from several scripts appear in an unclear order One mixed register has no defined common collation policy Choose a dominant key system or create separate named registers
The text direction is wrong Sorting configuration does not control typesetting direction Continue with the bidirectional-register how-to

12. What this guide has established

This guide has shown that:

  1. the main document language and the register sorting language are separate settings;
  2. language establishes the language-sensitive basis of the register;
  3. method selects the general collation strategy;
  4. explicit sorting keys solve exceptional entry-level problems;
  5. named registers may use different language and sorting settings;
  6. mixed-language and mixed-script indexes require an explicit editorial policy;
  7. transliteration, normalization, text direction, and column order are distinct issues;
  8. realistic diagnostic entries should be tested with the current ConTeXt version.

The central rule is: configure the general language policy once, then use explicit sorting keys only where the displayed form cannot safely determine its own position.

13. Next step

If the register contains Arabic, Hebrew, or other right-to-left material, continue with:

That guide treats:

  • right-to-left entry direction;
  • mixed left-to-right and right-to-left text;
  • alignment;
  • punctuation and page references;
  • the physical order of multiple columns.

Indexes and registers in ConTeXt  ·  Overview  ·  Tutorial  ·  How-to guides  ·  Previous: Creating local and sectional registers  ·  Sorting multilingual registers  ·  Next: Typesetting bidirectional registers