定义书目环境

定义书目环境

我尝试使用 biblatex 在同一文档中为两个不同的参考书目设置两种不同的样式。我使用关键字 procedure two 创建这两个参考书目,并找到了一种使用命令定义新 bibenvironement 的方法\defbibenvironment,然后使用命令\printbibliography[env=newenvrionment, keyword=blabla]

我使用作者年份样式作为主要参考书目,因此我在为套餐收费时使用以下选项:

\usepackage[language=auto,backend=biber,sorting=nyt,bibstyle=authoryear,citestyle=authortitle-icomp]{biblatex}

建议定义一个“主要来源”环境,类似于第一个环境,但不是显示:

作者(年份)标题,期刊,

我希望有:

期刊(年份)名称、作者。

我对使用 biblatex 还很陌生,我不明白如何使用来做这样的事情\defbibenvironment

否则,如果有另一种解决方案可用,这里是一个可编译的 MWE:

\documentclass[a4paper,12pt]{book}




\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage[main=french,english]{babel}
\usepackage{csquotes}
\usepackage[T1]{fontenc}
\usepackage[pdftex]{graphicx}
\usepackage[top=2.5cm, bottom=2.5cm, right=2cm, left=2cm, headheight = 20pt]{geometry}
\usepackage{pifont}
\usepackage{xspace}
\usepackage{setspace}
\usepackage{mathptmx}
\usepackage{parskip}
\usepackage{titlesec}
\usepackage[titletoc]{appendix}
\usepackage[hidelinks]{hyperref}
\usepackage{tocloft}
\usepackage{calc}
\usepackage{tocbibind}
\usepackage[vskip=0pt]{quoting}
\usepackage{pdfpages}



\usepackage[language=auto,backend=biber,sorting=nyt,bibstyle=authoryear,citestyle=authortitle-icomp]{biblatex}


%citer le titre du journal pour les citations 
\DeclareCiteCommand{\citejournal}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \usebibmacro{journal}
     \usebibmacro{date}
       \usebibmacro{title}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footcitejournal}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \usebibmacro{journal}
     \usebibmacro{date}
       \usebibmacro{title}}
  {\multicitedelim}
  {\usebibmacro{postnote}}  

\DeclareCiteCommand{\citerevue}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \usebibmacro{title}
     \usebibmacro{journal+issuetitle}
     \usebibmacro{date}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footciterevue}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \usebibmacro{title}
     \usebibmacro{journal+issuetitle}
     \usebibmacro{date}}
  {\multicitedelim}
  {\usebibmacro{postnote}}  


% Put editor string in parentheses
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}

% Obtenir le nom de l'éditeur pour les @incollection entre le 'in' et le titre
\renewbibmacro*{in:}{%
  \printtext{\bibstring{in}\intitlepunct}%
 \ifentrytype{article}{}{}%
 \ifentrytype{incollection}{%
  \ifnameundef{bookauthor}
    {\ifnameundef{editor}
       {\printnames{translator}%
        \setunit{\addcomma\space}%
        \usebibmacro{translator+othersstrg}%
        \clearname{translator}}
       {\printnames{editor}%
        \setunit{\addcomma\space}%
        \usebibmacro{editor+othersstrg}%
        \clearname{editor}}}
    {\ifnamesequal{author}{bookauthor}
       {}
       {\printnames{bookauthor}%
        \clearname{bookauthor}}}}%
  \newunit\newblock}

% mettre entre parenthèses le numéro de la revue dans un volume en comportant plusieurs 
 \renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
  \setunit*{\addnbspace}% 
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}



\renewbibmacro*{date}{\printdate}

\DeclareCiteCommand{\citejournal}
      {\usebibmacro{prenote}}
      {\usebibmacro{citeindex}%
        \usebibmacro{journal}
        \setunit{\addspace} % space delimiter
        \usebibmacro{date}
        \setunit{\addspace} % space delimiter
           \usebibmacro{title}}
      {\multicitedelim}
      {\usebibmacro{postnote}}


