\index inside \autocite prenote 不起作用

\index inside \autocite prenote 不起作用
  1. 我正在編寫一個使用該包biblatex-chicagomakeidx.
  2. 我正在使用 endnotes 包將所有腳註推送到註釋部分。
  3. 所有引文都出現在參考書目部分。這是使用 實現的\autocite
  4. 在該專案中,我想要在\autocite.這意味著,在索引部分中,術語將對應於註釋部分中的相關頁面。例如,在以下範例中,「clah」應與頁碼一起出現在「索引」中,其中出現在「註釋」部分中。

我面臨的問題是 - 當我放入\index預註釋時它無法編譯。但\index內後記效果很好。有人可以澄清如何解決這個問題嗎?

例如,當我這樣做時

\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 Question.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 完整索引

相關內容