使用 biblatex 索引复杂的 [postnote] 内容

使用 biblatex 索引复杂的 [postnote] 内容

我目前正在使用 biblatex 制作古代作家索引,如下所示:-

Author,
  On Conundrums,
    II, 77.3--5, 1
    II, 77.10--12, 2
    II, 100, 5--6, 3

其中II是书的卷号On Conundrums77100为页码,而,,3--510--12引用5--6段落的行号,最后1,,为每个引用出现的页码。23

在我的文档源中,诸如这样的引用II, 77.3--5进入<prenote>可选参数,如下所示:\autocite[II, 77.3--5]{Author}

为了生成实际索引,我使用了@PaulStanley 提供的解决方案那里,我对其进行了改编,使其符合 biblatex 3.3 新的名称格式规则(请参阅本文末尾的“biblatexengine.tex”)。

问题在于诸如这样的引用II, 77.3--5在索引中排序不正确。举两个例子,仅仅因为 5 > 2II, 55.1而放在后面,仅仅因为 3 > 1而放在后面,等等。II, 211.25--28II, 77.3--5II, 77.10--12

换句话说,页码/行号在这里不被视为数字,而在“简单”的后记内容中,它们始终存在,例如\autocite[123]{Author}

有办法实现这个功能吗?目前,我的解决方案是给所有数字加上前缀零,如下所示:II, 077.01--13,然后将格式化的索引传递给 Lua 脚本以删除前导零。这可行,但难道没有更好的方法吗?

任何帮助将非常感激。

梅威瑟:

\documentclass{article}

\usepackage{fontspec}
\usepackage{libertine}

\usepackage{filecontents}

\begin{filecontents}{mwe.bib}
@Book{IAUMuller,
  year =     1995,
  author =   {{Ibn Abī Uṣaybiʿa}},
  title =    {ʿUyūn al-anbāʾ fī ṭabaqāt al-atibbāʾ},
  shorttitle =   {ʿUyūn al-anbāʾ},
  editor =   {Müller, August},
  shorteditor =  {Müller},
  pagination =   {none},
  entrysubtype = {classical},
  publisher =    {Institute for the history of Arabic-Islamic Science},
  location =     {Frankfurt am Main},
  volumes =  2
}
\end{filecontents}

\usepackage{indextools}

\usepackage[citestyle=verbose-trad3, citepages=omit,
backend=biber, indexing]{biblatex}

\addbibresource{mwe.bib}

\makeindex[name=authortitle, title={Ancient Authors}]
\makeindex[name=ancauthortitle, title={Modern Authors}]

\input{biblatexengine.tex}

\begin{document}
First reference\autocite[II, 77.3--5]{IAUMuller}; second
reference\autocite[II, 100.5--6]{IAUMuller}. And finally\autocite[II,
77.10--12]{IAUMuller}.

\printbibliography
\printindex[ancauthortitle]
\end{document}

的内容biblatexengine.tex。该文件的相关部分开始于%RELEVANT并结束于%NOT RELEVANT

