\index dentro de \autocite prenote no funciona

\index dentro de \autocite prenote no funciona
  1. Estoy escribiendo un archivo tex que usa el paquete biblatex-chicagoy makeidx.
  2. Estoy usando el paquete de notas finales para enviar todas las notas a pie de página a la sección Notas.
  3. Todas las citas aparecen en la sección Bibliografía. Esto se logra usando \autocite.
  4. En el proyecto, quiero indexar dentro de las notas previas y posteriores de \autocite. Es decir, en la sección Índice, un término corresponderá a la página correspondiente en la sección Notas. Por ejemplo, en el siguiente ejemplo, "clah" debería aparecer en el índice junto con el número de página en la sección de Notas donde aparece.

qEl problema al que me enfrento es el siguiente: cuando pongo \indexnotas previas, no se compila. Pero \indexlas notas posteriores funcionan bien. ¿Alguien podría aclarar cómo solucionar este problema?

Por ejemplo, cuando hago

\autocite[blah blah][clah clah\index{clah}]{a-citekey}

¡funciona! Sin embargo,

\autocite[blah blah\index{blah}][clah clah]{a-citekey}

no se puede compilar.

Aquí está el MWE:

\def\DevnagVersion{2.16}
\documentclass[11pt]{book}
\usepackage[a4paper,bindingoffset=0.2in,%
        left=1in,right=1in,top=1.2in,bottom=1.2in,%
        footskip=.5in]{geometry}

\usepackage{makeidx}
\usepackage{endnotes}
\let\footnote=\endnote

\usepackage[notes]{biblatex-chicago}
\renewcommand\nameyeardelim{, }
\addbibresource{question.bib}

\usepackage{float}
\usepackage{tabls}
\usepackage{graphicx}
\usepackage[colorlinks]{hyperref}
\usepackage{cleveref}
\usepackage{parskip}
\usepackage{devanagari}
\usepackage{epigraph}

\usepackage{fancyhdr, blindtext}
\newcommand{\changefont}{%
\fontsize{8}{10}\selectfont
}
\fancyhf{}
\fancyhead[LE,RO]{\changefont \slshape \rightmark} %section
\fancyhead[RE,LO]{\changefont \slshape \leftmark} %chapter
\fancyfoot[C]{\changefont \thepage} %footer
\pagestyle{fancy}

\newcounter{ExCount}
\newcommand{\ex}[1]{
\stepcounter{ExCount}
\addcontentsline{toc}{section}{~~ \textit{Example \arabic{ExCount}: #1}}
\subsubsection*{~~ \textit{Example \arabic{ExCount}: #1}}
}
\newcommand{\he}[1]{
\addcontentsline{toc}{section}{#1}
\subsubsection*{#1}
}


\DeclareAutoCiteCommand{endfull}[f]{\footfullcite}{\footfullcites}
\ExecuteBibliographyOptions{autocite=endfull}


\sloppy

\title{A catchy title}
\author{Author One \and Author Two}

\makeindex

\begin{document}
\maketitle\newpage
\tableofcontents\newpage

\frontmatter

\chapter{Intro}

Testing the Wendy Doniger example from Penguin.\footcite[][p. 65]{doniger1999splitting}

This line is just to test index.\autocite[please refer to][for a detailed analysis{\index{analysis}}]{a-citekey}

% but this does not work
% This line is just to test index.\autocite[please   refer\index{refer} to][for a detailed analysis]{a-citekey}

\newpage
\def\enotesize{\footnotesize}  
\cleardoublepage 
\addcontentsline{toc}{chapter}{Notes}
\theendnotes


\addcontentsline{toc}{chapter}{Bibliography}
\renewcommand*{\bibfont}{\footnotesize}
\printbibliography

\cleardoublepage
\addcontentsline{toc}{chapter}{Index}    % adds Index to TOC
\printindex

\end{document}

Aquí está el contenido de la pregunta bibfile.bib

@book{doniger1999splitting,
  title =        {Splitting the difference: Gender and myth in ancient
              Greece and India},
  author =       {Doniger, Wendy},
  year =         {1999},
  publisher =    {University of Chicago Press},
  location =     {Chicago}
}


@InCollection{a-citekey,
  author =       {Author One},
  title =        {A long title: this is a really long title},
  booktitle =    {This is my book: proud to have written this},
  publisher =    {Elite Publishing House},
  year =         2006,
  editor =       {A bigshot editor},
  chapter =      7,
  url =          {http://www.example.com/a-link.html}
}

Respuesta1

Usar

\protect\index{<term>}

en lugar de \index{<term>}en notas previas y posteriores.

Dependiendo del estilo y la configuración, biblatexes posible que se apliquen formatos adicionales u otras macros a los campos de notas anteriores y posteriores. Puede suceder que el contenido del campo se expanda de tal manera que las macros no expandibles causen problemas. Es por eso que está seguro protegiendo los usos de \indexen notas previas y posteriores \protectincluso si no parece necesario a primera vista.

\documentclass{article}
\usepackage{makeidx}
\usepackage{biblatex-chicago}
\usepackage[colorlinks]{hyperref}

\makeindex

\addbibresource{biblatex-examples.bib}


\begin{document}
Testing the Wendy Doniger example from Penguin.\autocite[65]{sigfridsson}

This line is just to test index.\autocite[refer][analysis\protect\index{analysis}]{sigfridsson}

This line is just to test index.\autocite[refer\protect\index{refer}][analysis]{sigfridsson}

\printbibliography

\printindex
\end{document}

En el caso de biblatex-chicagolas prenotas son problemáticas debido a que \MakeCapitalen

\DeclareFieldFormat{prenote}{\ifcapital{\MakeCapital{#1}}{#1}\isdot}

Con el estándar biblatex \indexen las notas posteriores es problemático debido a \mkpageprefixy \mknormrangeen

\DeclareFieldFormat{postnote}{\mkpageprefix[pagination][\mknormrange]{#1}}

Índice completo de MWE

información relacionada