TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose I have two .tex files, each of which must have a bibliography. However, I want the bibliography in the second file to contain only citations that are not in the first. As an example:

\documentclass[11pt, a4paper]{article}

\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=apa,natbib=true,backend=biber,maxbibnames=99,url=false]{biblatex}
\DeclareLanguageMapping{american}{american-apa}

\bibliography{test}

\begin{document}

This is test file 1 \citep{Tversky:Kahneman:1990,Tversky:Kahneman:1974}

\printbibliography

\end{document}

This first file cites two sources.

Here is the second file:

\documentclass[11pt, a4paper]{article}

\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=apa,natbib=true,backend=biber,maxbibnames=99,url=false]{biblatex}
\DeclareLanguageMapping{american}{american-apa}

\bibliography{test}

\begin{document}

This is test file 2 \citep{Tversky:Kahneman:1990,Kahneman:1973}

\printbibliography

\end{document}

Notice that this tex document cites two sources: one that was cited in the first, and one that wasn't. I'd like the reference section here to include only Kahneman:1973, because Tversky:Kahneman:1990 is included in the first.

Here's my test.bib in case you want to compile the files above...

@book{Kahneman:1973,
author = {Kahneman, D.},
title = {Attention and effort},
publisher = {Prentice-Hall},
year = {1973},
address = {Englewood Cliffs, NJ},
confidential = {n}
}

@article{Tversky:Kahneman:1974,
author = {Tversky, A. and Kahneman, D.},
title = {Judgment under Uncertainty: {H}euristics and Biases},
journal = {Science},
year = {1974},
volume = {185},
number = {4157},
pages = {1124-1131},
note = {10.1126/science.185.4157.1124},
confidential = {n}
}

@incollection{Tversky:Kahneman:1990,
author = {Tversky, A. and Kahneman, D.},
title = {Judgements under uncertainty: {H}euristics and Biases},
booktitle = {Rationality in action: {C}ontemporary approaches.},
publisher = {Cambridge University Press},
year = {1990},
pages = {171-188},
editor = {Moser, Paul K.},
address = {New York},
confidential = {n}
}

Is there a way to accomplish this? I am using latexmk to compile my document. I'm also open to ways of using extra scripting to do it. Thanks!

share|improve this question

migrated from stackoverflow.com Feb 19 '14 at 17:09

This question came from our site for professional and enthusiast programmers.

    
Are there any news here? Are you still interested in a solution? – Johannes_B Dec 6 '14 at 13:20
    
@Johannes_B Are you interested in a solution? I have cooked something up below. Maybe it is enough to get this question off the unanswered list. – moewe Oct 19 '15 at 10:07

We can use a similar strategy to Cite references in the order that they appear in another file.

Again we import the other document (your first file, in the example \jobname-ext) in a savebox wrapped in a refsegment. Now we only have to filter out those entries from that segment and discard them, that is done with the onlynew filter just like in Multiple reference lists using biblatex: how to remove duplicated entries?.

The second file (in the example \jobname) will then have the following document environment

\begin{document}
\importcites{\jobname-ext}
This is test file 2 \cite{sigfridsson,worman}

\printbibliography[filter=onlynew]
\end{document}

MWE

\documentclass[british]{scrartcl}  
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=numeric,backend=biber,sorting=none,backref=true,defernumbers=true]{biblatex}
\addbibresource{biblatex-examples.bib}
\usepackage{docmute}

\usepackage{filecontents}
\begin{filecontents*}{\jobname-ext.tex}
\documentclass[british]{scrartcl}  
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=numeric,backend=biber,sorting=none]{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}
This is test file 1 \cite{sigfridsson,geer}

\printbibliography
\end{document}
\end{filecontents*}

\makeatletter
\defbibenvironment{plainimport}{}{}{}
\newsavebox{\importbox}
\newcommand{\importcites}[1]{%
  \sbox\importbox{\vbox{%
    \citetrackerfalse
    \begin{refsegment}
      \defbibfilter{onlynew}{not segment=\therefsegment}
      \input{#1}
      \let\blx@anchor\@empty
      \printbibliography[env=plainimport,segment=\therefsegment]
    \end{refsegment}}}}
\makeatother


\begin{document}
\importcites{\jobname-ext}
This is test file 2 \cite{sigfridsson,worman}

\printbibliography[filter=onlynew]
\end{document}

example output of the second file

share|improve this answer
    
One solution is better than none :-) – Johannes_B Oct 19 '15 at 10:15
    
Credits go to PLK for telling me how to use \defbibfilter more effectively (here). – moewe Oct 21 '15 at 6:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.