Go to page:

Search:   Help



LyX documentation


Shared groups



Categories: Index
<< | Page list | >>

This page is for adding tips about writing an index. feel free to add to it.

Note: A good starting point is the User's Guide, section 6.6, where index handling is described (also, many of the things described here are already documented in the User's Guide).


Discussions on the users' list:

Index entries

In LyX, index entries are added with Insert --> Index Entry. This will create a collapsible inset (similar to a footnote) that marks the index entry in your document.

Click on that box to open and fine-tune your entry. In markup, you would have to write


for any entry that you want to appear in your index. Since LyX takes care of the \index command and the braces, you need to specify the 'foo' part only.

Here is a handy list of arguments you can put in LyX's index entry box, and of what they produce. To avoid struggling, it should be noted that:

  • the given page numbers in the following examples are, of course, entirely fictitious.
  • braces have to be put into a Tex-Code environment: Insert --> Tex Code.
ExampleIndex entryComment
PeterPeter, 8Plain entry
Peter!PanPan, 9Subentry under 'Peter'
Paul@\textsl{Paul}Paul, 7Formatted entry
Mary@\textbf{Mary}Mary, 2Same as above
Joe|textbfJoe, 4Formatted page number
Jenny|textitJenny, 6Same as above
ecole@\'ecoleÚcole, 1Handling of accents
Jimmy|( Specifying a page range: start
Jimmy|)Jimmy, 3--9Specifying a page range: end
Peter|(textbf Specifying a page range with formatted page number: start
Peter|)Peter, 3--9Specifying a page range with formatted page number: end
Jimmy|see{Joe}Jimmy, see JoeCross-reference
Joe|seealso{Paul}Joe, see also PaulCross-reference with seealso
Aermel@─rmel─rmel, 62Entry with Umlauts, will be sorted correctly

The Index List is added to your document with Insert --> List/TOC --> Index List. This will create an Index box . If you want to modify the font face or font size of the printed index, select the Index box and then apply the desired font as usual in the Text Style dialogue.

The index heading can be changed by adding the command \renewcommand{\indexname}{foo} to the preamble of your document, with 'foo' as the new heading. Likewise, you can modify how the see output looks. For example, \renewcommand{\seename}{s. } will produce "Jimmy, s. Joe" as output.

With the KOMA classes, it is also possible to put a preamble right before the index entries. To do so, add \setindexpreamble{foo} to your document preamble.

Tips for creating indexes

Multiple indices

In some fields, it is common to have more than one index; for instance, in the field of law, one often needs a Table of Cases and Table of Statutes as well as a regular index. In the humanities, the index is often split into an index of terms (index rerum) and an index of names (index nominum).

LyX 2.0 finally introduces native support for multiple indices (see http://wiki.lyx.org/LyX/NewInLyX20#indices).

In earlier versions (up to LyX 1.6.x), multiple indices require manual fiddling. Here is some short HowTo.

a.) Using the Memoir class

This simple example is to add one new index called index2 with the Memoir class:

  1. Make sure you are using Memoir class (Document -> Settings -> Document Class)
  2. In your preamble (Document -> Settings -> LaTeX preamble), insert the following code:
    \renewcommand{\indexname}{My second index}
  3. To insert index entries for the second index, use \secondindex{your index entry} in ERT.
  4. To insert the index into your document, use \secondindexpage in ERT.
  5. Create a shell script similar to this:
    MAKEINDEX=`which makeindex`
    $MAKEINDEX -o secondindex.ind secondindex.idx
  6. Change Preferences -> Outputs -> LaTeX -> External applications -> Index command to point to the shell script that you created in the previous step.

b.) Using other classes

With other classes, the splitindex package can be used. For example, we want to have an additional "Index of Names":

  1. Make sure the splitindex package is installed
  2. Change Preferences -> Outputs -> LaTeX -> External applications -> Index command to splitindex -m 'makeindex -c -q' (if you use different makeindex options or xindy, you can adjust the command accordingly, for instance splitindex -m 'texindy -L german-duden -M book-order' works as well).
  3. In your preamble (Document -> Settings -> LaTeX preamble), insert the following code:
    \newindex[Index of Names]{nom}
  4. Insert the Entries to the main index as usual (Insert>Index Entry), and insert the index itself as usual (Insert>Lists & TOC>Index List).
  5. As for the second index, add in TeX mode at the place where the index shall be printed: \printindex[nom]
  6. Insert the entries that should go to the Index of names in TeX mode: \sindex[nom]{Knuth, Donald E.}

If you're running LyX 1.6, you can also use this module. Save it in the layouts folder of your personal LyX directory, run Tools>Reconfigure in LyX, restart and then select "Index of Names" from Document>Settings>Modules. Then you can insert entries to the Index of Names via Insert>Custom Insets>NameIndex. If you need a different (or an additional) Index, change the module file accordingly.

Nested Index Entries

(Tip from Chris Lale.)

Note: This feature is also described in the User Guide, section 6.6.2.

Insert the index entries in the normal way

Insert -> Index Entry..

Separate the entry text from the sub-entry text with an exclamation mark ("!").

Insert the index list at the end of the document as usual.

Insert -> Lists & TOC -> Index List

For instance, these index entries

Synaptic!menu bar
Synaptic!tool bar
Synaptic!tool bar!location

produce this index list

Synaptic, 2
   menu bar, 2
   tool bar, 2
      location, 2

Semi-automatic indexing

Despite the problematics of automatically generated indexes (see the discussion below), here's a package that allows you to do this, provided that you use XeTeX: http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=xeindex

Emails from the thread that started this page

This page was started from this thread. Below are some of the mails in the thread.

Ed Sawicki:

I love LyX but I dislike the way an index is created.
The indexed words are turned into boxes on the screen that
I find annoying. I'd also like a bit more automation to make
indexing easier. I'm wondering whether I'm overlooking a
capability in LyX and whether someone has already created a

If there's no other solution, here's what I plan:

1. When the book is finished, convert it to ASCII and LaTex.
2. From the ASCII file, create a word list that consists of
   all the words in the book. Pare this list down to only the
   words that should be indexed using some automation and manual
   inspection and editing.
3. Add phrases that should be indexed to the list. I'll have to
   maintain a list of phrases manually as I write the book.
4. Have a script automatically insert indexing markup into the
   LaTeX file.
5. Fix any problems with manual editing of the LaTeX file.
6. Use the marked up LaTeX file to print the final book.

Whenever changes to the book are needed, I modify the LyX
version of the book. When finished, I go to step 1.


Seems to me that a good index need more than simply indexing
words and that index substructuring and typographic control
is quite important, and should be made while writing.
The contents of the index tags is quite important IMHO

Helge Hafting:

Be careful with "fully automated indexing".  Indexing
every page where some word occur usually makes for
a poor index.  It is easy, because all you need is to
pick the words and let the computer do the rest.  But
the result is rarely good, as a normal text contain
many indexable words in places people aren't interested
in looking up.  

I've got the following advice on index creation:
1. Try to not index more than three locations for a word.
   People simply don't try 20 locations, so it is
   a waste *even* if all of them are equally relevant. 
   There may be exceptions to this depending on what you're
   writing - this is the general advice.
2. Avoid foo:56,57,58,59 (or foo:56--59)  Simply
   index the start of the range, people will go there
   and read through it.
3. Index only the important places a word is used.
   People looking in the index for "foo" want to
   find the important pieces about "foo", not everytime the
   word was used.

This advice is more work and stands in the way of
automation.  Still, it usually results in better books.


Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2020-12-26 22:45 CET