我使用 biblatex 来构建:
- 一个自动索引参考书目中所引用的作者。
- 单一语言的参考书目,标点符号规则取自 langid每个条目。
正如在最后一个答案的评论中所讨论的那样,这些解决方案非常独立地工作,但是当我尝试混合两者时出现以下错误:
! Undefined control sequence.
\blx@nameparser@i ...pandafter {\mblx@currentname
}{\mblx@exemptfields } {\b...
l.142 \footcite{compagnon}
我尝试“免除”该author
字段的补丁,但没有成功。这可以实现吗?还是补丁会变得不合理?
下面是一个测试代码,注释掉允许建立索引的长补丁:
\documentclass{article}
\usepackage[english,french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{makeidx}
\usepackage[backend=biber,
style=verbose-trad2,
singletitle=true,
indexing=cite,
]{biblatex}
\makeindex
\renewbibmacro*{citeindex}{
\ifciteindex
{\indexnames{labelname}}
{}}
\makeatletter
\newcommand*{\mblx@exemptfields}{}
\newrobustcmd*{\ExemptFromLanguageSwitching}{%
\forcsvlist{\listgadd\mblx@exemptfields}}
\def\blx@thefakelangenv{otherlanguage}%
\def\blx@beglang@fake{%
\blx@clearlang
\begingroup
\ifdef\abx@field@langid
{\def\blx@endlang@fake{%
\end{otherlanguage*}%
\endgroup}%
\begin{otherlanguage*}{\abx@field@langid}}
{}}
\let\blx@endlang@fake\relax
\renewrobustcmd*{\blx@imc@printfield}[2][]{%
\blx@imc@iffieldundef{#2}
{\blx@nounit}
{\blx@getformat\blx@theformat{ffd}{#1}{#2}%
\ifdefvoid\blx@theformat
{\blx@nounit}
{\blx@begunit
\ifinlist{#2}{\mblx@exemptfields}
{}
{\let\blx@theformat@outer\blx@theformat
\def\blx@theformat##1{\blx@theformat@outer{\blx@beglang@fake ##1\blx@endlang@fake}}}%
\edef\currentfield{#2}%
\expandafter\expandafter
\expandafter\blx@theformat
\expandafter\expandafter
\expandafter{\csname abx@field@#2\endcsname}%
\blx@endunit}}}
\catcode`\&=3
\def\blx@printnames#1#2#3#4{%
\blx@imc@ifnameundef{#4}
{\blx@nounit}
{\def\mblx@currentname{#4}%
\blx@getformat\blx@thewrapperformat{nwd}{#1}{#4}%
\ifdefvoid\blx@thewrapperformat
{\blx@nounit}
{\blx@getformat\blx@theformat{nfd}{#1}{#4}%
\ifdefvoid\blx@theformat
{\blx@nounit}
{\blx@begunit
\blx@namesetup{#2}{#3}{#4}%
\blx@thewrapperformat{\expandafter\blx@nameparser\blx@thedata{}&}%
\blx@endunit}}}}
\long\def\blx@nameparser@i#1#2{%
\begingroup
\ifblank{#1}
{}
{\setkeys{blx@opt@name}{#1}}%
\setkeys{blx@opt@namepart}{#2}%
\expandafter\ifinlist\expandafter{\mblx@currentname}{\mblx@exemptfields}
{\blx@theformat{#2}}
{\blx@beglang@fake\blx@theformat{#2}\blx@endlang@fake}%
\endgroup}
\def\blx@printlist#1#2#3#4{%
\blx@imc@iflistundef{#4}
{\blx@nounit}
{\def\mblx@currentlist{#4}%
\blx@getformat\blx@thewrapperformat{lwd}{#1}{#4}%
\ifdefvoid\blx@thewrapperformat
{\blx@nounit}
{\blx@getformat\blx@theformat{lfd}{#1}{#4}%
\ifdefvoid\blx@theformat
{\blx@nounit}
{\blx@begunit
\blx@listsetup{#2}{#3}{#4}%
\blx@thewrapperformat{\expandafter\blx@listparser\blx@thedata{}&}%
\blx@endunit}}}}
\long\def\blx@listparser#1{%
\ifblank{#1}
{\blx@listbreak}
{\ifnum\c@listcount<\c@liststart
\else
\expandafter\ifinlist\expandafter{\mblx@currentlist}{\mblx@exemptfields}
{\blx@theformat{#1}}
{\blx@beglang@fake\blx@theformat{#1}\blx@endlang@fake}%
\fi
\advance\c@listcount\@ne
\ifnum\c@listcount>\c@liststop
\expandafter\blx@listbreak
\fi
\blx@listparser}}
\makeatother
\catcode`\&=4
\ExemptFromLanguageSwitching{url,doi,eprint,pages}
\begin{filecontents}[force]{\jobname.bib}
@book{compagnon,
author = {Compagnon, Antoine and Someone Else},
translator = {Même, Moi},
date = {1998},
title = {Titre: aléatoire?},
pages = {306-723},
langid = {french},
url = {https://example.com/~stuff/more.pdf},
}
@book{glashow,
author = {Glashow, Sheldon and Someone Else},
title = {Random: title?},
translator = {Self, My},
date = {1961},
pages = {579-588},
langid = {english},
url = {https://example.com/~stuff/more.pdf},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\footcite{compagnon}
\footcite{glashow}
\printindex
\printbibliography
\end{document}
答案1
代码在多语言文献中的标点符号规则可能不仅应该修补\printnames
和\printlist
,还应该\indexnames
修补和\indexlist
。(现在那里也已经修复了。)
以下代码应该可以编译。
\documentclass{article}
\usepackage[english,french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{makeidx}
\usepackage[backend=biber,
style=verbose-trad2,
singletitle=true,
indexing=cite,
]{biblatex}
\makeindex
\renewbibmacro*{citeindex}{
\ifciteindex
{\indexnames{labelname}}
{}}
\makeatletter
\newcommand*{\mblx@exemptfields}{}
\newrobustcmd*{\ExemptFromLanguageSwitching}{%
\forcsvlist{\listgadd\mblx@exemptfields}}
\def\blx@thefakelangenv{otherlanguage}%
\def\blx@beglang@fake{%
\blx@clearlang
\begingroup
\ifdef\abx@field@langid
{\def\blx@endlang@fake{%
\end{otherlanguage*}%
\endgroup}%
\begin{otherlanguage*}{\abx@field@langid}}
{}}
\let\blx@endlang@fake\relax
\renewrobustcmd*{\blx@imc@printfield}[2][]{%
\blx@imc@iffieldundef{#2}
{\blx@nounit}
{\blx@getformat\blx@theformat{ffd}{#1}{#2}%
\ifdefvoid\blx@theformat
{\blx@nounit}
{\blx@begunit
\ifinlist{#2}{\mblx@exemptfields}
{}
{\let\blx@theformat@outer\blx@theformat
\def\blx@theformat##1{\blx@theformat@outer{\blx@beglang@fake ##1\blx@endlang@fake}}}%
\edef\currentfield{#2}%
\expandafter\expandafter
\expandafter\blx@theformat
\expandafter\expandafter
\expandafter{\csname abx@field@#2\endcsname}%
\blx@endunit}}}
\catcode`\&=3
\def\blx@printnames#1#2#3#4{%
\blx@imc@ifnameundef{#4}
{\blx@nounit}
{\def\mblx@currentname{#4}%
\blx@getformat\blx@thewrapperformat{nwd}{#1}{#4}%
\ifdefvoid\blx@thewrapperformat
{\blx@nounit}
{\blx@getformat\blx@theformat{nfd}{#1}{#4}%
\ifdefvoid\blx@theformat
{\blx@nounit}
{\blx@begunit
\blx@namesetup{#2}{#3}{#4}%
\blx@thewrapperformat{\expandafter\blx@nameparser\blx@thedata{}&}%
\blx@endunit}}}}
\def\blx@indexnames#1#2#3#4{%
\blx@imc@ifnameundef{#4}
{}
{\def\mblx@currentname{#4}%
\blx@getformat\blx@theformat{nid}{#1}{#4}%
\ifdefvoid\blx@theformat
{}
{\begingroup
\blx@namesetup{#2}{#3}{#4}%
\blx@indexnamesetup
\expandafter\blx@nameparser\blx@thedata{}&%
\endgroup}}}
\long\def\blx@nameparser@i#1#2{%
\begingroup
\ifblank{#1}
{}
{\setkeys{blx@opt@name}{#1}}%
\setkeys{blx@opt@namepart}{#2}%
\expandafter\ifinlist\expandafter{\mblx@currentname}{\mblx@exemptfields}
{\blx@theformat{#2}}
{\blx@beglang@fake\blx@theformat{#2}\blx@endlang@fake}%
\endgroup}
\def\blx@printlist#1#2#3#4{%
\blx@imc@iflistundef{#4}
{\blx@nounit}
{\def\mblx@currentlist{#4}%
\blx@getformat\blx@thewrapperformat{lwd}{#1}{#4}%
\ifdefvoid\blx@thewrapperformat
{\blx@nounit}
{\blx@getformat\blx@theformat{lfd}{#1}{#4}%
\ifdefvoid\blx@theformat
{\blx@nounit}
{\blx@begunit
\blx@listsetup{#2}{#3}{#4}%
\blx@thewrapperformat{\expandafter\blx@listparser\blx@thedata{}&}%
\blx@endunit}}}}
\def\blx@indexlist#1#2#3#4{%
\blx@imc@iflistundef{#4}
{}
{\def\mblx@currentlist{#4}%
\blx@getformat\blx@theformat{lid}{#1}{#4}%
\ifdefvoid\blx@theformat
{}
{\begingroup
\blx@listsetup{#2}{#3}{#4}%
\expandafter\blx@listparser\blx@thedata{}&%
\endgroup}}}
\long\def\blx@listparser#1{%
\ifblank{#1}
{\blx@listbreak}
{\ifnum\c@listcount<\c@liststart
\else
\expandafter\ifinlist\expandafter{\mblx@currentlist}{\mblx@exemptfields}
{\blx@theformat{#1}}
{\blx@beglang@fake\blx@theformat{#1}\blx@endlang@fake}%
\fi
\advance\c@listcount\@ne
\ifnum\c@listcount>\c@liststop
\expandafter\blx@listbreak
\fi
\blx@listparser}}
\makeatother
\catcode`\&=4
\ExemptFromLanguageSwitching{url,doi,eprint,pages}
\begin{filecontents}{\jobname.bib}
@book{compagnon,
author = {Compagnon, Antoine and Someone Else},
translator = {Même, Moi},
date = {1998},
title = {Titre: aléatoire?},
pages = {306-723},
langid = {french},
url = {https://example.com/~stuff/more.pdf},
}
@book{glashow,
author = {Glashow, Sheldon and Someone Else},
title = {Random: title?},
translator = {Self, My},
date = {1961},
pages = {579-588},
langid = {english},
url = {https://example.com/~stuff/more.pdf},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\footcite{compagnon}
\footcite{glashow}
\printindex
\printbibliography
\end{document}