仅在两个拆分传记中的一个中的条目前添加标签

仅在两个拆分传记中的一个中的条目前添加标签

我在参考书目条目前使用标签,就像在像 biblatex 或 natbib 中的 authordate2 这样的书目样式?,效果很好。但是,我需要将标签限制为参考书目的第一部分(第二部分专门用于没有作者的在线资源),我使用 MWE 的过滤器进行管理。我使用的是 biblatex、biber、APA 样式、意大利语。我在 Sharelatex.com 上编辑。

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}    
\usepackage[italian]{babel}
\usepackage[babel]{csquotes}
\usepackage[style=apa,backend=biber]{biblatex}         
\DeclareLanguageMapping{italian}{italian-apa}

%LABELS
\defbibenvironment{bibliography}
  {\list
     {
        \printtext[]{%
            \begingroup
            \defcounter{maxnames}{\value{mymaxcitenames}}%
            \printnames{labelname}%
            \setunit{\nameyeardelim}%
            \printfield{labelyear}% 
            \printfield{extrayear}%
            \endgroup
            }%
        }
     {\setlength{\labelwidth}{100pt}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hfill##1\hss}
      }
  {\endlist}
  {\item}


\defbibfilter{online}{
    type=online
}

\defbibfilter{offline}{
    type=book or
    type=article or
    type=report
}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}

@online{cit1,
  title = {Title},
  url = {http://www.website.com},
  timestamp = {2013-04-11T17:20:44Z},
  titleaddon = {Example},
  urldate = {2013-04-10},
  date = {2004}
}

@report{cit2,
  author = {BBBAuthor, Name},
  title = {Title Title Title},
  url = {http://www.example.com},
  timestamp = {2013-04-11T17:20:44Z},
  titleaddon = {Website Name},
  urldate = {2013-04-10},
  date = {2004}
}

@book{cit3,
  location = {Location},
  title = {Title Title},
  timestamp = {2016-02-01T21:50:03Z},
  langid = {english},
  publisher = {Publisher},
  author = {Author, Name},
  date = {2001}
}

\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\begin{minipage}{\textwidth}

Bla bla\footnote{\cite[]{cit1}, \url{http://www.website.com}}.
Bla\footnote{\cite[]{cit2}, \url{http://www.example.com}}.
Blaaa blaa bla\footcite[]{cit3}.

\printbibliography[heading=bibintoc,filter=offline,title={Bibliography}]
\printbibliography[title={Online},filter=online,heading=subbibliography]

\end{minipage}

\end{document}

答案1

这应该像将您的新书目环境重命名为一样简单bibwithlabels

\defbibenvironment{bibliography}
  {\list
     {
        \printtext[]{%
            \begingroup
            \defcounter{maxnames}{\value{mymaxcitenames}}%
            \printnames{labelname}%
            \setunit{\nameyeardelim}%
            \printfield{labelyear}% 
            \printfield{extrayear}%
            \endgroup
            }%
        }
     {\setlength{\labelwidth}{100pt}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hfill##1\hss}
      }
  {\endlist}
  {\item}

并将其用于离线书目,选项env

\printbibliography[heading=bibintoc,filter=offline,title={Bibliography},env=bibwithlabels]
\printbibliography[title={Online},filter=online,heading=subbibliography]

相关内容