8

Biblatex allows multiple bibliographies to be printed. How do I make one bilbiography use author-year style while make another use a numerical style? I've heard that this is bad typography but I want to do it to distinguish between actual references to literature (author-year) and image credits (which I hope to do numerically).

I've read through the Biblatex documentation and it doesn't seem to help.

lockstep
  • 250,273
Herng Yi
  • 615

2 Answers2

9

After much searching on Tex.StackExchange, I put together a hack that produced this:

enter image description here

I hope my code will be of use to others who want to do something similar.

Code:

\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}

The file Bibliography.bib contains:

@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/},
}
Herng Yi
  • 615
1

Talking about distinguishing between literature and credits, I need something similar.

So, an experiment: (not in mixing two styles, but in having two streams of information)

Using an extended author-title style as a base (ext-authortitle-ibid) to make things easier, and adding photographer and photoname as fields to use in an @photo bib entrytype, and using a counter to number the cited photos in sequence and printing that number as part of the citation (with a custom \photocite), and a corresponding bib driver (\DeclareBibliographyDriver{photo}), and using a keyword, "photo", to split the bibliographies, and remembering to reset the photocounter to zero just before the photo bibliography prints (and to keep the photo bibliography unsorted as well (via a refcontext) so it, too, is in citation order), we get:

image credits separate from references

MWEB

\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}

Being able to classify the data into categories is key: entrytype and keyword help here (and also category, for that matter). The information could even be stored in, say, the @article entrytype with appropriate use of \ifentrytype and ifkeyword (manual: 4.6.2 Stand-alone Tests, at p 233). There is also an entrysubtype available, for even greater granularity.

Printing the citations rotated sideways (and/or as part of captions) is also possible.

On a different solution path, different bib environments (to define what gets printed as the lookup label) combined with different sorting schemes is another methodology, since bibliographies are "just" list environments.

Cicada
  • 10,129