% Distinguish between "real" journals and preprint sites.
\defbibcheck{formal}{
  \ifboolexpr{
    test {\iffieldequalstr{journaltitle}{CoRR}}
    or
    test {\iffieldequalstr{journaltitle}{bioRxiv}}
  }
  {\skipentry}
  {}
}

\defbibcheck{informal}{%
  \ifboolexpr{
    test {\iffieldequalstr{journaltitle}{CoRR}}
    or
    test {\iffieldequalstr{journaltitle}{bioRxiv}}
  }
  {}
  {\skipentry}
}


% Typeset my name in bold in the bibliography.
% https://tex.stackexchange.com/a/327046
\def\makenamesetup{%
  \def\bibnamedelima{~}%
  \def\bibnamedelimb{ }%
  \def\bibnamedelimc{ }%
  \def\bibnamedelimd{ }%
  \def\bibnamedelimi{ }%
  \def\bibinitperiod{.}%
  \def\bibinitdelim{~}%
  \def\bibinithyphendelim{.-}}
\newcommand*{\makename}[2]{\begingroup\makenamesetup\xdef#1{#2}\endgroup}

\newcommand*{\boldname}[3]{%
  \def\lastname{#1}%
  \def\firstname{#2}%
  \def\firstinit{#3}}
\boldname{}{}{}

% Patch new definitions
\renewcommand{\mkbibnamegiven}[1]{%
  \ifboolexpr{ ( test {\ifdefequal{\firstname}{\namepartgiven}} or test {\ifdefequal{\firstinit}{\namepartgiven}} ) and test {\ifdefequal{\lastname}{\namepartfamily}} }
  {\mkbibbold{#1}}{#1}%
}

\renewcommand{\mkbibnamefamily}[1]{%
  \ifboolexpr{ ( test {\ifdefequal{\firstname}{\namepartgiven}} or test {\ifdefequal{\firstinit}{\namepartgiven}} ) and test {\ifdefequal{\lastname}{\namepartfamily}} }
  {\mkbibbold{#1}}{#1}%
}

% Typeset my name in bold.
\boldname{Ivanov}{Sergiu}{}


\begin{refsection}[bib/sivanov-dblp.bib,bib/sivanov-extra.bib]

\nocite{*}

\subsection*{Book chapters}
\label{sec:chapters}

\newrefcontext[sorting=ydnt,labelprefix=ch]
\printbibliography[
  heading=none,
  type=inbook
]

\subsection*{Peer-reviewed journals}
\label{sec:journals}

\newrefcontext[sorting=ydnt,labelprefix=j]
\printbibliography[
  heading=none,
  type=article,
  check=formal
]

\subsection*{Conference proceedings}
\label{sec:proceedings}

\newrefcontext[sorting=ydnt,labelprefix=c]
\printbibliography[
  heading=none,
  type=inproceedings
]

\subsection*{Theses}
\label{sec:theses}

\newrefcontext[sorting=ydnt,labelprefix=t]
\printbibliography[
  heading=none,
  type=thesis
]

% \subsection*{Technical reports}
% \label{sec:reports}

% \newrefcontext[sorting=ydnt,labelprefix=r]
% \printbibliography[
%   heading=none,
%   type=report
% ]

% \subsection*{Preprints}
% \label{sec:informal}

% \newrefcontext[sorting=ydnt,labelprefix=p]
% \printbibliography[
%   heading=none,
%   type=article,
%   check=informal
% ]

\end{refsection}

%%% Local Variables:
%%% TeX-engine: luatex
%%% TeX-master: "hdr"
%%% End:
