# Why do I need \newrefsegment when I already specify refsegment=section?

The following works well and shows exactly what I want. I am just wondering about this: Why do I have to use \newrefsegment, if I already specified refsegment=section? I expected everything to work without extra \newrefsegment commands. On the other hand, I can omit refsegment=section and it still works (which is somehow clear).

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[american]{babel}
\usepackage{titlesec}
\usepackage[
backend=bibtex,
style=authoryear,
refsegment=section
]{biblatex}

\defbibheading{subbibheading}{
\section*{References for Section \ref{refsegment:\therefsection\therefsegment}}
}
\addbibresource{biblatex-examples.bib}

\begin{document}

\section{Foo}
\newrefsegment
\textcite{reese}
\printbibliography[segment=\therefsegment, heading=subbibheading]

\section{Bar}
\newrefsegment
\textcite{glashow}
\printbibliography[segment=\therefsegment, heading=subbibheading]

\printbibliography[heading=bibintoc]
\end{document}

-
refsegment=section is the rough equivalent of setting \newrefsegment before \section. biblatex patches divisional commands this way to ensure that citations in titles don't get assigned to the previous reference segment or section. – Audrey Feb 25 at 21:30
Thanks, Audrey. Is it then possible to increase the counter by 1 globally so that only using refsegment=section leads to the correct output? I just tried \setcounter{therefsegment}{1} ... but that fails – Marius Hofert Feb 25 at 21:39

## 1 Answer

The refsegment=section setting is the rough equivalent of issuing \newrefsegment before \section. biblatex patches divisional commands this way to ensure that citations in titles don't get assigned to the previous reference segment or section.

To define the label after the section counter is incremented you can patch the relevant commands in your preamble. For example:

\makeatletter
\patchcmd{\refsegment}
{\label{refsegment:\the\c@refsection\the\c@refsegment}}{}{}{}
\apptocmd{\@sect}
{\label{refsegment:\the\c@refsection\the\c@refsegment}}{}{}
\makeatother


The titlesec package redefines the high-level divisional commands so any low-level patches done by biblatex are ignored; the refsegment and refsection options won't work at all. In this case use \newrefsegment after \section instead of refsegment=section.

It does make more sense to create labels after any section counters have been incremented. We can look into this for commonly-used document classes, but packages like titlesec will likely remain unsupported.

-
 Hi Audrey. Thanks for helping. I initially thought it works, but I load the package titlesec as well, and then it seems to break down. I update the minimal example accordingly. Do you know a solution for that? – Marius Hofert Feb 25 at 23:47 Thanks a lot, Audrey, just saw your updated answer. – Marius Hofert Feb 26 at 11:43