TransWikia.com

chapterbib fails with subdirectories and latexmk

TeX - LaTeX Asked by Samuel Marks on September 9, 2020

I’ve got a rather simple layout that I’m trying to get working with latexmk. What am I doing wrong?

EDIT: Changed examples with result of latest headway made. all.bib had to be symlinked to the chapters subdirectory, and -f was required in latexmk.

Although this generates pretty much the desired output, I would say things are being done wrong, because -f is required, and the numbering of references is consistent throughout (rather than specific per chapter).

I tried omitting bibliographystyle from the chapter, and changing it to bibliography{../all}… to no avail.

Replicate with:

$ latexmk -gg -pdf -quiet -f

Latexmk: Run number 1 of rule 'pdflatex'
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
 restricted write18 enabled.
entering extended mode
Latexmk: Non-existent bbl file 'chapters/ch0.bbl'
 No file chapters/ch0.bbl.
Latexmk: Non-existent bbl file 'all.bbl'
 No file all.bbl.
Latexmk: Run number 1 of rule 'bibtex chapters/ch0'
For rule 'bibtex chapters/ch0', running '&run_bibtex(  )' ...
-- IEEEtranN.bst version 1.14 (2015/08/26) by Michael Shell.
-- http://www.michaelshell.org/tex/ieeetran/bibtex/
-- See the "IEEEtran_bst_HOWTO.pdf" manual for usage information.
** Natbib version - not for normal IEEE work.

Done.
Latexmk: Run number 1 of rule 'bibtex all'
For rule 'bibtex all', running '&run_bibtex(  )' ...
Illegal, another bibstyle command---line 3 of file chapters/ch0.aux
 : bibstyle
 :          {IEEEtranN}
I'm skipping whatever remains of this command
Illegal, another bibdata command---line 7 of file all.aux
 : bibdata
 :         {all}
I'm skipping whatever remains of this command
-- IEEEtranN.bst version 1.14 (2015/08/26) by Michael Shell.
-- http://www.michaelshell.org/tex/ieeetran/bibtex/
-- See the "IEEEtran_bst_HOWTO.pdf" manual for usage information.
** Natbib version - not for normal IEEE work.

Done.
(There were 2 error messages)
Latexmk: Run number 2 of rule 'pdflatex'
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
 restricted write18 enabled.
entering extended mode
Latexmk: Run number 2 of rule 'bibtex chapters/ch0'
For rule 'bibtex chapters/ch0', running '&run_bibtex(  )' ...
-- IEEEtranN.bst version 1.14 (2015/08/26) by Michael Shell.
-- http://www.michaelshell.org/tex/ieeetran/bibtex/
-- See the "IEEEtran_bst_HOWTO.pdf" manual for usage information.
** Natbib version - not for normal IEEE work.

Done.
Latexmk: Run number 2 of rule 'bibtex all'
For rule 'bibtex all', running '&run_bibtex(  )' ...
Illegal, another bibstyle command---line 3 of file chapters/ch0.aux
 : bibstyle
 :          {IEEEtranN}
I'm skipping whatever remains of this command
Illegal, another bibdata command---line 7 of file all.aux
 : bibdata
 :         {all}
I'm skipping whatever remains of this command
-- IEEEtranN.bst version 1.14 (2015/08/26) by Michael Shell.
-- http://www.michaelshell.org/tex/ieeetran/bibtex/
-- See the "IEEEtran_bst_HOWTO.pdf" manual for usage information.
** Natbib version - not for normal IEEE work.

Done.
(There were 2 error messages)
Latexmk: Run number 3 of rule 'pdflatex'
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
 restricted write18 enabled.
entering extended mode
Collected error summary (may duplicate other messages):
  bibtex all: Bibtex errors: See file 'all.blg'

all.tex

documentclass{book}
usepackage[sectionbib,square,sort,comma,numbers]{natbib}
usepackage{chapterbib}

%begin{filecontents*}{all.bib}end{filecontents*}

begin{document}

bibliographystyle{IEEEtranN}

include{chapters/ch0}

Hello randomcite{hawMaximizationExtractableRandomness2015} world

