# How to locate rejected index enteries

Some of my index entries are being rejected for some reason. How do I determine which index entries were rejected?

For instance if I uncomment the \def at the top of the MWE below I see the message in the console. All this does is switch from suing \tiny to \small. Not sure why one would be ok but the other.

Scanning input file TestIndex.idx...done (0 entries accepted, 10 rejected)

I searched for the word rejected in imakeidx.sty but that word is not in that file, so not sure where this message is coming from.

The above is just one cause of the entries being rejected. I need to know what are some of the other causes as I have some rejected without using \small.

## Code:

%\def\UseSmallInIndex{}%

\documentclass{article}
\usepackage{datatool}% database
\usepackage{imakeidx}% indexing
\usepackage{hyperref}% For cross references
\usepackage{xcolor}%
\makeindex

% ---------- Process Each Word:
%
% http://tex.stackexchange.com/questions/12810/how-do-i-split-a-string
\makeatletter
\def\ProcessEachWord#1{%
\begingroup%
\edef\@tempa{#1\space}%
\gdef\@tempb{#1}%
\expandafter\endgroup%
}%
\ProcessWord[\@tempb]{#1}%  #1 = substr, #2 = rest of string
\begingroup%
\ifx\relax#2\relax% is #2 empty?
\def\next{\endgroup\EndProcessWords}% your own end-macro if required
\else%
\fi%
\next%
}%
\makeatother
% ----------

\newcommand{\ProcessWord}[2][]{%
\ifdefined\UseSmallInIndex%
\index{#2!#1\href{run:#1.pdf}{\small\textcolor{red}{pdf}}}%
\else%
\index{#2!#1\href{run:#1.pdf}{\tiny\textcolor{red}{pdf}}}%
\fi%
}%
\newcommand{\EndProcessWords}{}

\begin{document}
\DTLnewdb{DB}%
\DTLnewrow{DB}%
\DTLnewdbentry{DB}{FileName}{Now good enough}%
\DTLnewrow{DB}%
\DTLnewdbentry{DB}{FileName}{Now good enough for you and me}%

\DTLforeach{DB}{\FileName=FileName}{%
\section{\FileName}%
\par\noindent\href{run:\FileName.pdf}{\FileName}%
\ProcessEachWord{\FileName}%
}%

\printindex
\end{document}

-

You find the rejected entries in the .ilg file, which is the log of Makeindex's activities.

Where's the problem? If you look at the entries generated when \UseSmallInIndex is undefined, you find them of the form

\indexentry{Now!Now good enough\href  {run:Now good enough.pdf}{\relax \fontsize  {5}{6}\selectfont  \leavevmode {\color  {red}pdf}}|hyperpage}{1}


and you see that \tiny has been substituted by its expansion. The expansion of \small gives instead

\indexentry{Now!Now good enough\href  {run:Now good enough.pdf}{\relax \fontsize  {9}{11}\selectfont  \abovedisplayskip 8.5\p@ plus3\p@ minus4\p@ \abovedisplayshortskip \z@ plus2\p@ \belowdisplayshortskip 4\p@ plus2\p@ minus2\p@ \def \leftmargin \leftmargini \parsep 4\p@ plus2\p@ minus\p@ \topsep 8\p@ plus2\p@ minus4\p@ \itemsep 4\p@ plus2\p@ minus\p@ {\leftmargin \leftmargini \topsep 4\p@ plus2\p@ minus2\p@ \parsep 2\p@ plus\p@ minus\p@ \itemsep \parsep }\belowdisplayskip \abovedisplayskip \leavevmode {\color  {red}pdf}}|hyperpage}{1}


which is where Makindex chokes.

Solution:

\newcommand{\ProcessWord}[2][]{%
\ifdefined\UseSmallInIndex
\index{#2!#1\href{run:#1.pdf}{\protect\small\protect\textcolor{red}{pdf}}}%
\else
\index{#2!#1\href{run:#1.pdf}{\protect\tiny\protect\textcolor{red}{pdf}}}%
\fi
}


I'd also use \protected@edef in the definition of \ProcessEachWord for similar reasons.

-