## LaTeX forum ⇒ Text Formatting ⇒ Chapter-wise referencing in LaTeX

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
samirandam
Posts: 7
Joined: Sat Oct 10, 2015 7:47 pm

### Chapter-wise referencing in LaTeX

I am writing a book based on Springer's svmono (http://resource-cms.springer.com/spring ... monographs) document class.

Ever since I started preparing my academic documents in LaTeX, I have been using BibTeX to produce bibliographies for all of my documents (thesis, papers, technical documents, etc.). And this way it used to generate the bibliography at the end of the document either in form of a chapter (in case of Thesis) or in form of a section (in case of paper). However, with my current assignment, I need to include the Reference section at the end of each chapter. I have a single ref.bib file which contains all of the references. Now I want to use that ref.bib and Springer's bibliography style file (spmpsci.bst) to generate separate reference section at the end of each chapter. Could you please help me out?

Thanks
SAMIRAN.

Tags:

Johannes_B
Site Moderator
Posts: 4173
Joined: Thu Nov 01, 2012 4:08 pm
Using chapterbib, you should split your chapters to different tex-files and include them in your document. You have to run bibtex on the different generated aux-files. A tool like latexmk will be of great help.

%\RequirePackage{filecontents}\begin{filecontents*}{wombat.tex}\chapter{Walzing Womabt }\cite{companion}\bibliographystyle{plain}\bibliography{biblatex-examples}% sample database from the biblatex package\end{filecontents*}\begin{filecontents*}{snake.tex}\chapter{Salsa Snake}\cite{aristotle:physics}\bibliographystyle{plain}\bibliography{biblatex-examples}% sample database from the biblatex package\end{filecontents*}\begin{filecontents*}{duck.tex}\chapter{Dixie-dancing Duck}\cite{ctan}\bibliographystyle{plain}\bibliography{biblatex-examples}% sample database from the biblatex package\end{filecontents*}\documentclass{svmono}\usepackage[sectionbib]{chapterbib}\begin{document} \include{wombat}\include{snake}\include{duck}  \end{document}
Attachments
samirandamChapterbib.pdf
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

samirandam
Posts: 7
Joined: Sat Oct 10, 2015 7:47 pm
Hi Johannes,

I am trying to establish a MWE following your guidance. Attached zip file contains the working directory (main file: test.tex, chapters: chap1.tex, chap2.tex, bibliography file: book.bib, document class file: svmono.cls, bibliography style file: spmpsci.bst).

I am using command line in linux to compile the files. I am first running the command - latex test.tex, then I tried to run bibtex chap1.aux which threw an error. I guess, I am doing something wrong. Could you please check whether the dir. structure is fine or not. If it is correct then please guide me how to compile them step-by-step commands.

Thanks
Samiran.
Attachments
sdam_test.zip
MWE_Dir

Johannes_B
Site Moderator
Posts: 4173
Joined: Thu Nov 01, 2012 4:08 pm
Good example.

You test file contains the following line: \include{\chap2}

The backslash inside the argument is wrong, this will lead to a latex error.
You mentioned an error while running bibtex, i didn't get any. Please show us the blg-file created by Bibtex.

I find it exhausting having to think about the order and how to compile. I am not alone, and somebody created a great tool for automation called latexmk.
I am using vim for editing, inside vim i call latexmk -pdf %, terminal output rushes by and i get the ready and final pdf. You should try it out
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

samirandam
Posts: 7
Joined: Sat Oct 10, 2015 7:47 pm
Hi Johannes,

Thank you for pointing out the error in syntax.

The good news is I have figured out the series of commands that I must run to get the final PDF. I am enlisting those commands here for others.

latex test.texbibtex chap1.auxbibtex chap2.auxlatex test.texlatex test.texdvips -Ppdf -G0 test.dvips2pdf test.ps

After running the bibtex, I had to run latex on the main file twice to get the citation properly in the final PDF.