Recfile Bibliography for TeX
Store your bibliography in a recfile
database, then extract any part with make
.
For example, you could store books like this in bibliography.rec
:
1%rec: book
2%key: slug
3
4slug: thinkingexperience
5author: H. H. Price
6title: Thinking and Experience
7year: 1953
8publisher: Harvard University Press, Cambridge
9
10slug: inventingrightwrong
11author: John Leslie Mackie
12title: Inventing Right and Wrong
13year: 1997
14publisher: Penguin Books, England
Run make book
to extract book.bib
, ready for LaTeX to use:
1@book{thinkingexperience,
2 author = {H. H. Price},
3 title = {Thinking and Experience},
4 year = {1953},
5 publisher = {Harvard University Press, Cambridge},
6}
7
8@book{inventingrightwrong,
9 author = {John Leslie Mackie},
10 title = {Inventing Right and Wrong},
11 year = {1997},
12 publisher = {Penguin Books, England},
13}
The makefile
syntax is just a few lines (though admittedly employs some garbled shell-crud):
1bibs != grep -Po '%rec: \K.*' bibliography.rec
2bibfiles = $(patsubst %, %.bib, $(bibs))
3
4$(bibfiles): %.bib: bibliography.rec
5 recsel $< -t $(basename $@) |\
6 sed 's/slug: \(.*\)/@$(basename $@){\1,/g' |\
7 sed 's/^\(\b.*\b\): \(.*\)/ \1 = {\2},/gI' |\
8 sed 's/^$$/}\n/g' > $@
9 echo '}' >> $@
Here's a longer bibliography.rec
file, which can also produce article.bib
:
1%rec: book
2%key: slug
3%type: year int
4%constraint: year > -2000
5%sort: year month
6
7slug: thinkingexperience
8author: H. H. Price
9title: Thinking and Experience
10year: 1953
11publisher: Harvard University Press, Cambridge
12
13slug: inventingrightwrong
14author: John Leslie Mackie
15title: Inventing Right and Wrong
16year: 1997
17publisher: Penguin Books, England
18
19slug: metaphysicscontemporaryintro
20author: Michael J. Loux
21title: Metaphysics: A Contemporary Introduction
22year: 1998
23publisher: Routledge, London
24
25slug: pluralityworlds
26author: David Lewis
27title: On the Plurality of Worlds
28publisher: Blackwell Publishing, Oxford
29year: 2001
30
31%rec: article
32%key: slug
33%sort: year month
34
35slug: genuinerealisttheory
36author: John Divers
37title: A Genuine Realist Theory of Advanced Modalizing
38year: 1999
39pages: 217–240
40month: april
41journaltitle: Mind
42uri: https://academic.oup.com/mind/article-abstract/108/430/217/975258?redirectedFrom=fulltext
43volume: 108
44publisher: Harvard University Press, Cambridge
45
46slug: twokindsmentalrealism
47author: Tam\'{a}s Demeter
48title: Two Kinds of Mental Realism
49year: 2009
50pages: 40:59-71
51uri: https://www.researchgate.net/profile/Tamas_Demeter2/publication/41554923_Two_Kinds_of_Mental_Realism/links/0deec53247f5a4ae21000000.pdf
52month: august
53journaltitle: Journal for General Philosophy of Science
54volume: 30
55publisher: Harvard University Press, Cambridge