Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

generating a bib file

361 views
Skip to first unread message

Haines Brown

unread,
Jul 9, 2016, 5:43:48 PM7/9/16
to
This must be a FAQ, but I've not found answers to it.

I have many enormous .bib databases that I process with JabRef. So when
I run biber on a .tex file, it takes forever to finish. So I have
created a custom .bib file of just those citations used in a document so
that processing goes much faster.

However, creating this bib file with JabRef is laborious. I use JabRef
to create multiple subdatabases, one for each database used in my
document and with different titles. With an editor I then consolidate
them into one .bib file placed in my document's working directory.

All the info needed to generated a bib file for a particular document is
present in the .bbl file. So how can I reformat a copy of the .bbl file
to produce a .bib file? Or is there a simple command to generate a .bib
file?

Haines Brown






Uwe Siart

unread,
Jul 10, 2016, 3:19:51 AM7/10/16
to
Haines Brown <hai...@engels.histomat.net> writes:

> All the info needed to generated a bib file for a particular document
> is present in the .bbl file. So how can I reformat a copy of the .bbl
> file to produce a .bib file? Or is there a simple command to generate
> a .bib file?

The Emacs editor (in particular the RefTeX package, that is included in
Emacs) provides such function:

Menu (in LaTeX mode) "Ref" -> "Global Actions" -> "Create BibTeX file"

--
Uwe

Haines Brown

unread,
Jul 10, 2016, 9:29:42 AM7/10/16
to
Uwe, your reply is much appreciated. It is good to know that emacs can
handle the production of a .bib file. However, your reply left me
bewildered.

Your recommendation to do

Menu (in LaTeX mode) "Ref" -> "Global Actions" -> "Create BibTeX file"

does not correspond to my emacs 24.4 menu, and I suspect the reason is
that RefTeX is not enabled. The Reftex manual says I should have added
a path to reftex in my ~/.emacs configuration, which I had not done.

So I add to .emacs:

(add-to-list 'load-path "/usr/local/share/Emacs24/emacs-24.4/lisp/ \
textmodes/reftex")
(require 'reftex)

This did nothing (no reftex menu in emacs), so I replaced last line with

(load "reftex.el" nil t t)

and got:

File error: Cannot open load file, no such file or directory, reftex.el



Frank Tetzel

unread,
Jul 10, 2016, 10:00:04 AM7/10/16
to
> I have many enormous .bib databases that I process with JabRef. So
> when I run biber on a .tex file, it takes forever to finish. So I have
> created a custom .bib file of just those citations used in a document
> so that processing goes much faster.
>
> However, creating this bib file with JabRef is laborious. I use JabRef
> to create multiple subdatabases, one for each database used in my
> document and with different titles. With an editor I then consolidate
> them into one .bib file placed in my document's working directory.

My current workflow is very similar. I use Kbibtex and i have one
master .bib file containing all the literature (including references to
the local pdf file). For a paper i create a new .bib file in Kbibtex and
copy&paste the entries that i need. I'm also not really happy to do
this manually but it's usually not that bad to look for an automatic
way. A smaller .bib file just for the paper also makes it easier to
share the code with other authors.

Here are some tools mentioned which might be useful for scripting:

http://tex.stackexchange.com/questions/1453/command-line-tools-for-some-bibtex-database-manipulations

Regards,
Frank

Ulrike Fischer

unread,
Jul 10, 2016, 12:50:42 PM7/10/16
to
You can use biber to create a bib-file which contains only the cited
bib-files.

biber --output-format=bibtex <your-file>.bcf

This would result in a new .bib file called <your-file>_biber.bib
containing all cited entries in test.tex, in citation order,

For more information check the biber documentation.

--
Ulrike Fischer
http://www.troubleshooting-tex.de/

Haines Brown

unread,
Jul 10, 2016, 3:42:30 PM7/10/16
to
Frank Tetzel <s144...@mail.zih.tu-dresden.de> writes:

>> However, creating this bib file with JabRef is laborious. I use JabRef
>> to create multiple subdatabases, one for each database used in my
>> document and with different titles. With an editor I then consolidate
>> them into one .bib file placed in my document's working directory.
>
> My current workflow is very similar. I use Kbibtex and i have one
> master .bib file containing all the literature (including references to
> the local pdf file).

> Here are some tools mentioned which might be useful for scripting:
>
> http://tex.stackexchange.com/questions/1453/command-line-tools-for-some-bibtex-database-manipulations

Thanks, Frank.

I've spent significant time trying to pursue the issue, and so far no
luck.

I first tried bibtool on Universal.tex:

$ bibtool -x Universal.aux -o Universal.bib -v
--- BibTool: Trying /home/haines/.bibtoolrsc
--- BibTool: Trying /home/haines/.bibtoolrsc.rsc
--- BibTool: Trying ./.bibtoolrsc
--- BibTool: Trying ./.bibtoolrsc.rsc
--- BibTool: Trying /usr/share/bibtool/.bibtoolrsc
--- BibTool: Trying /usr/share/bibtool/.bibtoolrsc.rsc
--- BibTool: Reading <stdin>

After much digging, I found out that bibtool is written for bibtex and
does not understand an .aux file written in biblatex. One can edit the
.aux file, but that's opening the way to problems. The consensus seems
to be that if biblatex is used, best is to use biber to generate a
.bib file.

So I next tried biber

I spent a lot of time with its --tool mode before I realized it must
have a .bib file as datasource. To generate a new .bib file one should
use the --output_format=bibtex option. One stumbling block was
that bibtex manual specifies the option as --output-format, which does
not work. Otherwise following the manual's example, I do:

$ biber --output_format=bibtex Universal.bcf
INFO - This is Biber 1.8
INFO - Logfile is 'Universal.blg'
INFO - Reading 'Universal.bcf'
INFO - Found 137 citekeys in bib section 0
INFO - Looking for bibtex format file 'Universal.bib'
ERROR - Cannot find 'Universal.bib'!
INFO - ERRORS: 1

I thought a .bib file is supposed to be the output, not input.
While my citations are all in \include{} files, it seems to me
that biber here simply needs the .bcf file to do the job.

Someone suggested the answer is to do:

$ biber Universal.tex --output_format bibtex
INFO - This is Biber 1.8
INFO - Logfile is 'Universal.tex.blg'
ERROR - Cannot find control file 'Universal.tex.bcf'! - did you
pass the "backend=biber" option to BibLaTeX?
INFO - ERRORS: 1

but this is even worse.

Apparently pybib can be used. Unfortunately, it is not documented and
you have to know python to understand what its tools are doing.

Apparently I'm unable to grasp the biber syntax.

Haines Brown


Uwe Siart

unread,
Jul 10, 2016, 4:32:06 PM7/10/16
to
Haines Brown <hai...@engels.histomat.net> writes:

> Your recommendation to do
>
> Menu (in LaTeX mode) "Ref" -> "Global Actions" -> "Create BibTeX file"
>
> does not correspond to my emacs 24.4 menu, and I suspect the reason is
> that RefTeX is not enabled.

Ah, yes, it could well be that RefTeX is not enabled by default.

I use AUCTeX for TeXing in Emacs and in my site-start.el I have

,----
| (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
`----

after the AUCTeX loading section.

In addition (but I think that's not crucial for your problem) I
customized the variable "reftex-plug-into-AUCTeX" and set it to true.

--
Uwe

Haines Brown

unread,
Jul 10, 2016, 5:02:51 PM7/10/16
to
Uwe Siart <use...@siart.de> writes:

> Haines Brown <hai...@engels.histomat.net> writes:
>
>> Your recommendation to do
>>
>> Menu (in LaTeX mode) "Ref" -> "Global Actions" -> "Create BibTeX file"
>>
>> does not correspond to my emacs 24.4 menu, and I suspect the reason is
>> that RefTeX is not enabled.
>
> Ah, yes, it could well be that RefTeX is not enabled by default.
>
> I use AUCTeX for TeXing in Emacs and in my site-start.el I have
>
> ,----
> | (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
> `----

I have no site-start.el, but the emacs session I use for working with
tex file has a .emacs startup file. I put it there and now I get the
Ref menu. Thanks!

So now I can do:

Menu (in LaTeX mode) "Ref" -> "Global Actions" -> "Create BibTeX file"

Unfortunately, this did not work. Specically, the .tex file is displayed
in emacs, and then I do Ref -> Global actions -> Create Bibtex file.
A dialog pops up asking me where to save my document .tex file. If I
replace the document.tex file with document.bib, it produces error that
.bib files not found.

> In addition (but I think that's not crucial for your problem) I
> customized the variable "reftex-plug-into-AUCTeX" and set it to true.

You lost me here. I don't see that variable in any of my relevant config
files.

Haines Brown

jon

unread,
Jul 16, 2016, 12:26:01 AM7/16/16
to
if you're already using biber, there's a much easier way. assuming you
have run, say,

pdflatex myfile.tex # or: any command that generates the .bcf

then you can do:

biber --output_format=bibtex --output_resolve myfile.bcf

this should produce a .bib file that only contains what you cited in
the .tex file.

cheers,
jon.

Haines Brown

unread,
Jul 17, 2016, 12:53:21 PM7/17/16
to
Jon, thanks, but I had already that without success. The root name of my
files is Universal. From a terminal I ran:

$ biber --output_format=bibtex --output_resolve Universal.bcf
INFO - This is Biber 1.8
INFO - Logfile is 'Universal.blg'
INFO - Reading 'Universal.bcf'
INFO - Found 137 citekeys in bib section 0
INFO - Looking for bibtex format file 'Universal.bib'
ERROR - Cannot find 'Universal.bib'!
INFO - ERRORS: 1

"Universal.bib" is what I'm trying to create. Also, is this a "format"
file?

Haines Brown


Haines Brown

unread,
Jul 17, 2016, 1:42:52 PM7/17/16
to
Sorry to follow up on my own note, but I should add that if I create an
empty Univesral.bib file and run the biber command, now the file is
found but cannot be read:

$ biber --output_format=bibtex --output_resolve Universal.bcf
INFO - This is Biber 1.8
INFO - Logfile is 'Universal.blg'
INFO - Reading 'Universal.bcf'
INFO - Found 137 citekeys in bib section 0
INFO - Looking for bibtex format file 'Universal.bib'
ERROR - Can't read Universal.bib
INFO - ERRORS: 1

Haines

jon

unread,
Jul 18, 2016, 12:01:24 AM7/18/16
to
On Sunday, 17 July 2016 12:53:21 UTC-4, Haines Brown wrote:
hmm, well it works for me. two questions/comments:

1. you are using biber 1.8, which is (for biber) old. would be worth
exploring when biber started being able to create .bib files from
.bcf files

2. can biber find Universal.bib on a normal run of biber? seems odd that
it should work on a normal call of biber and fail when certain option
switches are added...

cheers,
jon.

Haines Brown

unread,
Jul 18, 2016, 8:19:40 AM7/18/16
to
jon <jonwro...@gmail.com> writes:


>> > if you're already using biber, there's a much easier way. assuming you
>> > have run, say,
>> >
>> > pdflatex myfile.tex # or: any command that generates the .bcf
>> >
>> > then you can do:
>> >
>> > biber --output_format=bibtex --output_resolve myfile.bcf
>> >
>> > this should produce a .bib file that only contains what you cited in
>> > the .tex file.
>>
>> Jon, thanks, but I had already that without success. The root name of my
>> files is Universal. From a terminal I ran:
>>
>> $ biber --output_format=bibtex --output_resolve Universal.bcf
>> INFO - This is Biber 1.8
>> INFO - Logfile is 'Universal.blg'
>> INFO - Reading 'Universal.bcf'
>> INFO - Found 137 citekeys in bib section 0
>> INFO - Looking for bibtex format file 'Universal.bib'
>> ERROR - Cannot find 'Universal.bib'!
>> INFO - ERRORS: 1

> hmm, well it works for me. two questions/comments:
>
> 1. you are using biber 1.8, which is (for biber) old. would be worth
> exploring when biber started being able to create .bib files from
> .bcf files

I'm currently installing a newer version of my operating system, and
I'll install TeXLive, biber and reftex as well to give the biber command
a try.

> 2. can biber find Universal.bib on a normal run of biber? seems odd that
> it should work on a normal call of biber and fail when certain option
> switches are added...

I found the problem and it now works.

The Universal .bib file I had assembled from JabRef subdatabases is 4.5
Mb. The Universal_biber.bib file created by reftex is 300 Kb because a
lot of irrelevant garbage is cut. The RefTeX file is much neater. Off
hand the bib file it creates works well.

Haines


0 new messages