在 Biblatex 中混合书目样式

在 Biblatex 中混合书目样式

Biblatex 允许打印多个参考书目。如何让一个参考书目使用作者-年份样式,而另一个使用数字样式?我听说这是糟糕的排版,但我想这样做来区分对文献的实际引用(作者-年份)和图像来源(我希望以数字方式表示)。

我已经读完了Biblatex 文档但似乎没有帮助。

答案1

在 Tex.StackExchange 上进行大量搜索之后,我整理出了一个可以产生以下效果的 hack:

在此处输入图片描述

我希望我的代码能够对想要做类似事情的人有所帮助。

代码:

\documentclass{article}
\usepackage[backend=biber, %I think this should work for BibTex too, but I'm not sure.
  style=authoryear, %Set author-year as the default style; later hacks will produce a fake numeric style.
  defernumbers %Works together with resetnumbers so that the numbering of numeric entries is independent of the author-year citations.
  ]{biblatex}
\addbibresource{Bibliography.bib}

%Copied from numeric.cbx to imitate numerical citations.
\providebool{bbx:subentry}
\newbibmacro*{citenum}{%Note: the original macro was called "cite". I did not redefine "cite", but instead defined a new macro "citenum", because the author-year citations use the "cite" macro too. "\renewbibmacro*{cite}" would have caused all the author-year citations to become numeric too.
  \printtext[bibhyperref]{%If you ever want to use hyperref
    \printfield{prefixnumber}%
    \printfield{labelnumber}%
    \ifbool{bbx:subentry}
      {\printfield{entrysetcount}}
      {}}}

%Copied from numeric.cbx to define a new numeric citation command for @online entries.
\DeclareCiteCommand{\conline}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citenum}}%Note: this was originally "cite" but I changed it to "citenum" to avoid clashes with the author-year style.
  {\multicitedelim}
  {\usebibmacro{postnote}}

\begin{document}
Cite books, \parencite{Book} \parencite{Book2}

Cite online stuff, \conline{Online} \conline{Online2}

%Print the normal author-year bibliography
\printbibliography[nottype=online]

%Redefine the bibliography environment to imitate the numeric citation style
\defbibenvironment{bibliography}
{\list
{\printfield[labelnumberwidth]{labelnumber}}
{\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\labelsep}{1em}
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}\hspace{-1.1em}}
\printbibliography[type=online,title=Online,resetnumbers]
\end{document}

该文件Bibliography.bib包含:

@book{Book,
  author    = {Author},
  title     = {Title},
  publisher = {Publisher},
  year      = {2014},
}

@book{Book2,
  author    = {Author2},
  title     = {Title2},
  publisher = {Publisher2},
  year      = {2015},
}