bibliography{all}

end{document}

chapters/ch0.tex

chapter{ch0}
so much divcite{govindarajuGeneticsFraminghamHeart2008}

bibliographystyle{IEEEtranN}
bibliography{all}

all.bib

@article{hawMaximizationExtractableRandomness2015,
  title = {Maximization of {{Extractable Randomness}} in a {{Quantum Random}}-{{Number Generator}}},
  author = {Haw, J. Y. and Assad, S. M. and Lance, A. M. and Ng, N. H. Y. and Sharma, V. and Lam, P. K. and Symul, T.},
  year = {2015},
  month = may,
  volume = {3},
  pages = {054004},
  issn = {2331-7019},
  doi = {10.1103/PhysRevApplied.3.054004},
  journal = {Physical Review Applied},
  language = {en},
  number = {5}
}

@article{govindarajuGeneticsFraminghamHeart2008,
  title = {Genetics of the {{Framingham Heart Study Population}}},
  author = {Govindaraju, Diddahally R. and Cupples, L. Adrienne and Kannel, William B. and O'Donnell, Christopher J. and Atwood, Larry D. and D'Agostino, Ralph B. and Fox, Caroline S. and Larson, Marty and Levy, Daniel and Morabito, Joanne and Vasan, Ramachandran S. and Splansky, Greta Lee and Wolf, Philip A. and Benjamin, Emelia J.},
  year = {2008},
  volume = {62},
  pages = {33--65},
  issn = {0065-2660},
  doi = {10.1016/S0065-2660(08)00602-0},
  abstract = {This article provides an introduction to the Framingham Heart Study (FHS) and the genetic research related to cardiovascular diseases conducted in this unique population. It briefly describes the origins of the study, the risk factors that contribute to heart disease and the approaches taken to discover the genetic basis of some of these risk factors. The genetic architecture of several biological risk factors has been explained using family studies, segregation analysis, heritability, phenotypic and genetic correlations. Many quantitative trait loci underlying cardiovascular diseases have been discovered using different molecular markers. Additionally, results from genome-wide association studies using 100,000 markers, and the prospects of using 550,000 markers for association studies are presented. Finally, the use of this unique sample in genotype and environment interaction is described.},
  journal = {Advances in genetics},
  language = {eng},
  pmid = {19010253}
}

One Answer

With chapterbib there needs to be a bibliographystyle command for each included chapter/bibliograpy. There should also be one at the beginning of the document if you are generating a separate whole-document bib. When generating the whole-doc-bib, bibtex will complain about multiple bibdata [from bibliography] and bibstyle [aka bibliographystyle] commands, but will complete its job properly.

It turns out that latexmk does know about chapterbib, and runs bibtex on each included file separately, and also on the whole document. The problem is that it sees the error messages from bibtex, thinks they are fatal, and aborts. Since latexmk already recognizes chapterbib, it should be possible to fix the problem fairly easily. In the meantime, run latexmk with the "-f" option. The latexmk documentation says

-f    Force latexmk to continue document processing despite errors.

That is a bit heavy-handed because it won't stop for any errors. Given that the original (or edited) question implies "-f" was used, the final result should be correct, despite the error messages! Indeed (according to the question edit) the "-gg" option is useful if you continue after failed runs of latexmk.

There is still a problem with the document that is not apparent in its reduced form. All the bibliographies use a numbered-in-order format, so the final overall bibliography will need different numbers from the chapter bibliographies, except for the simplest case as shown. The chapterbib documentation (again item 7 "Overall bibliographies") says

This produces an independent overall bibliography which only makes sense for various named bibliography styles; a numbered style, or one with any other type of automatic enumeration will give different tags in each bibliography and lead to confusion.

The potential solutions are

  • Use a named bibliography style in the root document for the overall bibliography. (I don't yet know if there is a way to tell natbib to use "numbers" only sometimes.)

  • Use the chapterbib option [duplicate] with an enumerated style so the final bibliography is a collection of the chapter bibliographies (but citations outside the included chapters are not allowed).

Answered by Donald Arseneau on September 9, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP