\DeclareSourcemap 通过 \perrefsection 进行过滤

\DeclareSourcemap 通过 \perrefsection 进行过滤

是否可以在 DeclareSourceMap 中过滤特定的引用部分,就像文件名一样?

我想在两个参考文献中使用相同的书目文件。第一个参考文献包含“常规”条目,使用 \cite{} 引用,而第二个参考文献包含 nocite{*} 命令,参考书目显示我自己的出版物。

现在我遇到了一些 tex 容量错误问题,因为 bbl 文件太大了。因此,我想有一个 DeclareSourceMap 过滤器,我可以在其中过滤掉所有没有我的名字的条目,但仅限于第二个引用部分。

到目前为止,我的解决方法是将文件符号链接到另一个名称并使用 \perdatasource 开关,但更好的解决方案是直接通过 refsection 进行过滤。

我也在github-问题跟踪器,但我得到的建议是在这里发帖寻找解决方案。

以下是该问题的 MWE:

% % Konfiguration für Texstudio (Version > 2.9)
% !TeX program = pdflatex
% !BIB program = biber
% !TeX spellcheck = de_DE
% !TeX encoding = utf8
% !TeX root = 
\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{greenwade93,
    author  = "George D. Greenwade",
    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
    year    = "1993",
    journal = "TUGBoat",
    volume  = "14",
    number  = "3",
    pages   = "342--351"
}
@book{goossens93,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
@book{goossens95,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "Another dummy entry",
    year      = "1995",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
\end{filecontents}
\usepackage{biblatex}
\addbibresource{\jobname.bib}
\newcommand{\lastname}{Goossens}

\DeclareBibliographyCategory{filteredauthor}
\makeatletter
\@ifpackagelater{biblatex}{2016/03/01}
{ %New Syntax for declareindexname for biblatex>3.3
\DeclareIndexNameFormat{Filterauthor}{% Test could be refined
    \nameparts{#1} 
    \ifboolexpr{ test {\ifdefstrequal{\lastname}{\namepartfamily}}}
    {\addtocategory{filteredauthor}{\thefield{entrykey}}}{}}}
{ %Old Syntax for biblatex<3.3
\DeclareIndexNameFormat{Filterauthor}{% Test could be refined
    \ifboolexpr{ test {\ifdefstring{\lastname}{#1}}}
    {\addtocategory{filteredauthor}{\thefield{entrykey}}}{}}
}
\makeatother

\AtDataInput{%Filter for last name
    \indexnames[Filterauthor][1-100]{author}%Test auf alle 
}
\begin{document}
\section{The normal document}
Normal document with a cite \cite{greenwade93} and another cite \cite{goossens95}.
\printbibliography

\section{Later...}
Later in the document there should be a list of all publications from Goossens only.
\begin{refsection}[\jobname.bib]
\nocite{*}
    \printbibliography[title={Publications of Goossens},category=filteredauthor]

\end{refsection}
\end{document}

在 .bbl 文件上运行 biber 后,你会发现真正的问题:文件中引用的条目出现了两次,因为它们是由 nocite 命令触发的。对于这个例子来说,这实际上不是一个问题,但对于巨大的 bibfiles 来说,这将是一个问题。如果可以仅使用 declaredsourcemap 过滤 refsection 1,这个问题就很容易解决了

谨致问候,Stefan

答案1

现在,使用目前在 Sourceforge 上处于 DEV 状态的 biblatex 3.5/biber 2.6 可以实现这一点。sourcemaps 中的命令有一个refsection选项\map,可以强制将包含的映射步骤仅应用于特定的参考部分。

相关内容