2

Consider the following MWE:

\documentclass{article}
\usepackage[backend=bibtex]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{mybib.bib}
  @misc{A01,
    author={Author, A.},
    year={2001},
    title={Alpha}
  }
\end{filecontents}
\addbibresource{mybib.bib}

\begin{filecontents}{mytext.tex}
  Hey, I want to repeat some text!
\end{filecontents}

\begin{document}
\include{mytext}
\cite{A01}
\include{mytext}
\printbibliography
\end{document}

Bibtex will complain because we're asking it to process the file mytext.aux twice:

A level-1 auxiliary file: mytext.aux
Already encountered file mytext.aux
---line 10 of file bi.aux
: \@input{mytext.aux :
}
I'm skipping whatever remains of this command

Is there any way to deal with that situation in a more clever way? What if I want to include the same snippet twice, but don't want this error to be reported, what should I do?

Troy
  • 13,741
Clément
  • 5,591
  • 1
    Use \input instead of \include so it does not create an auxiliary file? – Troy Jan 30 '17 at 02:52
  • Yes, but what if I still want to benefit from the \include features? (Like \includeonly, for instance, cf. http://tex.stackexchange.com/q/246/34551). (PS: thanks for the edit.) – Clément Jan 30 '17 at 04:01
  • I don't see why you would want to use \include in such a situation. What do you gain from \includeonly for snippets? Also I would never use \include in an article. – Ulrike Fischer Jan 30 '17 at 08:42
  • As so often this works just fine with backend=biber. You should switch backends anyway since BibTeX is only supported as legacy backend. – moewe Jan 30 '17 at 17:48
  • @UlrikeFischer : article was just for the example, I actually use this code for a beamer document (and the included document is a customized table of contents). And, indeed, biber handles that situation just fine. So I guess your answer would be "either don't use include that way, or switch to biber? – Clément Feb 01 '17 at 14:18

1 Answers1

1

Use Biber instead of BibTeX. Biber uses one single .bcf file for the entire document and voids the .aux files.

Since BibTeX is only considered a legacy backend for existing documents that cannot switch to Biber and only supports a limited set of features, a switch to Biber is recommended anyway.

moewe
  • 175,683