7

I am using biblatex with refsection=chapter. That results in aux files named according to this pattern, assuming a source file called book.tex for a book of n chapters:

book1-blx.aux
book2-blx.aux
...
bookn-blx.aux

Is there a hook to change that name? I need to associate the aux file to its corresponding chapter (these files are used in other processes) For example:

book_chaplabel-blx.aux

I think I can add a hook inside the include command so I can grab the chapter file name, but I don't know where to hook it up to the generated aux file name.

EDITING for clarity:

It may be that trying to substitute the chaptername in for the integer isn't the right way to solve the problem. The main thing is that I need a way to associate the aux file with the chapter it came from. I must post-process the bbl files and aux files for each chapter. The post-processed files are used in a different workflow (epub/docbook generation).

1
  • 2
    Just in case you would rather get around this whole problem, if you use biber as the backend instead of bibtex, it requires only one run and this multiple file issue doesn't exist.
    – PLK
    Sep 5, 2012 at 18:34

1 Answer 1

5

The numeric part of the auxiliary filename corresponds to the reference section counter (the same value returned by \therefsection). The filename suffix (-blx) corresponds to \blxauxsuffix. This can be redefined with \renewcommand in the preamble. The filename prefix is hardcoded as \jobname.

You could patch biblatex internals to add chapter filenames, but these need to be defined in the preamble. So hooking into \include is too late. One workaround is to specify an ordered list of chapter filenames in the preamble.

Here's an example that replaces the reference section number with chapter filenames. The chapter filenames are passed to a new command \blxauxprefix as a comma-separated list.

\documentclass{report}
\usepackage[backend=bibtex,refsection=chapter]{biblatex}

\makeatletter

\def\blxauxprefix#1{%
  \defcounter{listcount}{0}%
  \def\do##1{\stepcounter{listcount}\csgdef{blxauxprefix:\the\c@listcount}{-##1}}%
  \docsvlist{#1}}

\patchcmd{\blx@refsection@bibtex}
  {\jobname\the\c@refsection\blxauxsuffix}
  {\jobname\csuse{blxauxprefix:\the\c@refsection}\blxauxsuffix}{}{}

\patchcmd{\blx@bblfile@bibtex}
  {\jobname\the\c@refsection\blxauxsuffix}
  {\jobname\csuse{blxauxprefix:\the\c@refsection}\blxauxsuffix}{}{}

\apptocmd{\include}
  {\ifcsstring{blxauxprefix:\the\c@refsection}{#1}{}
     {\blx@warning{%
        'aux' file prefix does not match \MessageBreak
        '\@backslashchar include' filename #1}}}{}{}

\makeatother

\blxauxprefix{chap1,chap2}

\begin{filecontents}{chap1.tex}
\chapter{First chapter}
\cite{ctan}
\end{filecontents}

\begin{filecontents}{chap2.tex}
\chapter{Second chapter}
\cite{companion,knuth:ct}
\end{filecontents}

\addbibresource{biblatex-examples.bib}

\defbibheading{subbibliography}{\section*{%
  \ifnumgreater{\therefsection}{0}
    {References for Chapter \ref{refsection:\therefsection}}
    {References before chapters}}}

\begin{document}
\cite{markey}
\include{chap1}
\include{chap2}
\printbibheading
\bibbysection[heading=subbibliography]
\end{document}
1
  • awesome, @Audrey! I never would have figured that one out. In fact I was going to close the question as too esoteric to ask here. Thanks very much.
    – Tim A
    Sep 6, 2012 at 13:14

You must log in to answer this question.

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