2

I have a book with multiple bibliographies. My editor wants a special formatting for one of the bibliographies. Below is an MWE and below the MWE the explanation:

MWE:

\documentclass[]{book}


\usepackage[style=authortitle-dw,
edsuper=true,
namefont=smallcaps,
useprefix=true,
ibidemfont=smallcaps,
idemfont=smallcaps,
idembibformat=dash,
shorthandibid=true,
backref=false,
backrefstyle=none,
hyperref=true,
isbn=false,
backend=biber,
citereset=chapter,
edstringincitations=false,
bibencoding=utf8]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{quellen.bib}
@incollection{inproc1,
    Author = {Test Author},
    crossref = {proc},
    Pages = {1--10},
    Title = {Testing the Title}}

@incollection{inproc2,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the second Title}}
@incollection{inproc4,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the third Title}}
@incollection{inproc5,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the forth Title}}
@incollection{inproc6,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the fifth Title}}
@collection{proc,
    Editor = {Senor Editor and Senora Editora},
    Publisher = {Any Publisher},
    Title = {My Proceedings},
    Year = {2013},
    shorttitle = {Shorttitle}}

@inproceedings{inproc3,
    Author  = {Nother Author},
    Publisher = {Nother Publisher},
    Title   = {In Some Other Proceedings},
    Maintitle = {Main Title of Other Proceedings},
    Year     = {2001},
}
\end{filecontents}

\begin{filecontents}{literatur.bib}
    @incollection{inproc12,
        Author = {Test Author},
        crossref = {proc},
        Pages = {1--10},
        Title = {Testing the Title}}

    @incollection{inproc22,
        Author = {Test Author},
        crossref = {proc},
        Pages = {10--20},
        Title = {Testing the second Title}}

    @incollection{inproc42,
        Author = {Test Author},
        crossref = {proc},
        Pages = {10--20},
        Title = {Testing the third Title}}

    @incollection{inproc52,
        Author = {Test Author},
        crossref = {proc},
        Pages = {10--20},
        Title = {Testing the forth Title}}

    @incollection{inproc62,
        Author = {Test Author},
        crossref = {proc},
        Pages = {10--20},
        Title = {Testing the fifth Title}}

    @collection{proc2,
        Editor = {Senor Editor and Senora Editora},
        Publisher = {Any Publisher},
        Title = {My Proceedings},
        Year = {2013},
        shorttitle = {Shorttitle}}

    @inproceedings{inproc32,
        Author  = {Nother Author},
        Publisher = {Nother Publisher},
        Title   = {In Some Other Proceedings},
        Maintitle = {Main Title of Other Proceedings},
        Year     = {2001},
    }
\end{filecontents}

\addbibresource{literatur.bib}
\addbibresource{quellen.bib}

