You could use perl
to go through the bib file, save all titles as a hash key with its line as the hash value, and then loop through it and print the title if its value has multiple entries. To do so, create a file with the following content, e.g. "finddupls.pl", change the bib file name, then execute perl finddupls.pl
in your terminal:
#!perl
my %seen = ();
my $line = 0;
open my $B, 'file.bib';
while (<$B>) {
$line++;
# remove all non-alphanumeric characters, because bibtex could have " or { to encapsulate strings etc
s/[^a-zA-Z0-9 _-]//ig;
# lower-case everything to be case-insensitive
# pattern matches lines which start with title
$seen{lc($1)} .= "$line," if /^\s*title\s*(.+)$/i;
}
close $B;
# loop through the title and count the number of lines found
foreach my $title (keys %seen) {
# count number of elements seperated by comma
my $num = $seen{$title} =~ tr/,//;
print "title '$title' found $num times, lines: ".$seen{$title},"\n" if $num > 1;
}
# write sorted list into file
open my $S, '>sorted_titles.txt';
print $S join("\n", sort keys %seen);
close $S;
It returns directly in the terminal something like this:
title 'observation on soil moisture of irrigation cropland by cosmic-ray probe' found 2 times, lines: 99,1350,
title 'multiscale and multivariate evaluation of water fluxes and states over european river basins' found 2 times, lines: 199,1820,
title 'calibration of a non-invasive cosmic-ray probe for wide area snow water equivalent measurement' found 2 times, lines: 5,32,
And it additionally writes a file sorted_titles.txt
listing all titles alphabetically ordered which you could go through and detect duplicates manually.
Johannes_B gave the wanted answer in comments above. I'll put it here:
@misc{testkey,note={My own reference text}}
This achieves exactly what I want: the ability to write references manually but still maintain the ability to sort them properly (using number reference system).
(The reason is to be able to not spend too much time configuring different presets when I can achieve a proper reference in a fraction of time by writing it myself manually.)
Best Answer
With a TeX Live distribution (possibly also with MiKTeX) there is a
bibexport
program. Assuming your document ismyarticle.tex
, you have to compile it normally and then you callwhere
extracted.bib
is the name that you want to give to your new.bib
file. Notice that you have to give the extension.aux
(or no extension at all).Then you have to change the name of the
.bib
file in your document, in order to useextracted.bib
.