Is it possible to index an exclamation point?
The characters !
, @
, and |
need to be escaped in an indexing context. For makeindex
to understand you mean to mention them rather than use them, you must 'quote' them with a "
. The following should do the trick:
\index{"!} % or, in this case: \fun{"!}
I did some playing around, and the problem seems to stem from your \fun
command, as I added in an $x$
to see if it would print with this, and only prints the x. Also, adding spacing { ! }
rather than {!}
seems to break the formatting. I left it in so you can see it. Removing the \fun
command also removes it from the index altogether, but I guess you probably worked that out yourself.
\documentclass{report}
\usepackage{imakeidx}
%\RequirePackage{imakeidx}
%===----- Functions for indexing and typesetting -----=====
\newcommand{\fun}[1]{\texttt{#1}\index{#1}}
\newcommand{\FUN}[1]{\texttt{#1}\index{#1|textbf}}
\newcommand{\code}[1]{\texttt{#1}}
\makeindex
\begin{document}
%\SweaveOpts{concordance=TRUE}
\chapter{Logical operators}
\begin{table}[!htbp]
\caption{Logical operators.} \label{table:logicops}
\begin{center}
\begin{tabular}{l l}
Operator & Meaning \\ \hline
\fun{\textgreater{}} & greater than\\
\fun{\textless{}} & less than\\
\fun{\&} & AND\\
\fun{==} & equal to\\
\fun{\textbar{}} & OR\\
\fun{\%in\%} & is an element of\\
\fun{ ! x } & NOT\\
\end{tabular}
\end{center}
\end{table}
I hope this helps, I've never personally used an Index before.
I also had other problems with your code when compiling, so I commented everything out except the table. This could be my compiler, so I'll leave that bit to you :)