使用 BibLaTeX 源映射缩进附录

使用 BibLaTeX 源映射缩进附录

我正在尝试制作一个带注释的参考书目,其中包含每个条目的摘要段落,以便每个参考书目的附录出现在比条目本身深一个缩进级别的新行上。

对于每个条目

addendum = {Text.}

以下似乎运行良好,产生了我想要看到的输出格式:

addendum = {\paragraph\indent{Text.}\\}

我正在尝试使用以下命令执行自动转换:

\DeclareSourcemap{
    \maps[datatype=bibtex]{
        \map{
            \step[fieldsource=addendum, 
                match=\regexp{(.*)},
                fieldset=addendum,
                replace={\\paragraph\{\\indent $1\} \\}
            ]
        }
    }
}

但是,我似乎无法在替换字段中正确转义字符,并且 LaTeX 会产生错误:

Undefined control sequence.
\\  ->\let \reserved@e 
                       \relax \let \reserved@f \relax \@ifstar {\let \reserv...
l.68 }

我完全搞不懂这一点——我是否错误地定义了输出正则表达式?

编辑:最小工作示例:

测试文件

@article{test,
  author    = {Luigi P. Cordella and
               Pasquale Foggia and
               Carlo Sansone and
               Mario Vento},
  title     = {A (Sub)Graph Isomorphism Algorithm for Matching Large Graphs},
  journal   = {{IEEE} Trans. Pattern Anal. Mach. Intell.},
  volume    = {26},
  number    = {10},
  pages     = {1367--1372},
  year      = {2004},
  doi       = {10.1109/TPAMI.2004.75},
  timestamp = {Sat, 12 Mar 2016 09:04:02 +0100},
  addendum = {This is a test of simple annotations.}
}

@article{test2,
  author    = {Luigi P. Cordella and
               Pasquale Foggia and
               Carlo Sansone and
               Mario Vento},
  title     = {A (Sub)Graph Isomorphism Algorithm for Matching Large Graphs},
  journal   = {{IEEE} Trans. Pattern Anal. Mach. Intell.},
  volume    = {26},
  number    = {10},
  pages     = {1367--1372},
  year      = {2004},
  doi       = {10.1109/TPAMI.2004.75},
  timestamp = {Sat, 12 Mar 2016 09:04:02 +0100},
  addendum = {\paragraph\indent{\textbf{Annotation:} This is a test of simple annotations using biblatex.}\\}
}

测试.tex

\documentclass[a4]{article}
\usepackage[backend=biber]{biblatex}

\bibliography{test}

% Sourcemap is placed here.

\begin{document}

Test 1 \cite{test}
Test 2 \cite{test2}

\printbibliography

\end{document}

其中测试 1 是转换前的引用,测试 2 是所需的输出。

答案1

你不需要使用\DeclareSourcemap,一个简单的

\DeclareFieldFormat{addendum}{\paragraph\indent{\textbf{Annotation:}\addspace#1}\\}

足够了:

\documentclass{article} % [a4] is not a correct option
\usepackage[english]{babel}
\usepackage{filecontents}
\begin{filecontents}{test.bib}
@article{test,
    author    = {Luigi P. Cordella and
        Pasquale Foggia and
        Carlo Sansone and
        Mario Vento},
    title     = {A (Sub)Graph Isomorphism Algorithm for Matching Large Graphs},
    journal   = {{IEEE} Trans. Pattern Anal. Mach. Intell.},
    volume    = {26},
    number    = {10},
    pages     = {1367--1372},
    year      = {2004},
    doi       = {10.1109/TPAMI.2004.75},
    timestamp = {Sat, 12 Mar 2016 09:04:02 +0100},
    addendum = {This is a test of simple annotations.}
}
@article{test2,
    author    = {Luigi P. Cordella and
        Pasquale Foggia and
        Carlo Sansone and
        Mario Vento},
    title     = {A (Sub)Graph Isomorphism Algorithm for Matching Large Graphs},
    journal   = {{IEEE} Trans. Pattern Anal. Mach. Intell.},
    volume    = {26},
    number    = {10},
    pages     = {1367--1372},
    year      = {2004},
    doi       = {10.1109/TPAMI.2004.75},
    timestamp = {Sat, 12 Mar 2016 09:04:02 +0100},
    addendum = {This is a test of simple annotations using biblatex.}
}
\end{filecontents}

\usepackage[backend=biber]{biblatex} 
\usepackage{csquotes} % added
% New format for addendum field
\DeclareFieldFormat{addendum}{\paragraph\indent{\textbf{Annotation:}\addspace#1}\\}
\addbibresource{test.bib} % Not \bibliography{test}

\begin{document}

Test 1 \cite{test}
Test 2 \cite{test2}

\printbibliography

\end{document}

在此处输入图片描述

PS = 我还更改了你的 mwe 的一些代码行,请参阅注释。

相关内容