# How to add an entry to theindex at item level without page number?

In my index, I would like to group certain items under a group entry name. Sinmce I already use the three levels available (item, subitem, subsubitem), I tried to create an entry without page number. In the example below, "Weird Languages" should not be followed by a page number, because it is intended as the class title of what follows.

 \documentclass[12pt,twoside,a4paper,openright]{book}

\usepackage{xunicode}
\usepackage{imakeidx}
\makeindex[name=texts,title=Texts,columns=1,options=-s mystyle -c -l]
\begin{document}

\index[texts]{Script@\string\textbf{Weird Languages}}

3.28\index[texts]{Script!Aramaic!3.28}
5.1\index[texts]{Script!Greek!5.1}
8.1\index[texts]{Script!Demotic!8.1}

\printindex[texts]

\end{document}


The outcome so far is:

How do I suppress the page number of an individual entry, here "Weird Languages" , or, how do I add an item without page number while keeping page numbers for other items as normal?

-
A tip: If you indent lines by 4 spaces or enclose words in backticks , they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). –  percusse Apr 12 '13 at 15:08
As a last resort, you can edit the .ind file manually (after creating the index). It looks like one big long list environment, so it is easy to figure out and do. However, if you are going to be doing a lot of this sort of thing, it would be better to do it programmatically. –  jon Apr 12 '13 at 16:39
I will be doing a lot of this, so I am indeed looking for a programmatic solution. In addition, manual removal does not work; each time it goes through TeX the numbers are added. –  user19544 Apr 12 '13 at 18:11
Not by default: only makeindex would do that. So, presumably it's because imakeidx is being run without the noautomatic option. Also not allowing -shell-escape should solve that problem, I believe. But no matter if you have many 'no page number' entries that you want to add. –  jon Apr 12 '13 at 19:37

here's a hack that works when i've used it.

in the preamble, add these definitions:

\newcommand{\idxnopage}[1]{{}}
\providecommand{\gobble}[1]{{}}


use it like this, inserting appropriate sort argument and text:

\index{<sort argument>@\idxsechead{<header text>} |idxnopage}


i haven't been able to come up with a "combined" definition that incorporates the \idxnopage. (maybe david or egreg can improve this.)

edit: here is a small example that will produce the output described above. note that it is essential to run makeindex on the .idx file produced by the first latex run, and then to process the .tex file again through latex to actually include the index in the output.

\documentclass{article}
\usepackage{makeidx}
\newcommand{\idxnopage}[1]{{}}
\providecommand{\gobble}[1]{{}}
\makeindex

\begin{document}
Here is some text\index{some text} that we want indexed.

We also want a header'' in the index.
\printindex
\end{document}

-
I do not get any text out of this; could something be missing? –  user19544 Apr 12 '13 at 18:42
@willem -- try something like: \index[texts]{aScript@\idxsechead{Weird Languages}|idxnopage} (with the three \*commandds defined as above. Note that aScript will put the phrase 'Weird Languages' above 'Script' while Script would put it below. –  jon Apr 12 '13 at 19:54
yes, I made a mistake in my text, it works very well indeed –  user19544 Apr 13 '13 at 22:54

Just for proof of concept. Taking the .ind file generated from the example file given above, you have:

\begin{theindex}

\item Script
\subitem Aramaic
\subsubitem 3.28, 1
\subitem Demotic
\subsubitem 8.1, 1
\subitem Greek
\subsubitem 5.1, 1
\item \string, \textbf{Weird Languages}{1}

\end{theindex}


If you change it to:

\begin{theindex}

\item \textbf{Weird Languages}
\item Script
\subitem Aramaic
\subsubitem 3.28, 1
\subitem Demotic
\subsubitem 8.1, 1
\subitem Greek
\subsubitem 5.1, 1

\end{theindex}


and run xelatex one more time with the noautomatic option for imakeidx`, you will get 'Weird Languages' above 'Script' and at the same level, but without a page reference. For a one-off edit or two, it is pretty simple.

-
This is helpful, too, the noautomatic option is crucial –  user19544 Apr 13 '13 at 22:54