The xeindex
package seems very buggy in this instance.
This problem only occurs if “foo” is not followed by text (\section
, \printindex
, \end{table}
and \\
don't count).
Works:
\section{foo and nothing else}
\section{foo and bar}
Breaks:
\section{foo}
… foo \printindex \end{document}
Help:
- Dirty workarounds like
f{}oo
work everywhere, but are painful and break hyphenation.
- The package provides
\StopIndex{<list>}
, \StopSearching
and \StartSearching
. In sections they need to be \protect
ed.
- Either
\StopSearching foo \StartSearching
or
{\StopSearching foo}
The package provides even \NoIndex
:
\def\NoIndex#1{%
\bgroup
\StopIndex
#1%
\egroup
}
but that fails. It needs at least a \protect
but then it's missing a }
again.
The following definition does work but does not typeset anything (no surprise there, just randomly adding \egroup
s can't be the solution.
\def\NoIndex#1{\bgroup\protect\StopIndex #1\egroup\egroup}
Therefore, I defined a custom command \PreventIndex{<to not be indexed>}
which works everywhere (?).
Code (MWE)
\documentclass{article}
\usepackage[paperheight=8cm,paperwidth=8cm]{geometry}
\usepackage{xeindex} \makeindex
\IndexList{mylist}{hello,foo and bar,hi}
\newcommand*\PreventIndex[1]{{\protect\StopSearching #1}}
\AtBeginDocument{\LARGE} % only for this MWE
\begin{document}
\section{I give a \PreventIndex{foo}} % Nothing after foo => \PreventIndex
Foo is horrible! % some plain text after foo => no need to stop Searching
\section{Foo, nothing else} % some plain text after foo => no need to stop Searching
There is really nothing else then foo? % some plain text after foo => no need to stop Searching
\section{Let's index!}
Foo and bar are always together. % Works, gets indexed
Bar was born ten minutes later then
\PreventIndex{foo} \(\Longleftarrow\) % :(
needs {\small\texttt{\textbackslash PreventIndex}}
\newpage
\begin{tabular}{c}
Foo and bar \\
sitting on a \PreventIndex{foo} \\ %
foo? %
\end{tabular}
\printindex
\end{document}
Output