\pagestyle{empty}
\begin{document}
\cite{inproc42}\cite{inproc52}\cite{inproc62}
Test \cite{inproc12} and \cite{inproc22} and \cite{inproc32}
\cite{inproc4}\cite{inproc5}\cite{inproc6}
Test \cite{inproc1} and \cite{inproc2} and \cite{inproc3}
\printbibliography[keyword=literatur,title=Specially formatted bibliography]
\printbibliography[keyword=quellen,title=Plain old'n sturdy bibliography]
\end{document}

And my biber.conf looks like

<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
  <maps datatype="bibtex" bmap_overwrite="1">
    <map>
      <per_datasource>literatur.bib</per_datasource>
      <map_step map_field_set="KEYWORDS" map_field_value="literatur"/>
    </map>
    <map>
      <per_datasource>quellen.bib</per_datasource>
      <map_step map_field_set="KEYWORDS" map_field_value="quellen"/>
    </map>        
  </maps>
</sourcemap>
</config>

The Specially formatted bibliography looks currently like this:

enter image description here

The first entry of the list for one author should also appear in the same formatting as the second, third..., i.e. it should start in the line below the author and have a dash in front of it

Author, Test:
  - Testing the fifth title ...
  - Testing the forth title ...
11
  • But you don't want that to happen for authors that are only listed with one work, right? That means that at the point of typesetting (the first occurrence of) the author name you already have to know if there are going to follow other works by the same author. The information is, however, not available at the point of typesetting the author name.
    – moewe
    Commented Jul 25, 2017 at 14:49
  • If you want this also for authors with only one work, have a look at biblatex-philosophy's philosophy-modern.
    – moewe
    Commented Jul 25, 2017 at 14:50
  • argh, that's too sad. I think it will be ok if it is this way also for authors with only one work. Now the problem is, for the other bibliographies I would like to use biblatex-dw, because of lots of other weird formatting problems already solved with biblatex-dw. Is this possible at all?
    – Philipp
    Commented Jul 25, 2017 at 15:00
  • Wait, a minute. There might be away around that. Let me check.
    – moewe
    Commented Jul 25, 2017 at 15:01
  • Normally we could use \ifsingletitle to check if there are more works by one author. But since we split the bibliography we have no way of knowing if the other works also go into the same bibliography.... Can you explain how the two bibliography lists differ? Could we maybe use a different method than keywords? Do you have to be able to cite sources for both bibliographies in the same chapter?
    – moewe
    Commented Jul 25, 2017 at 15:06

1 Answer 1

4

Wow. I can't believe this actually works...

Here's a possible way forward.

Set the biblatex option minxrefs=2 (hopefully you are not already using this).

We use a complicated set of source maps for the heavy lifting. We set keywords based on the bib file. We create a new entry of type specialauthor containing just the author and keyword field for every entry type in literatur.bib. We set xref to point to this new entry for every item in literatur.bib.

We create a new driver to handle the entries of type specialauthor.

We turn off the printing of the editor and translator strings when printing \bibnamedash in the special bibliography.

It's not thoroughly tested, so I'd be careful. And it will definitely give odd results if you are using custom name strings. But at least it doesn't require you to make any changes to your bib data.

And putting it all together:

\documentclass{article}

\usepackage[style=authortitle-dw,
edsuper=true,
namefont=smallcaps,
useprefix=true,
ibidemfont=smallcaps,
idemfont=smallcaps,
idembibformat=dash,
shorthandibid=true,
backref=false,
backrefstyle=none,
isbn=false,
backend=biber,
edstringincitations=false,
bibencoding=utf8,
minxrefs=2]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{quellen.bib}
@incollection{inproc1,
    Author = {Test Author},
    crossref = {proc},
    Pages = {1--10},
    Title = {Testing the Title}}

@incollection{inproc2,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the second Title}}
@incollection{inproc4,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the third Title}}
@incollection{inproc5,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the forth Title}}
@incollection{inproc6,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the fifth Title}}
@collection{proc,
    Editor = {Senor Editor and Senora Editora},
    Publisher = {Any Publisher},
    Title = {My Proceedings},
    Year = {2013},
    shorttitle = {Shorttitle}}

@inproceedings{inproc3,
    Author  = {Nother Author},
    Publisher = {Nother Publisher},
    Title   = {In Some Other Proceedings},
    Maintitle = {Main Title of Other Proceedings},
    Year     = {2001},
}
\end{filecontents}

\begin{filecontents}{literatur.bib}
@incollection{inproc12,
    Author = {Test Author},
    crossref = {proc},
    Pages = {1--10},
    Title = {Testing the Title}}

@incollection{inproc22,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the second Title}}

@incollection{inproc42,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the third Title}}

@incollection{inproc52,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the forth Title}}

@incollection{inproc62,
    Author = {Test Author},
    crossref = {proc},
    Pages = {10--20},
    Title = {Testing the fifth Title}}

@collection{proc2,
    Editor = {Editor, Senor and Editora, Senora},
    Publisher = {Any Publisher},
    Title = {My Proceedings},
    Year = {2013},
    shorttitle = {Shorttitle}}

@collection{proc3,
    Editor = {Editor, Senor and Editora, Senora},
    Publisher = {Any Publisher},
    Title = {Your Proceedings},
    Year = {2013},
    shorttitle = {Shorttitle}}

@inproceedings{inproc32,
    Author  = {Nother Author},
    Publisher = {Nother Publisher},
    Title   = {In Some Other Proceedings},
    Maintitle = {Main Title of Other Proceedings},
    Year     = {2001},
}
\end{filecontents}

