# Elementname: `Makeindex`

## Description

Sort and split a list of elements to make an index.

Allowed attributes: pagenumber, section, select, sortkey

Child elements: (none)

Parent elements: Element, SaveDataset

### Attributes

pagenumber (text, optional, since version 2.7.11)

  The name of the attribute that holds the page numbers. Defaults to 'page'.

section (text)

  Create an XML-element with this name for every section (letter) in the index.

select (XPath Expression)

  The xpath expression ($variable) that holds the element structure for the index.

sortkey (text)

  The name of the attribute holding the indexentry (that should be sorted).

## Example

Index generation works in two steps: First, collect all the entries in a Element structure, then, while saving the generated structure, sort the keys and group them with this command.

      <Record element="data">
        <LoadDataset name="index" />
        <SetVariable variable="indexentries">
          <Element name="indexentry">
            <Attribute name="name" select="'Home'" />
            <Attribute name="page" select="1" />
          </Element>
          <Element name="indexentry">
            <Attribute name="name" select="'House'" />
            <Attribute name="page" select="2" />
          </Element>
          <Element name="indexentry">
            <Attribute name="name" select="'Hello'" />
            <Attribute name="page" select="3" />
          </Element>
          <Element name="indexentry">
            <Attribute name="name" select="'Garage'" />
            <Attribute name="page" select="4" />
          </Element>
        </SetVariable>
        <SaveDataset filename="index" elementname="Index">
          <Makeindex select="$indexentries" sortkey="name" section="part" />
        </SaveDataset>
      </Record>

      <Record element="Index">
        <ForAll select="part">
          <PlaceObject>
            <Table width="3" stretch="max">
              <Tr>
                <Td border-bottom="0.4pt" colspan="2">
                  <Paragraph><Value select="@name" /></Paragraph>
                </Td>
              </Tr>
              <ForAll select="indexentry">
                <Tr>
                  <Td>
                    <Paragraph><Value select="@name" /></Paragraph>
                  </Td>
                  <Td>
                    <Paragraph><Value select="@page" /></Paragraph>
                  </Td>
                </Tr>
              </ForAll>
            </Table>
          </PlaceObject>
        </ForAll>
      </Record>

## See also

SaveDataset

# Commands

- A
- Action
- AtPageCreation
- AtPageShipout
- Attribute
- B
- Barcode
- Bold
- BoldItalic
- Bookmark
- Box
- Br
- Case
- Circle
- Color
- Column
- Columns
- Compatibility
- Contents
- Copy-of
- DefineColor
- DefineFontalias
- DefineFontfamily
- DefineTextformat
- Element
- Fontface
- ForAll
- Frame
- Grid
- Group
- Groupcontents
- HSpace
- Hyphenation
- I
- Image
- Include
- Initial
- InsertPages
- Italic
- Layout
- Li
- LoadDataset
- LoadFontfile
- Loop
- Makeindex
- Margin
- Mark
- Message
- NewPage
- NextFrame
- NextRow
- NoBreak
- Ol
- Options
- Otherwise
- Output
- Overlay
- PDFOptions
- Pageformat
- Pagetype
- Paragraph
- PlaceObject
- Position
- PositioningArea
- PositioningFrame
- ProcessNode
- Record
- Regular
- Rule
- SaveDataset
- SavePages
- SetGrid
- SetVariable
- SortSequence
- Stylesheet
- Sub
- Sup
- Switch
- Table
- Tablefoot
- Tablehead
- Tablerule
- Td
- Text
- Textblock
- Tr
- Trace
- Transformation
- U
- URL
- Ul
- Until
- VSpace
- Value
- While

Version: 3.0.1 | Start page | Command reference | Other language: German