3

I have a .bbl file that contains a massive amount of entries (I don't have the related .bib file that generated it). Is it possible to tell LaTeX to include only the references/citations from .bbl file that are cited in the text and not everything (which is what happens if you "input" the .bbl file)?

MWE is below:

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}

\title{Your Paper}

\author{You}

\date{\today}

\begin{document}
\maketitle

\begin{abstract}
Your abstract.
\end{abstract}

\input{test.bbl}

\end{document}
10
  • Are you using BibTeX?
    – Christian
    Apr 16, 2016 at 10:13
  • 1
    What you want to have should be the default behaviour. (Normally, the .bbl file gets generated by BibTeX from the .bib and contains only the entries that were actually used in the .tex) Can you post a MWE?
    – Ruben
    Apr 16, 2016 at 10:13
  • I am using this \input{supp.bbl} at the end of the document to include the .bbl
    – spokus
    Apr 16, 2016 at 10:15
  • Please post a full minimal working example instead of throwing out little bits of information.
    – Ruben
    Apr 16, 2016 at 10:16
  • overleaf.com/4912864mzbxrx#/15127112 would this do ?
    – spokus
    Apr 16, 2016 at 10:21

1 Answer 1

4

If your .bbl file is well formed, that is

  1. You only have \bibitem{<tag>}

  2. There is no empty line in entries

  3. Each entry (including the last one) is followed by a blank line

then you can use a trick involving the usage of \citation that's normally defined to do nothing.

File spokus-old.bbl

\begin{thebibliography}{1}

\bibitem{Barker1998}
Chris Barker.
\newblock Partitives, double genitives and anti-uniqueness.
\newblock \emph{Natural Language \& Linguistic Theory}, 16:\penalty0 679--717,
  1998.

\bibitem{Berwick1985}
Robert~C. Berwick.
\newblock \emph{Acquisition of syntactic knowledge}.
\newblock MIT Press, Cambridge, MA, 1985.

\bibitem{Carlson1977}
Gregory~N. Carlson.
\newblock \emph{Reference to Kinds in {E}nglish}.
\newblock PhD thesis, University of Massachusetts, Amherst, 1977.

\bibitem{Carlson1995}
Gregory~N. Carlson and Francis~Jeffrey Pelletier, editors.
\newblock \emph{The Generic Book}.
\newblock Chicago University Press, Chicago, 1995.

\end{thebibliography}

File spokus.tex

\documentclass{article}

\makeatletter
\let\original@bibitem\bibitem
\def\bibitem#1#2\par{%
  \@ifundefined{cited@#1}{}{\original@bibitem{#1}#2\par}%
}
\renewcommand\citation[1]{\global\@namedef{cited@#1}{}}
\makeatother


\begin{document}

\cite{Barker1998}

\cite{Carlson1977}

\input{spokus-old.bbl}

\end{document}

Output

enter image description here

Explanation

Every \cite command writes a note in the aux file, in the form

\citation{<tag>}

Such note is normally only used by BibTeX, so it is defined to gobble its argument. We can redefine it to mark a label as used, which is the purpose of

\renewcommand\citation[1]{\global\@namedef{cited@#1}{}}

The \bibitem command is redefined to absorb the whole entry and then to see whether \cited@<tag> is defined; if it is, it outputs the entry, otherwise does nothing.

0

You must log in to answer this question.

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