bibliographies with recfiles

This commit is contained in:
Malin Freeborn 2025-02-14 13:05:28 +01:00
parent fc88ab6200
commit aa32bfc249
Signed by: andonome
GPG Key ID: 52295D2377F4D70F
2 changed files with 122 additions and 0 deletions

View File

@ -45,6 +45,7 @@ recset -f "$new_field" --delete $database
- [Extended example](recfiles/extended.md)
- [Playing with board games data](recfiles/Board_Games.md)
- [Playing with IP addresses](recfiles/IP_ASN.md)
- [Manage LaTeX Bibliographies](recfiles/bibliography.md)
- [Fixes](recfiles/recfixes.md)
# Resources

View File

@ -0,0 +1,121 @@
---
title: "Recfile Bibliography for TeX"
tags: [ "data", "database", "recfiles", "tex" ]
requires: [ "Recfiles", "TeX", "Makefile" ]
---
Store your bibliography in a `recfile` database, then extract any part with `make`.
For example, you could store books like this in `bibliography.rec`:
```recfile
%rec: book
%key: slug
slug: thinkingexperience
author: H. H. Price
title: Thinking and Experience
year: 1953
publisher: Harvard University Press, Cambridge
slug: inventingrightwrong
author: John Leslie Mackie
title: Inventing Right and Wrong
year: 1997
publisher: Penguin Books, England
```
Run `make book` to extract `book.bib`, ready for LaTeX to use:
```bib
@book{thinkingexperience,
author = {H. H. Price},
title = {Thinking and Experience},
year = {1953},
publisher = {Harvard University Press, Cambridge},
}
@book{inventingrightwrong,
author = {John Leslie Mackie},
title = {Inventing Right and Wrong},
year = {1997},
publisher = {Penguin Books, England},
}
```
The `makefile` syntax is just a few lines (though admittedly employs some garbled shell-crud):
```make
bibs != grep -Po '%rec: \K.*' bibliography.rec
bibfiles = $(patsubst %, %.bib, $(bibs))
$(bibfiles): %.bib: bibliography.rec
recsel $< -t $(basename $@) |\
sed 's/slug: \(.*\)/@$(basename $@){\1,/g' |\
sed 's/^\(\b.*\b\): \(.*\)/ \1 = {\2},/gI' |\
sed 's/^$$/}\n/g' > $@
echo '}' >> $@
```
Here's a longer `bibliography.rec` file, which can also produce `article.bib`:
```recfile
%rec: book
%key: slug
%type: year int
%constraint: year > -2000
%sort: year month
slug: thinkingexperience
author: H. H. Price
title: Thinking and Experience
year: 1953
publisher: Harvard University Press, Cambridge
slug: inventingrightwrong
author: John Leslie Mackie
title: Inventing Right and Wrong
year: 1997
publisher: Penguin Books, England
slug: metaphysicscontemporaryintro
author: Michael J. Loux
title: Metaphysics: A Contemporary Introduction
year: 1998
publisher: Routledge, London
slug: pluralityworlds
author: David Lewis
title: On the Plurality of Worlds
publisher: Blackwell Publishing, Oxford
year: 2001
%rec: article
%key: slug
%sort: year month
slug: genuinerealisttheory
author: John Divers
title: A Genuine Realist Theory of Advanced Modalizing
year: 1999
pages: 217240
month: april
journaltitle: Mind
uri: https://academic.oup.com/mind/article-abstract/108/430/217/975258?redirectedFrom=fulltext
volume: 108
publisher: Harvard University Press, Cambridge
slug: twokindsmentalrealism
author: Tam\'{a}s Demeter
title: Two Kinds of Mental Realism
year: 2009
pages: 40:59-71
uri: https://www.researchgate.net/profile/Tamas_Demeter2/publication/41554923_Two_Kinds_of_Mental_Realism/links/0deec53247f5a4ae21000000.pdf
month: august
journaltitle: Journal for General Philosophy of Science
volume: 30
publisher: Harvard University Press, Cambridge
```