I am using the solution from Indexing with Binary Units using siunitx package. This not only solved the specific problem that I had posted but seemed to resolve a numerous other problems as well. However, it appears that there is some difficulty if the there are double quotes in the unexpanded parameter which results in
Reading raw-index "/var/folders/70/.../T/N728p7zZMX"...
ERROR: READ: input stream #<CLOSED INPUT BUFFERED FILE-STREAM CHARACTER #P"/var/folders/70/.../T/N728p7zZMX" @3> ends within a string
where the ... are some randomly generated path.
The MWE has only one line added to the solution at the referenced question
Code:
\documentclass{article}
\usepackage{imakeidx}
\usepackage{xparse}
\usepackage{siunitx}
\usepackage{xcolor}
%% https://tex.stackexchange.com/questions/50712/automatically-convert-quotations-in-the-form-of-abc-to-become-abc
\usepackage{csquotes}
\MakeOuterQuote{"}
\usepackage{hyperref}
\newcommand*\lettergroup[1]{\subsection{#1}}
\newcommand*{\IndexWithName}[2]{%
% #1 = word to index
% #2 = index name
\index[#2]{#1}%
}
\NewDocumentCommand{\FormatIndexEntry}{mm}{%
\textcolor{blue}{#1} #2%
}
%% Defer the binary units until AFTER \begin{document} as per
%% https://tex.stackexchange.com/questions/287579/how-to-overwrite-siunitxs-binary-prefixes
\sisetup{binary-units=true}
\AtBeginDocument{%
\DeclareSIUnit\bit{\textcolor{red}{bit}}%
}
\NewDocumentCommand{\AddIndexEntry}{%
O{}% #1 = index name
m% #2 = word to index this under
m% #3 = indexed term
m% #4 = symbol
}{%
\expandafter\IndexWithName\expandafter{%
#2!#3@\FormatIndexEntry{#3}{\unexpanded{\unexpanded{#4}}}%
}{#1}%
}
\newcommand{\indexopt}[2]{\index[#2]{#1}}
\makeindex[title={Main Index},columns=1,program=texindy]
\makeindex[title={Name Index},columns=1,program=texindy,name=Name]
\indexsetup{level=\section}
\begin{document}
\SI{1}{\bit}
\AddIndexEntry[Name]{Bytes}{Bit}{symbol: \si{\bit}}
\AddIndexEntry[Name]{Bytes}{Bit}{text using "quotes"}% <---- This is a problem.
\clearpage
\setcounter{secnumdepth}{0}
\printindex[Name]
\end{document}

"in a LaTeX document. Note that"is a special character in.idxfiles and, at least with MakeIndex, it should be quoted as""– egreg Feb 09 '16 at 10:22csquotespackages (Have updated MWE to reflect that). Should that not be used? – Peter Grill Feb 09 '16 at 10:27