[Tex/LaTex] Separating two types of articles from bibtex using \printbibliography

biblatexsubdividing

I am not an expert on LaTeX/TeX but know very basic of it only. I have a .bib file where I put all my "articles" like this in the .bib:

@article{,
      author         = "Authors1",
      title          = "{Ttile of articles}",
      collaboration  = "Collaboration",
      year           = "2012",
      ...
      ..
}

@article{,
      author         = "Authors2",
      title          = "{Ttile of articles}",
      collaboration  = "Collaboration",
      year           = "2011",
      ...
      journal        = "Phys.Lett.",  
      ..
}

The first one is un-published but it's available on the arXiv while the 2nd one is published in a journal … the difference is the line "journal" above.

I want to create two categories of published and unpublished to list the two types separately in an automated way.

How could I achieve this using \printbibliography? It will help me every time I update the list (usually quite large) as things will be taken care in an automated way.
For the moment I am using a .sty file which uses this to define bib categories:

% Bibliography categories                               
\def\makebibcategory#1#2{\DeclareBibliographyCategory{#1}\defbibheading{#1}{\section*{#2}}}
\makebibcategory{books}{Books}                          
\makebibcategory{papers}{Refereed Research Papers}      
\makebibcategory{chapters}{Book chapters}               
\makebibcategory{conferences}{Papers in Conference Proceedings}
\makebibcategory{techreports}{Unpublished working papers}
\makebibcategory{bookreviews}{Book reviews}             
\makebibcategory{editorials}{Editorials}                
\makebibcategory{phd}{PhD Thesis}                       
\makebibcategory{subpapers}{Submitted Papers to Journals and arXiv}
\makebibcategory{curpapers}{Current projects}           

\setlength{\bibitemsep}{2.65pt}                         
\setlength{\bibhang}{.8cm}                              
\renewcommand{\bibfont}{\small}                         

\renewcommand*{\bibitem}{\addtocounter{papers}{1}\item \mbox{}\hskip-0.85cm\hbox to 0.85cm{\hfill\arabic{papers}.~~}}
\defbibenvironment{bibliography}                        
{\list{}                                                
  {\setlength{\leftmargin}{\bibhang}%                   
   \setlength{\itemsep}{\bibitemsep}%                   
   \setlength{\parsep}{\bibparsep}}}                    
{\endlist}                                              
{\bibitem}                                              

\newenvironment{publications}{\section{\LARGE Publications}\label{papersstart}\vspace*{0.2cm}\small
\titlespacing{\section}{0pt}{1.5ex}{1ex}\itemsep=0.00cm 
}{\label{papersend}\addtocounter{sumpapers}{-1}\refstepcounter{sumpapers}\label{sumpapers}}

\def\printbib#1{\printbibliography[category=#1,heading=#1]\lastref{sumpapers}} 

A working example would be of great help. Thanks a lot in advance.

Best Answer

Creating different categories for published and unpublished articles can be done by testing for every @article entry if the field journaltitle (for which the traditional journal is a synonym) is defined.

\documentclass{article}

\usepackage[defernumbers=true]{biblatex}

\DeclareBibliographyCategory{articlepublished}
\DeclareBibliographyCategory{articleunpublished}

\AtEveryCitekey{%
  \ifentrytype{article}{%
    \iffieldundef{journaltitle}{%
      \addtocategory{articleunpublished}{\thefield{entrykey}}%
    }{%
      \addtocategory{articlepublished}{\thefield{entrykey}}%
    }%
  }{%
  }%
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{AX12,
      author         = "Authors1",
      title          = "{Ttile of articles}",
      collaboration  = "Collaboration",
      year           = "2012",
}
@article{AY11,
      author         = "Authors2",
      title          = "{Ttile of articles}",
      collaboration  = "Collaboration",
      year           = "2011",
      journal        = "Phys.Lett.",  
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

\cite{AX12,AY11}

\printbibliography[category=articlepublished,title={Published Articles}]

\printbibliography[category=articleunpublished,title={Unpublished Articles}]

\end{document}

enter image description here

Related Question