@online{Online,
  author = {Author},
  title = {Title},
  titleaddon = {titleaddon},
  subtitle = {subtitle},
  url= {http://tex.stackexchange.com/},
}

@online{Online2,
  author = {Author2},
  title = {Title2},
  titleaddon = {titleaddon2},
  subtitle = {subtitle2},
  url= {http://tex.stackexchange2.com/},
}

答案2

说到区分文献和学分,我需要一些类似的东西。

因此,进行一个实验:(不是混合两种风格,而是拥有两条信息流)

使用扩展的作者标题样式作为基础(ext-authortitle-ibid)使事情变得更容易,并添加photographerphotoname作为在 bib entrytype 中使用的字段@photo,并使用计数器按顺序对引用的照片进行编号并将该编号作为引用的一部分打印(使用自定义\photocite),以及相应的 bib 驱动程序(\DeclareBibliographyDriver{photo}),并使用关键字“照片”来拆分参考书目,并记得在打印照片参考书目之前将照片计数器重置为零(并保持照片参考书目也未排序(通过 refcontext)以便它也按引用顺序排列),我们得到:

图片来源与参考资料分开

移动网络

\RequirePackage{filecontents}

%dbx
%bbx
%cbx
%lbx
%bib
%ist


%:::::::::::::::::::::::::::::::::::::::::::::
\begin{filecontents*}{photo.dbx}
\DeclareDatamodelFields[type=field, datatype=literal]{
  photoname,
  photographer,
}
\DeclareLanguageMapping{english}{english-photo}


\endinput
\end{filecontents*}
%====================================





%:::::::::::::::::::::::::::::::::::::::::::::
\begin{filecontents*}{photo.bbx}
\ProvidesFile{photo.bbx}[2006/04/09 v1.0 biblatex bibliography style]
\RequireBibliographyStyle{ext-authortitle-ibid}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareBibliographyDriver{photo}{%
    \usebibmacro{begentry}
    \usebibmacro{photo-count}\addspace\usebibmacro{photoby-bib}
    \usebibmacro{finentry}
}




\DeclareSortingTemplate{photosort}{
\sort{
    \field{photographer}
    }
\sort{
    \field{photoname}
    }
}



\newcounter{photonum}
\setcounter{photonum}{0}
\newcommand\incrphotonum{\refstepcounter{photonum}}


\endinput
\end{filecontents*}
%====================================



%:::::::::::::::::::::::::::::::::::::::::::::
\begin{filecontents*}{photo.cbx}
\ProvidesFile{photo.cbx}[2019-04-09 v1.0 biblatex citation style]
\RequireCitationStyle{ext-authortitle-ibid}

%~~~~~~~~~~~~~~~~~~~
% fieldformats: photo
\DeclareFieldFormat{photoname}{\mkbibquote{#1}}
\DeclareFieldFormat{photographer}{#1}


%~~~~~~~~~~~~~~~~~~~
% bibmacros
%======================= photoname
\newbibmacro{getphotoname}{%
      \printfield{photoname}%
}

%======================= photographer
\newbibmacro{getphotographer}{%
    \printfield{photographer}%
}
%======================= photoby-caption
\newbibmacro{photoby-caption}{%
      \iffieldundef{photoname}{}{\usebibmacro{getphotoname}}%
    \iffieldundef{photographer}{}{\addspace\mkbibparens{\usebibmacro{getphotographer}}}%
}


%======================= photoby-bib
\newbibmacro{photoby-bib}{%
      \iffieldundef{photoname}{}{\usebibmacro{getphotoname}}%
    \iffieldundef{photographer}{}{\addcomma\addspace\bibstring{photoby}\addspace\usebibmacro{getphotographer}\isdot}%
}


\newbibmacro{photo-count}{%
\incrphotonum\mkbibbrackets{\thephotonum}
}

%~~~~~~~~~~~~~~~~~~~
% citecommands
%======================= photocite
\DeclareCiteCommand{photocite}%
%@@@@@@@@@@@@@@@@ prenote
{%
    \usebibmacro{prenote}%
}% 
%@@@@@@@@@@@@@@@@ item
{%
\ifentrytype{photo}%
{%photo ==================================
    \usebibmacro{photo-count}\addspace\usebibmacro{photoby-caption}%
}{}}%
%@@@@@@@@@@@@@@@@ delim
{}%
%@@@@@@@@@@@@@@@@ postnote
{%
    \usebibmacro{postnote}% 
}






\endinput
\end{filecontents*}
%====================================

%====================================
\begin{filecontents*}{english-photo.lbx}
  \ProvidesFile{english-photo.lbx}[2019/04/09 english with additions for photo citations]
  \InheritBibliographyExtras{english}
  \NewBibliographyString{photoby}
  \DeclareBibliographyStrings{%
    inherit   = {english},
    photoby = {{photo by}{photo by}},
  }

\endinput
\end{filecontents*}
%====================================






%====================================
\begin{filecontents*}{\jobname.bib}

@photo{ph1,
photoname={The Woods},
photographer={M Woods},
keywords={photo},
}

@photo{ph2,
photoname={The Sky},
photographer={A B Skier},
keywords={photo},
}
@photo{ph3,
photoname={The Air},
photographer={O Ayre},
keywords={photo},
}
@photo{ph4,
photoname={The Lake},
photographer={N Lakes},
keywords={photo},
}
@photo{ph5,
photoname={The Sea},
photographer={R Seasons},
keywords={photo},
}

\end{filecontents*}
%====================================








\documentclass[12pt]{article}
\usepackage{fontspec}
\setmainfont{Noto Serif}
\usepackage[british]{babel}
\usepackage{csquotes}


\usepackage[
    style=photo, 
        ]{biblatex}
\defbibnote{abibnote}{Plain bibliography}
\defbibnote{photobibnote}{List of photos}


\usepackage{xcolor}
\pagecolor{red!3}

\addbibresource{biblatex-examples.bib}
\addbibresource{\jobname.bib}

\begin{document}
\section{Introduction}
Some plain cites: 
\cite{kastenholz} 
\cite{vangennep}

Some photo cites: air: \photocite{ph3}, sky: \photocite{ph2}, and sea: \photocite{ph5}. 

\printbibliography[prenote=abibnote,notkeyword=photo]


\setcounter{photonum}{0}
\newrefcontext[sorting=none]
\printbibliography[
    keyword=photo,
    title={Photos},
    prenote=photobibnote,
    ]

\begin{center}
\textemdash
\textemdash
\end{center}
\end{document}

能够将数据分类是关键:keyword这里的 entrytype 和 help(以及category,就此而言)。信息甚至可以存储在 entrytype 中,@article并适当使用\ifentrytypeifkeyword(手册:4.6.2 独立测试,第 233 页)。还有一个entrysubtype可用的,以实现更大的粒度。

还可以打印横向旋转的引文(和/或作为标题的一部分)。

在不同的解决方案路径上,不同的 bib 环境(定义打印为查找标签的内容)与不同的排序方案相结合是另一种方法,因为书目“只是”列表环境。

相关内容