add tag
JeT
Based on [this previous question](https://topanswers.xyz/tex?q=1813), I like to put a sub bibliography at the end of my chapters. 


How can I check if the content of the subbiliography is non empty ?
(and avoid the "Empty bibliography" warning)

If the bibliography is actually empty, I'd prefer skipping any content (no heading too)


```
\documentclass{book}

\usepackage[%
	refsegment=chapter,% Pour avoir une bib per chap	
	bibencoding=inputenc,
	hyperref=auto,
	style=authoryear,
	giveninits=true,
	citestyle=alphabetic,
	sorting=nyt,
	sortcites=true,
	doi=false,
	isbn=false,
	url=false,
	eprint=false,
	autopunct=true,
	maxnames=10,%
	maxalphanames=3,%
	hyperref=true,
	abbreviate=false,
	backref=true,
	backend=biber%
]{biblatex}

\usepackage{hyperref}

\addbibresource{biblatex-examples.bib}

\renewbibmacro*{finentry}{\printfield{abstract}\finentry}

\usepackage{xpatch}
\xpretocmd{\chapter}{%
\ifnum\value{chapter}>0
  \printbibliography[segment=\therefsegment,heading=subbibliography]
\fi%
}{}{}

\begin{document}

\chapter{First chapter}

%\cite{padhye}. so no sub-bibliography with this chapter

\chapter{Second chapter}

\cite{kastenholz}, \cite{itzhaki}.

\chapter*{Bibliographie}
\addcontentsline{toc}{chapter}{Bibliographie} 

\renewbibmacro*{finentry}{\finentry}
\printbibliography[heading=none]

\end{document}
```
Top Answer
samcarter
Biblatex already checks if the bibliography is empty and does not print the heading in this case.

So instead of replicating the checks for an empty bibliography, which biblatex performs anyway to print this warning, you could just disable the warning.


```
\documentclass{book}

\usepackage[%
	refsegment=chapter,% Pour avoir une bib per chap	
	bibencoding=inputenc,
	hyperref=auto,
	style=authoryear,
	giveninits=true,
	citestyle=alphabetic,
	sorting=nyt,
	sortcites=true,
	doi=false,
	isbn=false,
	url=false,
	eprint=false,
	autopunct=true,
	maxnames=10,%
	maxalphanames=3,%
	hyperref=true,
	abbreviate=false,
	backref=true,
	backend=biber%
]{biblatex}

\usepackage{hyperref}

\addbibresource{biblatex-examples.bib}

\renewbibmacro*{finentry}{\printfield{abstract}\finentry}

\usepackage{xpatch}
\xpretocmd{\chapter}{%
\ifnum\value{chapter}>0
  \printbibliography[segment=\therefsegment,heading=subbibliography]
\fi%
}{}{}

\makeatletter
\def\blx@warn@bibempty{%
%  \@latex@warning{Empty bibliography}
}
\makeatother

\begin{document}

\chapter{First chapter}

\cite{padhye}.

\chapter{Second chapter}

\cite{kastenholz}, \cite{itzhaki}.

\chapter{Second chapter}

no here


\chapter*{Bibliographie}
\addcontentsline{toc}{chapter}{Bibliographie} 

\renewbibmacro*{finentry}{\finentry}
\printbibliography[heading=none]

\end{document}
```

This works similarly for subbibliographies filtered by type:

```
\documentclass{book}

\usepackage[%
	refsegment=chapter,% Pour avoir une bib per chap	
	bibencoding=inputenc,
	hyperref=auto,
	style=authoryear,
	giveninits=true,
	citestyle=alphabetic,
	sorting=nyt,
	sortcites=true,
	doi=false,
	isbn=false,
	url=false,
	eprint=false,
	autopunct=true,
	maxnames=10,%
	maxalphanames=3,%
	hyperref=true,
	abbreviate=false,
	backref=true,
	backend=biber%
]{biblatex}

\usepackage{hyperref}

\addbibresource{biblatex-examples.bib}

\makeatletter
\def\blx@warn@bibempty{%
%  \@latex@warning{Empty bibliography}
}

\def\blx@key@type#1{%
  \ifcsundef{blx@type@\the\c@refsection @#1}
    {%\blx@warning{Type '#1' not found}%
     \let\blx@tempa\@empty}
    {\blx@printbibchecks
     \iftoggle{blx@tempb}
       {\togglefalse{blx@tempb}%
        \blx@filter\blx@tempa{blx@type@\the\c@refsection @#1}}
       {\let\blx@tempa\@empty
        \blx@error
          {'type' used multiple times}
          {When passing multiple filter options, each entry\MessageBreak
           must satisfy all conditions (AND conjunction),\MessageBreak
           hence some options may not be used twice.\MessageBreak
           Use 'filter' and '\string\defbibfilter' with OR conjunctions}}}}
\makeatother

\begin{document}

\tableofcontents

\cite{aksin}

\chapter*{Bibliographie}
\addcontentsline{toc}{chapter}{Bibliographie} 
\phantomsection
\addcontentsline{toc}{section}{Books}
\printbibliography[heading=subbibliography,title={Books},type=book]
\phantomsection
\addcontentsline{toc}{section}{Articles}
\printbibliography[heading=subbibliography,title={Articles},type=article]

\end{document}
```

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.