Now that I got most of my pieces in place, I'm trying to work my custom "\printbibliography" command. I'm using the "article" class, but I take the.

In short, I need to create a custom command which create 2 types of bilbigraphy, depending on the presence of cited material of custom type "message". But the same would apply to any bibliography type, so I slightly change my code so that the "message" type is any kind of "X" entry type.

I need the following :

  • A bibliograhphy heading, appearing in the Table of content
  • A conditional test on the existence of a type of entries.
    • If no element of type "X" is present, then I print the bibliography
    • If at least 1 element of type "X" is present I need to split the bibliography into 2 subheadings, with different title. These titles must not be in the table of content.

This code works for me, in the case "with X entry" :

\printbibheading[title={Bibliographie}, heading=bibintoc]

\printbibliography[nottype = X, heading=subbibliography, title={Doctrine}]
\printbibliography[type = X, heading=subbibliography, title={Documents Officiels}]

I'd like to change it to something like this :

if(bibliography not contains any X entry type)
    \printbibliography[title={Bibliographie}, heading=bibintoc]
\printbibheading[title={Bibliographie}, heading=bibintoc]
\printbibliography[nottype = X, heading=subbibliography, title={Doctrine}]
\printbibliography[type = X, heading=subbibliography, title={Documents Officiels}]


  1. Is there a command to code this part "bibliography not contains any X entry type" ?
  2. What is the correct code for and if-else form in this type of context ?

Accepted answer

I simply copy-pasted the code of @moewe Then I replaced with the relevant custom type (@message)

And it worked hassle-free !


Let's for the moment assume your "type X" is @online.

First we need to count the number of entries for each type, this is done in \AtDataInput. In \printlegalbibliography we only need to check if there were any @online entries


\usepackage[style=authoryear, backend=biber]{biblatex}



    {\printbibheading[title={Bibliographie}, heading=bibintoc]%
     \printbibliography[nottype = online, heading=subbibliography, title={Doctrine}]%
     \printbibliography[type = online, heading=subbibliography, title={Documents Officiels}]}
    {\printbibliography[title={Bibliographie}, heading=bibintoc]}}

\section{Two online sources}

\section{No online sources}

enter image description here

  • Hi, this is perfect. At the moment, I only plan to use a single bibliography for my document, hence the first proposition is working just fine, thanks ! Edit: actually, there is only a single version of the code now, so I'll test it again tomorrow with your version. – XaWin Apr 23 '18 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.