%RELEVANT:
\makeatletter
\def\thefirstpage#1{%
  \expandafter\expandafter\expandafter\firstpage@i
  \expandafter\expandafter\expandafter{\csname abx@field@#1\endcsname}}
\def\firstpage@i#1{\firstpage@ii#1-\@nil}
\def\firstpage@ii#1-#2\@nil{#1}
 \newbibmacro*{index:name:title:pages}[5]{%
  \begingroup
  \ifuseprefix
    {\def\abx@tempa{%
       \ifblank{#4}{}{#4 }%
       \@firstofone #2% remove spurious braces
       \ifblank{#5}{}{ #5}%
       \ifblank{#3}{}{, #3}%
       \actualoperator
       \ifblank{#4}{}{\MakeCapital{#4} }%
       #2%
       \ifblank{#5}{}{ #5}%
       \ifblank{#3}{}{, #3}}}
    {\def\abx@tempa{%
       \@firstofone #2% remove spurious braces
       \ifblank{#5}{}{#5}%
       \ifblank{#3#4}{}{,}%
       \ifblank{#3}{}{ #3}%
       \ifblank{#4}{}{ #4}}}%
  \savefield{indextitle}{\abx@tempb}%
  \iffieldpages{postnote}
    {\protected@edef\theindexentry{\unexpanded{#1}{%
       \abx@tempa!\thefield{indexsorttitle}%
       \actualoperator\emph{\expandonce\abx@tempb}%
       !\thefirstpage{postnote}\actualoperator\thefield{postnote}|emph}}}
    {\protected@edef\theindexentry{\unexpanded{#1}{%
       \abx@tempa!\thefield{indexsorttitle}%
       \actualoperator\emph{\expandonce\abx@tempb}}}}%
  \theindexentry
  \endgroup}
\makeatother

\DeclareIndexNameFormat{title:pages}{%
\nameparts{#1}%
\iffieldequalstr{entrysubtype}{classical}{%
   \usebibmacro{index:name:title:pages}{\index[ancauthortitle]}%
     {\iffieldundef{usera}{}{\thefield{usera}\actualoperator}\namepartfamily}%
        {\namepartgiven%
        \iffieldundef{nameaddon}{}{\addspace\parentext{\thefield{nameaddon}}}}%
        {\namepartprefix}{\namepartsuffix}}%
   {\usebibmacro{index:name:title:pages}{\index[authortitle]}%
     {\iffieldundef{usera}{}{\thefield{usera}\actualoperator}\namepartfamily}%
        {\namepartgiven}{\namepartprefix}{\namepartsuffix}}}

\renewbibmacro*{citeindex}{%
  \ifciteindex{\indexnames[title:pages]{labelname}}{}}

%NOT RELEVANT (serves other purposes):

\DeclareCiteCommand{\notecite} % adapt \notecite
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames[title:pages]{labelname}}
     {}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\makeatletter           % include \ifciteindex in lowlevel \citename
\long\csdef{blx@cite@citename}#1#2#3#4#5#6{%
  \begingroup
  \blx@citecmdinit
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\abx@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\abx@field@postnote{#2}}%
  \def\blx@precode{\usebibmacro{prenote}}%
  \def\blx@loopcode{%
     \ifciteindex
     {\indexnames[title:pages]{labelname}}
     {}%
    \ifnameundef{#5}
      {\blx@warning@entry{'#5' undefined or not a name list}%
       \abx@missing{#5}}
      {\printnames[#4]{#5}}}%
  \def\blx@dlimcode{\multicitedelim}%
  \ifblank{#2}
    {\def\blx@postcode{#6}}
    {\def\blx@postcode{\usebibmacro{postnote}#6}}%
  \boolfalse{citetracker}%
  \boolfalse{pagetracker}%
  \blx@citeloop{#3}%
  \endgroup}
                      % include \ifciteindex in low-level \citefield
\long\csdef{blx@cite@citefield}#1#2#3#4#5#6{%
  \begingroup
  \blx@citecmdinit
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\abx@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\abx@field@postnote{#2}}%
  \def\blx@precode{\usebibmacro{prenote}}%
  \def\blx@loopcode{%
     \ifciteindex
     {\indexnames[title:pages]{labelname}}
     {}%
    \iffieldundef{#5}
      {\blx@warning@entry{'#5' undefined or not a field}%
       \abx@missing{#5}}
      {\printfield[#4]{#5}}}%
  \def\blx@dlimcode{\multicitedelim}%
  \ifblank{#2}
    {\def\blx@postcode{#6}}
    {\def\blx@postcode{\usebibmacro{postnote}#6}}%
  \boolfalse{citetracker}%
  \boolfalse{pagetracker}%
  \blx@citeloop{#3}%
  \endgroup}
\makeatother

相关内容