tueda / makefile4latex

A GNU Makefile for typesetting LaTeX documents.
MIT License
26 stars 3 forks source link

chapter-based bibliographic entries do not appear #31

Closed AlDanial closed 3 years ago

AlDanial commented 3 years ago

Hello, I've been using your Makefile on a large project for more than a year and am very pleased with it.

I've been struggling with its handling of chapter-based bibliographies however. I found a small project in the latex.org forums that demonstrates the problem I'm having. The second post to the thread at https://latex.org/forum/viewtopic.php?t=4647 has a small demo project, sample.zip, at https://latex.org/forum/download/file.php?id=979.

After downloading it, expanding it, deleting the derived files with rm *.{pdf,dvi,log,aux} *.b?? *.fls, I tried to rebuild the PDF with your Makefile by changing it to include

   TARGET = sample.pdf

then ran make. It rebuilt the PDF, but the citations appear as [?]. Also I tried to run bibtex on sample.aux then make again but that gave errors.

Can you give any tips that show how to rebuild sample.pdf with correct reference citations?

tueda commented 3 years ago

Thank you for filing the issue. In your case, you need to run

bibtex chp01
bibtex chp02
bibtex chp03

after typesetting sample.tex once, and then typeset sample.tex again. But you should not run bibtex for sample.

This is a rather complicated task to automate... It requires parsing log files to determine which files should be run with bibtex.

For now, I would suggest a manual update for the bibliography. Create latex.mk with the following contents:

CHAPTERS = chp01 chp02 chp03

MOSTLYCLEANFILES = \
    $(addsuffix .aux,$(CHAPTERS)) \
    $(addsuffix .bbl,$(CHAPTERS)) \
    $(addsuffix .blg,$(CHAPTERS))

%.bbl: %.aux
    @$(call exec,$(bibtex) $*,,bibtex)

update-chapterbib:
    $(MAKE)
    $(MAKE) $(addsuffix .bbl,$(CHAPTERS))
    touch $(srctexfiles)
    $(MAKE)

Then make update-chapterbib should reproduce the PDF file with the correct reference numbers. You can always use make update-chapterbib instead of make, but it can be considerably slower.

By the way, refsection of the biblatex package is supported by the Makefile (with some limitations), which may be used as an alternative to the chapterbib package.

AlDanial commented 3 years ago

Thanks for the quick reply. I changed the sample.tex to use biblatex + refsection and that worked well with your Makefile. (I tried the latex.mk method too, but that did not resolve the citations.)

I then attempted to change my large project in the same way but that gave me this problem, https://tex.stackexchange.com/questions/555438/problem-with-biblatex-when-using-any-options-with-usepackage , which is unrelated to your Makefile. I'm hoping this doesn't force me back to bibtex!