\addbibresource{literatur.bib}
\addbibresource{quellen.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \perdatasource{quellen.bib}
      \step[fieldset=keywords, fieldvalue={quellen}]
    }
    \map{
      \perdatasource{literatur.bib}
      \step[fieldset=keywords, fieldvalue={literatur}]
      \step[fieldset=options, fieldvalue={,}, append]
      \step[fieldsource=options, notmatch=\regexp{.*useauthor\s*=\s*false.*}, final]
      \step[fieldsource=author, match=\regexp{(.*)}, final]
      \step[entrynew={$1}, entrynewtype=specialauthor]
      \step[entrytarget={$1}, fieldset={author}, fieldvalue={$1}]
      \step[entrytarget={$1}, fieldset={keywords}, fieldvalue={literatur}]
      \step[fieldset=xref, fieldvalue={$1}]
    }
    \map{
      \perdatasource{literatur.bib}
      \step[notfield=author, final]
      \step[fieldset=options, fieldvalue={,}, append]
      \step[fieldsource=options, notmatch=\regexp{.*useeditor\s*=\s*false.*}, final]
      \step[fieldsource=editor, match=\regexp{(.*)}, final]
      \step[entrynew={$1}, entrynewtype=specialauthor]
      \step[entrytarget={$1}, fieldset={editor}, fieldvalue={$1}]
      \step[entrytarget={$1}, fieldset={keywords}, fieldvalue={literatur}]
      \step[fieldset=xref, fieldvalue={$1}]
    }
    \map{
      \perdatasource{literatur.bib}
      \step[notfield=author, final]
      \step[notfield=editor, final]
      \step[fieldset=options, fieldvalue={,}, append]
      \step[fieldsource=options, notmatch=\regexp{.*usetranslator\s*=\s*false.*}, final]
      \step[fieldsource=options, match=\regexp{.*usetranslator.*}, final]
      \step[fieldsource=translator, match=\regexp{(.*)}, final]
      \step[entrynew={$1}, entrynewtype=specialauthor]
      \step[entrytarget={$1}, fieldset={translator}, fieldvalue={$1}]
      \step[entrytarget={$1}, fieldset={options}, fieldvalue={usetranslator=true}]
      \step[entrytarget={$1}, fieldset={keywords}, fieldvalue={literatur}]
      \step[fieldset=xref, fieldvalue={$1}]
    }
  }
}

\DeclareBibliographyDriver{specialauthor}{%
  \renewcommand*{\finentrypunct}{\addcolon}%
  \ifbool{cbx:idemfull}
    {}
    {\usebibmacro{author/editor+others/translator+others}%
     \ifnameundef{labelname}
       {}
       {\setunit{\labelnamepunct}\newblock}}%
  \usebibmacro{finentry}}

\makeatletter
\AtEveryBibitem{%
  \ifboolexpr{
    test {\ifkeyword{literatur}}
    and
    not test {\ifentrytype{specialauthor}}
    and
    test {\iffieldequals{namehash}{\bbx@lasthash}}
    and
    not test {\iffirstonpage}
  }
    {\renewbibmacro*{translator+othersstrg}{}%
     \renewbibmacro*{editor+othersstrg}{}}
    {}}
\makeatother

\pagestyle{empty}
\begin{document}
\cite{inproc42}\cite{inproc52}\cite{inproc62}
Test \cite{inproc12} and \cite{inproc22} and \cite{inproc32}
\cite{inproc4}\cite{inproc5}\cite{inproc6}
Test \cite{inproc1} and \cite{inproc2} and \cite{inproc3}
\cite{proc2,proc3}
\printbibliography[keyword=literatur,title=Specially formatted bibliography]
\printbibliography[keyword=quellen,title=Plain old'n sturdy bibliography]
\end{document}

enter image description here

9
  • +1. Now that is a clever solution. Since we use the name of the author as entrykey this gave me some problem with non-ASCII author names. Potentially this also has trouble if I give the name of an author in two formats (Anne Elk vs Elk, Anne). But apart from that this really is impressive stuff.
    – moewe
    Commented Jul 26, 2017 at 9:57
  • Yes I wondered about this. To be honest I was surprised it worked with spaces. It does work OK with commas though. I tested that much. Commented Jul 26, 2017 at 10:00
  • I was surprised by the fact that spaces and commas went through that smoothly as well.
    – moewe
    Commented Jul 26, 2017 at 10:05
  • Hmm is minxrefs quite new? I am getting Package keyval error: minxrefs undefined. Should be solvable easily, let me see
    – Philipp
    Commented Jul 28, 2017 at 7:08
  • 1
    epic, thank you! This need biblatex > 2.4, just for other people's information
    – Philipp
    Commented Jul 28, 2017 at 7:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .