\documentclass[10pt,openany]{book}
\usepackage{stan-manuals}

\begin{document}

\pagestyle{plain}

\frontmatter
\include{title}
%\include{abstract}
\tableofcontents
\include{preface}
\include{acknowledgements}

\mainmatter
\include{introduction}
\include{commands}
\include{programming}
\include{language}
\include{functions}
\include{distributions}
\include{advanced}
\include{contributed}

\appendix
\include{appendices}
\include{references}
\titlespacing{\chapter}{0pt}{-4pt}{24pt}{}
{\footnotesize
\printindex
}

\backmatter % after appendices or problems
%\listoffixmes
\end{document}

\documentclass[10pt,openany]{book}
\usepackage{stan-manuals}

\begin{document}

\pagestyle{plain}

\frontmatter
\include{title}
%\include{abstract}
\tableofcontents
\include{preface}
\include{acknowledgements}

\mainmatter
\include{introduction}
\include{commands}
\include{programming}
\include{language}
\include{functions}
\include{distributions}
\include{advanced}
\include{contributed}

\appendix
\include{appendices}
\include{references}
\titlespacing{\chapter}{0pt}{-4pt}{24pt}{}
{\footnotesize
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Index}
\printindex
}

\backmatter % after appendices or problems
%\listoffixmes
\end{document}

Add index of functions to the TOC of the reference manual
Add index of functions to the TOC of the reference manual