\defbibenvironment{nolabelbib}%this is the bib envirionment I found in the other topic 
  {\list
     {}
     {\setlength{\leftmargin}{\bibhang}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item}


\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{test,
  author = {Author, A.},
  date = {2011-06-12},
  title = {Some relevant article},
  journal = {Test journal},
  keywords = {primaires_articles},
},

@incollection{mhone_crossroads_1992,
     title = {The Political Economy of Malawi - An Overview},
     chapter = {1},
     author = {Guy Mhone},
     year = {1992},
     booktitle = {Malawi At The Crossroads. The Post-Colonial Political Economy},
     publisher = {\textsc{SAPES} Books},
     address = {Harare},
     pages = {1--34},
     keywords = {malawi_histoire},
},

@article{momba_peasant_1985,
author = {Momba, Jotham C.},
title = {Peasant differentiation and rural party politics in colonial Zambia},
journal = {Journal of Southern African Studies},
volume = {11},
number = {2},
pages = {281-294},
year = {1985},
keywords = {malawi_histoire},
},


\end{filecontents}

\bibliography{\jobname}

\begin{document}

Some text~\citejournal{test}.\\




Some other\cite{momba_peasant_1985}\\

and other\cite{mhone_crossroads_1992}

\printbibliography[keyword=malawi_histoire,heading=subbibliography,title={Malawi: histoire sociale}]

\printbibliography[env=nolabelbib, keyword=primaires_articles,heading=subbibliography,title={Artiles de presse et revues}]

\end{document}

我希望第二个参考书目与期刊(日期)标题环境一致。它仅使用文章。

答案1

正如我在评论中写道的,不可能使用 abibenvironment来达到你的目的,因为bibenvironments是为了格式化参考书目列表

此外,据我所知,biblatex 并没有提供混合不同参考书目风格的实施解决方案,所以您必须自己尝试找到一种方法来实现您的目标。

我的解决方案:

  1. 选择默认的书目样式(authoryear适合您的情况)
  2. 创建与默认书目样式不同的驱动程序和宏(在您的情况下为 bibdriver forarticle和-macro)author
  3. 创建并实现一个切换按钮,您可以使用它在默认书目样式和新的宏之间切换。

该解决方案(经过改编)也适用于 2 种以上的书目样式。

然而,弱点在于,您必须注意与默认参考书目样式之间的每一个差异 - 如果您想更改默认参考书目样式,您必须重新开始......


这是您更新并评论的 MWE。我删除了很多不必要的(对于我们的问题而言)宏/包。它应该向您展示了我的解决方案的想法。

除了 MWE,您还可以修改新的宏并sorting\printbibliography命令等中设置选项。

\documentclass[a4paper,12pt]{book}

\usepackage[utf8]{inputenc}
\usepackage[main=french,english]{babel}
\usepackage{csquotes}
\usepackage[T1]{fontenc}
\usepackage[top=2.5cm, bottom=2.5cm, right=2cm, left=2cm, headheight = 20pt]{geometry}
\usepackage{xspace}
\usepackage{setspace}
\usepackage[hidelinks]{hyperref}
\usepackage[language=auto,backend=biber,sorting=nyt,bibstyle=authoryear,citestyle=authortitle-icomp]{biblatex}

\usepackage{etoolbox}%added


\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{test,
  author = {Author, A.},
  date = {2011-06-12},
  title = {Some relevant article},
  journal = {Test journal},
  keywords = {primaires_articles},
},

@incollection{mhone_crossroads_1992,
     title = {The Political Economy of Malawi - An Overview},
     chapter = {1},
     author = {Guy Mhone},
     year = {1992},
     booktitle = {Malawi At The Crossroads. The Post-Colonial Political Economy},
     publisher = {\textsc{SAPES} Books},
     address = {Harare},
     pages = {1--34},
     keywords = {malawi_histoire},
},

@article{momba_peasant_1985,
author = {Momba, Jotham C.},
title = {Peasant differentiation and rural party politics in colonial Zambia},
journal = {Journal of Southern African Studies},
volume = {11},
number = {2},
pages = {281-294},
year = {1985},
keywords = {malawi_histoire},
},


\end{filecontents}


%new toggle
\newtoggle{blx@bibdriver@article:journalyear}%new toggle to set which driver is to use
\togglefalse{blx@bibdriver@article:journalyear}


% Put editor string in parentheses
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}

% Obtenir le nom de l'éditeur pour les @incollection entre le 'in' et le titre
\renewbibmacro*{in:}{%
  \printtext{\bibstring{in}\intitlepunct}%
 \ifentrytype{article}{}{}%
 \ifentrytype{incollection}{%
  \ifnameundef{bookauthor}
    {\ifnameundef{editor}
       {\printnames{translator}%
        \setunit{\addcomma\space}%
        \usebibmacro{translator+othersstrg}%
        \clearname{translator}}
       {\printnames{editor}%
        \setunit{\addcomma\space}%
        \usebibmacro{editor+othersstrg}%
        \clearname{editor}}}
    {\ifnamesequal{author}{bookauthor}
       {}
       {\printnames{bookauthor}%
        \clearname{bookauthor}}}}%
  \newunit\newblock}

% mettre entre parenthèses le numéro de la revue dans un volume en comportant plusieurs 
 \renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
  \setunit*{\addnbspace}% 
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}


%redefine author-macro so it only prints the year in the default bibdriver
\renewbibmacro*{author}{%also modified
  \ifboolexpr{
    test \ifuseauthor
    and
    not test {\ifnameundef{author}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\usebibmacro{bbx:savehash}%
        \printnames{author}%
        \iffieldundef{authortype}
          {\setunit{\addspace}}
          {\setunit{\addcomma\space}}}%
     \iffieldundef{authortype}
       {}
       {\usebibmacro{authorstrg}%
        \setunit{\addspace}}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\addspace}}%
  \iftoggle{blx@bibdriver@article:journalyear}{}{%added
  \usebibmacro{date+extrayear}}}%modified

%new bibdriver for article in the second bibliography
\newbibmacro*{article:journalyear}{%modified bibdriver for article
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{journal+issuetitle}%
  \newunit
  \usebibmacro{date+extrayear}
  \newunit
  \usebibmacro{title}%
  \newunit
  \usebibmacro{author/translator+others}%
  \newunit
  \usebibmacro{note+pages}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}


%redeclare the existing bibdriver for article
\DeclareBibliographyDriver{article}{%from standard.bbx
\iftoggle{blx@bibdriver@article:journalyear}{\usebibmacro{article:journalyear}}{%added
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
  \usebibmacro{in:}%
  \usebibmacro{journal+issuetitle}%
  \newunit
  \usebibmacro{byeditor+others}%
  \newunit
  \usebibmacro{note+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{issn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}
}



\bibliography{\jobname}


\begin{document}

\nocite{*}

\printbibliography[keyword=malawi_histoire,heading=subbibliography,title={Malawi: histoire sociale}]

\toggletrue{blx@bibdriver@article:journalyear}

\printbibliography[keyword=primaires_articles,heading=subbibliography,title={Artiles de presse et revues}]

\printbibliography[type=article,heading=subbibliography,title={All articles}]

\end{document}


输出:

在此处输入图片描述

相关内容