biblatex,biber,两年之间可以 \printbibliography 吗?

biblatex,biber,两年之间可以 \printbibliography 吗?

使用biblatexBiber,是否可以\printbibliography在一个部分中打印从(假设)2003 年至 2008 年的所有参考书目()?然后在另一个部分中打印从 2009 年至 2016 年的所有参考书目?

答案1

这可以通过 Biber 使用正则表达式动态重写书目信息的功能来实现。此示例仅打印 2003-2008 和 2009-2015 范围内的条目,即使文档引用了从 2001 年到 2016 年的所有条目。

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}

@Article{a,
  date =     2001,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{b,
  date =     2003,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{c,
  date =     2005,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{d,
  date =     2007,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{e,
  date =     2009,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{f,
  date =     2011,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{g,
  date =     2013,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{h,
  date =     2015,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{i,
  date =     2016,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

\end{filecontents*}

\usepackage[backend=biber]{biblatex}
\addbibresource{\jobname.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \step[fieldsource=date,  match=\regexp{200([3-8])}, %
            fieldset=keywords, fieldvalue={ONE}, append, ]
      \step[fieldsource=date,  match=\regexp{(2009|201[0-5])}, %
            fieldset=keywords, fieldvalue={TWO}, append, ]
}}}

\begin{document}
\nocite{*}

\printbibliography[keyword=ONE, title={Group One (2003--2008)}]

\printbibliography[keyword=TWO, title={Group Two (2009--2015)}]

\end{document}

答案2

最简单的方法是定义两个check具有年份条件的

\defbibcheck{old}{
  \ifnumless{\thefield{year}}{2003}
    {\skipentry}
    {\ifnumgreater{\thefield{year}}{2008}
      {\skipentry}
      {}
    }
}

\defbibcheck{new}{
  \ifnumless{\thefield{year}}{2009}
    {\skipentry}
    {\ifnumgreater{\thefield{year}}{2016}
      {\skipentry}
      {}
    }
}

然后使用check\printbibliography` 选项,即:

\printbibliography[check=old, title={2003--2008}]

\printbibliography[check=new, title={2009-2016}]

答案3

jon 使用 Biber 正则表达式的回答非常精彩,但您也可以在文档中使用 bibcheck。我们只需要将 years 与etoolbox的功能进行比较。不幸的是,我们只有<>,所以我们的检查将如下所示

\defbibcheck{yrs0308}{%
  \iffieldint{year}
    {\ifboolexpr{test {\ifnumgreater{\thefield{year}}{2002}} and test {\ifnumless{\thefield{year}}{2009}}}
      {}
      {\skipentry}}
    {\skipentry}}

\defbibcheck{yrs1015}{%
  \iffieldint{year}
    {\ifboolexpr{test {\ifnumgreater{\thefield{year}}{2009}} and test {\ifnumless{\thefield{year}}{2016}}}
      {}
      {\skipentry}}
    {\skipentry}}

完整 MWE(改编自 jon 的)

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}

@Article{a,
  date =     2001,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{b,
  date =     2003,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{c,
  date =     2005,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{d,
  date =     2007,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{e,
  date =     2009,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{f,
  date =     2011,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{g,
  date =     2013,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{h,
  date =     2015,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

@Article{i,
  date =     2016,
  author =   {Author, Amy},
  title =    {Title},
  journaltitle = {Journal},
  volume =   10,
  number =   4,
  pages =    {100-141}}

\end{filecontents*}

\usepackage[backend=biber]{biblatex}
\addbibresource{\jobname.bib}

\defbibcheck{yrs0308}{%
  \iffieldint{year}
    {\ifboolexpr{test {\ifnumgreater{\thefield{year}}{2002}} and test {\ifnumless{\thefield{year}}{2009}}}
      {}
      {\skipentry}}
    {\skipentry}}

\defbibcheck{yrs1015}{%
  \iffieldint{year}
    {\ifboolexpr{test {\ifnumgreater{\thefield{year}}{2009}} and test {\ifnumless{\thefield{year}}{2016}}}
      {}
      {\skipentry}}
    {\skipentry}}


\begin{document}
\nocite{*}

\printbibliography[check=yrs0308, title={Group One (2003--2008)}]
\printbibliography[check=yrs1015, title={Group Two (2009--2015)}]
\end{document}

答案4

非常感谢。它帮了我大忙。不过,我不得不稍微修改一下代码才能让它工作。可能是因为我有另一个 \map (???)... 我不理解所有内容,而且 biblatex 的文档相当冗长!

\DeclareSourcemap{
 \maps[datatype=bibtex]{
  \map[overwrite=true]{
        \step[fieldsource=author, match=myself, final]
        \step[fieldset=keywords, fieldvalue={,}, append]
        \step[fieldset=keywords, fieldvalue=own, append]
}
     \map[overwrite=true]{
        \step[fieldsource=year,  match=\regexp{200([3-8])},final]
        \step[fieldset=keywords, fieldvalue={,}, append]
    \step[fieldset=keywords, fieldvalue=ONE, append]
}
     \map[overwrite=true]{
        \step[fieldsource=year,  match=\regexp{(2009|201[0-5])},final]
        \step[fieldset=keywords, fieldvalue={,}, append]
        \step[fieldset=keywords, fieldvalue={TWO}, append]
}}}
\printbibliography[keyword=own,type=article,heading=none,resetnumbers=true,keyword=ONE]

@jon,你能解释一下“final”代表什么吗?为什么

\step[fieldset=keywords, fieldvalue={,}, append]

对我来说有必要吗?

相关内容