# Refsection and \includeonly warning

I'm using biblatex with a biber backend to create a cumulative bibliography, subdivided by chapter. My (simplified) main file (main.tex) is:

\documentclass{book}

\usepackage[refsection=chapter, backend=biber]{biblatex}
\ref*{refsection:\therefsection}]{%
\setcounter{secnumdepth}{0}%
\section{#1}}

\usepackage{hyperref}

\includeonly{bar}

\begin{document}

\mainmatter
\include{foo}
\include{bar}

\backmatter

\end{document}


foo.tex is:

\chapter{Foo}
\label{cha:foo}
\nocite{cms}


and bar.tex is:

\chapter{Bar}
\ref{cha:foo}
\nocite{glashow}


According to this answer the benefit of using \include is that

"There will be a filename.aux file which contains all counter values, like page and chapter numbers etc., at the begin of the filename. This way the file can be compiled alone but still has the correct page and chapter etc. numbers. Such part aux files are read by the main aux file".

I expect the refsection counter to behave the same way. However when using \includeonly{some chapter} I get the following warning:

LaTeX Warning: Label refsection:01' multiply defined.
LaTeX Warning: There were multiply-defined labels.


If I remove the includeonly command then the warning disappears but is there a way to avoid that warning when using the includeonly command? Apparently the only way to eliminate the warning is by deleting the aux files of the chapters (not the main file) after each compilation. However in that way counter values are lost.

I know this is just a warning, not an error, and will not be an issue in the final (full) document. However I would like to understand why the warning appears and if possible to eliminate it.

EDIT: Before the bounty ends I want to make clear that I can tell my text editor (vim) not to show the warning. As I said before, what I really want to know why the warning appears when one of the advantages of using include is that it stores counter values.

• Remember, too, that this is a warning, not an error, and indeed one that will certainly not be an issue in the final (full) document. – jon Oct 1 '13 at 4:36
• @jon Thanks. I've changed the title of the question. – petobens Oct 1 '13 at 4:42
• Just out of interest, do you notice any adverse effect apart from the warning (wrong links, [in any way] messed up bibliography, wrong numbering)? I think jon is right, when he points out that this behaviour is very likely not relevant for the final (important) stage of your document preparation. – moewe Oct 1 '13 at 19:41
• @moewe everything works fine. However I thought that since I'm using include then the refsement counters should be stored in the aux files and no warning should appear. – petobens Oct 1 '13 at 23:40
• @cfr you seem to be right. The warning indeed disappears however now not only the included chapter is printed but also every chapter title in the document. I now i can comment the unwanted chapter titles but I hope there is a more general solution. The other problem with your solution is that the chapter title is in a page by itself and the contents of the chapter start in another one. I thought that maybe some of the biblatex maintainers could explain in detail why this happens and how to avoid it. – petobens Dec 18 '13 at 19:53

From my testing, starting with a clean directory (no .aux files) it works fine with \includeonly. It's only a problem if you have a foo.aux hanging around from a previous run which created it (presumably without the \includeonly) and then you try to run with \includeonly - this seems to pick up and read the foo.aux which contains counters the same as in bar.aux. This makes sense as when you are effectively only including bar.aux by using \includeonly, this would get counter "01" but if you included both, foo.aux would have this. If you don't delete your .aux files between runs with different \includeonly settings, it's natural you will get conflicts because you have old .aux files around.
• If I delete the aux files then (i) bar.tex chapter instead of being chapter 2 becomes chapter 1 (counter values are lost) and (ii) if from that bar.tex I have a reference to foo.tex (such as \ref{cha:foo}) then by deleting foo.aux the reference is lost (so basically I'm losing every advantage of using \include). – petobens Jul 10 '14 at 19:30
• To avoid this, I put the \newrefsection commands in the master, so the full set of refsections are created in the same numeric sequence regardless of what is actually put in the includeonly{...}` macro, although frankly i feel that the newrefsection macro should have an optional agrument to allow the user to specify a name, rather relying on a counter increment. – Nicholas Hamilton Mar 16 '17 at 3:00