\index внутри \autocite prenote не работает

\index внутри \autocite prenote не работает
  1. Я пишу tex-файл, который использует пакет biblatex-chicagoи makeidx.
  2. Я использую пакет endnotes, чтобы переместить все сноски в раздел «Примечания».
  3. Все цитаты отображаются в разделе «Библиография». Это достигается с помощью \autocite.
  4. В проекте я хочу индексировать внутри pre- и post-notes \autocite. Это означает, что в разделе Index термин будет соответствовать соответствующей странице в разделе Notes. Например, в следующем примере "clah" должен появиться в Index вместе с номером страницы в разделе Notes, где он появляется.

ВПроблема, с которой я столкнулся, заключается в следующем: когда я вставляю \indexpre-notes, он не компилируется. Но \indexвнутри post-notes работает просто отлично. Может кто-нибудь объяснить, как решить эту проблему?

Например, когда я делаю

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

это работает! Однако,

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

не скомпилируется.

Вот 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}

Вот содержание вопроса 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}
}

решение1

Использовать

\protect\index{<term>}

а не \index{<term>}в предисловиях и послесловиях.

В зависимости от стиля и настроек biblatexможет применяться дополнительное форматирование или другие макросы к полям пред- и постсносок. Может случиться, что содержимое поля будет расширено таким образом, что нерасширяемые макросы вызовут проблемы. Вот почему вы находитесь в безопасности, защищая использование \indexв пред- и постсносках с помощью , \protectдаже если на первый взгляд это не кажется необходимым.

\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}

В случае, если biblatex-chicagoпредварительные замечания являются проблематичными из- \MakeCapitalза

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

Со стандартом biblatex \indexв примечаниях проблематично из-за \mkpageprefixи \mknormrangeв

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

Полный индекс MWE

Связанный контент