Text FormattingChapter-wise referencing in LaTeX

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

Chapter-wise referencing in LaTeX

Post by samirandam »

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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Chapter-wise referencing in LaTeX

Post by Johannes_B »

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.

Code: Select all

%\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
(45.57 KiB) Downloaded 699 times
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

Chapter-wise referencing in LaTeX

Post by samirandam »

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.

Many many thanks in advance.

Thanks
Samiran.
Attachments
sdam_test.zip
MWE_Dir
(34.09 KiB) Downloaded 596 times
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Chapter-wise referencing in LaTeX

Post by Johannes_B »

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

Chapter-wise referencing in LaTeX

Post by samirandam »

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.tex
bibtex chap1.aux
bibtex chap2.aux
latex test.tex
latex test.tex
dvips -Ppdf -G0 test.dvi
ps2pdf 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.

Thanks for your help.

Regards
Samiran.
Post Reply