2

Addendum:

@PLK has commented below on the feasibility of this:

I can't see how this could work - \includeonly would have to be changed to be aware of biblatex-specific internals such as the segment/section creation macros in order to track such things in unloaded files.

I am not sure how complicated that is, so I'm offering a small bounty for anyone willing to look into this.


There's a conflict between biblatex's \printbibliography[segment=x] option to print per-section bibliographies, and the use of \includeonly.

As far as I can tell, this is caused by the segment numbers being re-arranged due to the sections not being included. So, if include two sections and the second one uses \printbibliography[segment=2], that will no longer work when you \includeonly{section2} because the segment number of that section is now segment=1:

! Package biblatex Error: Segment '2' not found in Section '0'.

This of course is fixable by changing segment every time, but that would make the use of \includeonly more than cumbersome. Any thoughts on how to fix this?

MWE:

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{bibliography.bib}
@Article{gob,
  title           = {I've Made a Huge Mistake},
  author          = {Bluth, Gob},
  journal         = {Journal of Magicians},
  year            = {2003},
  volume          = {1},
  number          = {1},
  pages           = {1--10},
}

@Article{michael,
  title           = {Her?},
  author          = {Bluth, Michael},
  journal         = {Sudden Valley},
  year            = {2003},
  volume          = {1},
  number          = {1},
  pages           = {1--10},
}

@Article{tobias,
  title           = {Never-nudism},
  author          = {F{\"u}nke, Tobias},
  journal         = {Blue Man Group},
  year            = {2003},
  volume          = {1},
  number          = {1},
  pages           = {1--10},
}
\end{filecontents}

\begin{filecontents}{section1.tex}
\section{First section}
Check this out~\cite{gob}.
\printbibliography[heading=subbibliography,segment=1,]
\end{filecontents}

\begin{filecontents}{section2.tex}
\section{Second section}
Check this out~\cite{michael}.
\printbibliography[heading=subbibliography,segment=2,]
\end{filecontents}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[%
  backend=biber,
  refsegment=section,
]{biblatex}
\addbibresource{bibliography.bib}

\includeonly{%
  % section1,% % This always works because its segment number is constant at 1.
  section2,%
}

\begin{document}
\include{section1}
\include{section2}
\nocite{tobias}
\printbibliography
\end{document}
13
  • 1
    I tried playing with this and found biblatex advised setting defernumbers=true. So I tried that and the references became even crazier. In particular, if I use defernumbers, I get reference labels which start at 3 rather than 1. That's without using \includeonly at all. I think you might not have this problem using refsection but then your references would be local and you couldn't get a useful global bibliography...
    – cfr
    Commented Jun 1, 2014 at 2:40
  • @cfr Yes, the defernumbers issue would have been another question actually -- I also get the non-sensical numbering. I am thoroughly confused. :-) Also, I am interested in refsegment only but I will indeed test refsection as well and report back. My intuition about how the problem is caused tells me that it will have the same issue.
    – sudosensei
    Commented Jun 1, 2014 at 8:20
  • @cfr Oh, wait. refsection may work because it resolves the section number automatically using \printbibliography instead of, e.g., \printbibliography[section=2]. But I think the general issue is still there -- section/segment numbers change when using \includeonly.
    – sudosensei
    Commented Jun 1, 2014 at 8:24
  • 1
    @cfr Well, let's see if PLK notices this. Maybe it is a bug. Otherwise, I'll offer a bounty on the question when the option is available and hope for the best. But you are definitely right about defernumbers -- it is weird. I'll just post it as a separate question.
    – sudosensei
    Commented Jun 1, 2014 at 12:40
  • 1
    I can't see how this could work - \includeonly would have to be changed to be aware of biblatex-specific internals such as the segment/section creation macros in order to track such things in unloaded files.
    – PLK
    Commented Jun 3, 2014 at 10:35

1 Answer 1

1

By using \printbibliography[heading=subbibliography,segment=\therefsegment] instead of explicitly setting the number of the segment, subsequent pdflatex invovations do not terminate with a Segment not found error.

If the auxiliary files are cleaned or biber is re-run, the document still compiles successfully, but the bibliography that is typeset may not be what you would expect to see in the final document (the ordering and/or numbering). Nonetheless, this enables the use of \includeonly as there will be no re-compilation errors due to missing segments.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .