将不同的书目样式应用于 biblatex 中的特定 \printbibliography

将不同的书目样式应用于 biblatex 中的特定 \printbibliography

我可以通过在调用中指定来使用参考书目样式usepackage

\usepackage[style=alphabetic]{biblatex}

然后我用

\printbibliography

但是我有一些额外的引文,keyword = {recommended}我可以用过滤器单独打印printbibliography。到目前为止一切顺利。即使全局设置是,我可以将参考书目样式设置reading为特定范围吗?printbibliographyalphabetic

就像是

\printbibliography[title={Citations},notkeyword=recommended]
{
% Somehow set style=reading here
\printbibliography[title={Further reading},keyword=recommended]
}

答案1

一般来说,不可能对\priontbibliography文档中的不同调用使用不同的样式,但通常可以模拟行为。

以下解决方案通过从 复制所有相关定义来模拟阅读列表reading.bbx。然后,问题只是这些定义何时执行,因为两个书目都使用了一些设置。幸运的是,这里所有有问题的定义都可以推迟到最后一分钟,并且不会发生冲突。这可能并不总是可行的,在这种情况下,我们可能必须重命名宏或以不同的方式解决这个问题。

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=alphabetic]{biblatex}

\makeatletter
\InitializeBibliographyStyle{%
  \global\undef\bbx@lasthash}

\defbibenvironment{readingbib}
  {\mkreadingbib
   \list
     {}
     {\setlength{\leftmargin}{0pt}%
      \setlength{\itemindent}{0pt}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\bbx@item}
  
\def\bbx@item@false{%
  \itemsep2\bibitemsep
  \item\relax
  \itemsep\bibitemsep}

\def\bbx@item@true{%
  \bbx@item@full}

\def\bbx@item@full{%
  \itemsep2\bibitemsep
  \@itempenalty\z@
  \item\relax
  \begingroup
  \samepage\bfseries
  \def\finentrypunct{\strut}%
  \usebibmacro{entryhead:full}%
  \ifbool{bbx:entrykey}
    {\def\newblockpunct{%
       \nobreak\hskip\z@skip\strut
       \hfill\penalty100\hskip1em\relax
       \hbox{}\nobreak\hfill\strut}%
     \def\finentrypunct{%
       \parfillskip\z@\finalhyphendemerits\z@
       \par\nobreak}%
     \newblock
     \printfield{entrykey}}
    {}%
  \finentry
  \endgroup
  \hrule height 1.25pt\relax
  \itemsep\bibitemsep
  \@itempenalty\@M
  \item\strut
  \@itempenalty\z@}

\def\bbx@item@name{%
  \iffieldequals{fullhash}{\bbx@lasthash}
    {\bbx@item@false}
    {\itemsep2\bibitemsep
     \@itempenalty\z@
     \item\relax
     \begingroup
     \samepage\bfseries
     \def\finentrypunct{\strut}%
     \usebibmacro{entryhead:name}%
     \finentry
     \endgroup
     \hrule height 1.25pt\relax
     \itemsep\bibitemsep
     \@itempenalty\@M
     \item\strut
     \@itempenalty\z@}}

\newbool{bbx:entrykey}
\newbool{bbx:annotation}
\newbool{bbx:abstract}
\newbool{bbx:library}
\newbool{bbx:file}

\DeclareBiblatexOption{global,type,entry}[boolean]{entryhead}[true]{%
  \ifcsdef{bbx@item@#1}
    {\letcs\bbx@item{bbx@item@#1}}
    {\PackageError{biblatex}
       {Invalid option 'header=#1'}
       {Valid values: header=true, false, full, name.}}}
\DeclareBiblatexOption{global,type,entry}[boolean]{entrykey}[true]{%
  \setbool{bbx:entrykey}{#1}}
\DeclareBiblatexOption{global,type,entry}[boolean]{annotation}[true]{%
  \setbool{bbx:annotation}{#1}}
\DeclareBiblatexOption{global,type,entry}[boolean]{abstract}[true]{%
  \setbool{bbx:abstract}{#1}}
\DeclareBiblatexOption{global,type,entry}[boolean]{library}[true]{%
  \setbool{bbx:library}{#1}}
\DeclareBiblatexOption{global,type,entry}[boolean]{file}[true]{%
  \setbool{bbx:file}{#1}}

\ExecuteBibliographyOptions{loadfiles,entryhead,entrykey,annotation,abstract,library,file}

\newbibmacro*{entryhead:full}{%
  \printnames[labelname][-1]{labelname}%
  \setunit*{\addcolon\space}%
  \printfield{labeltitle}}

\newbibmacro*{entryhead:name}{%
  \ifnameundef{labelname}
    {\printfield{labeltitle}}
    {\printnames[labelname]{labelname}}%
  \savefield{fullhash}{\bbx@lasthash}}

\newbibmacro*{entrytail}{%
  \newunit\newblock
  \begingroup
  \def\newblockpunct{\item}%
  \ifbool{bbx:annotation}
    {\usebibmacro{annotation}%
     \newunit\newblock}
    {}%
  \ifbool{bbx:abstract}
    {\usebibmacro{abstract}%
     \newunit\newblock}
    {}%
  \ifbool{bbx:file}
    {\printfield{file}%
     \newunit\newblock}
    {}%
  \ifbool{bbx:library}
    {\printfield{library}%
     \newunit\newblock}
    {}%
  \endgroup}

\newcommand*{\mkreadingbib}{%
  \DeclareNameAlias{author}{default}%
  \DeclareNameAlias{editor}{default}%
  \DeclareNameAlias{translator}{default}%
  %
  \DeclareNameWrapperAlias{author}{default}%
  \DeclareNameWrapperAlias{editor}{default}%
  \DeclareNameWrapperAlias{translator}{default}%
  %
  \DeclareFieldFormat{entrykey}{\mbox{\bfseries##1}}%
  \DeclareFieldFormat{annotation}{\bibstring{annotation}\addcolon\space ##1}%
  \DeclareFieldFormat{abstract}{\bibstring{abstract}\addcolon\space ##1}%
  \DeclareFieldFormat{library}{\bibstring{library}\addcolon\space ##1}%
  \DeclareFieldFormat{file}{\bibstring{file}\addcolon\space \url{##1}}%
  \DeclareFieldFormat{shorthandwidth}{##1}%
  %
  \setlength{\bibitemsep}{0.5\baselineskip}%
  \setlength{\bibparsep}{0pt}%
  %
  \renewbibmacro*{finentry}{%
    \ifbibliography
      {\usebibmacro{entrytail}}
      {}%
    \finentry}}
\makeatother


\begin{filecontents}{\jobname.bib}
@book{elk,
  author    = {Anne Elk},
  title     = {A Theory on Brontosauruses},
  year      = {1972},
  publisher = {Monthy \& Co.},
  location  = {London},
  keywords  = {recommended},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \autocite{sigfridsson}
\nocite{elk}

\printbibliography[title={Citations},notkeyword=recommended]
\printbibliography[title={Further reading},keyword=recommended,env=readingbib]
\end{document}

按字母顺序排列的引文和阅读清单

相关内容