LaTeX forum ⇒ Text FormattingChapter-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

Postby samirandam » Mon Oct 12, 2015 5:34 pm

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:

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Oct 12, 2015 6:47 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.

  1. %\RequirePackage{filecontents}
  2. \begin{filecontents*}{wombat.tex}
  3. \chapter{Walzing Womabt }
  4. \cite{companion}
  5. \bibliographystyle{plain}
  6. \bibliography{biblatex-examples}% sample database from the biblatex package
  7. \end{filecontents*}
  8. \begin{filecontents*}{snake.tex}
  9. \chapter{Salsa Snake}
  10. \cite{aristotle:physics}
  11. \bibliographystyle{plain}
  12. \bibliography{biblatex-examples}% sample database from the biblatex package
  13. \end{filecontents*}
  14. \begin{filecontents*}{duck.tex}
  15. \chapter{Dixie-dancing Duck}
  16. \cite{ctan}
  17. \bibliographystyle{plain}
  18. \bibliography{biblatex-examples}% sample database from the biblatex package
  19. \end{filecontents*}
  20. \documentclass{svmono}
  21. \usepackage[sectionbib]{chapterbib}
  22. \begin{document}
  23.  
  24. \include{wombat}
  25. \include{snake}
  26. \include{duck}
  27.  
  28.  
  29. \end{document}
Attachments
samirandamChapterbib.pdf
(45.57 KiB) Downloaded 222 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

Postby samirandam » Wed Oct 14, 2015 2:54 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.

Many many thanks in advance.

Thanks
Samiran.
Attachments
sdam_test.zip
MWE_Dir
(34.09 KiB) Downloaded 180 times

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Wed Oct 14, 2015 7:33 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

Postby samirandam » Thu Oct 15, 2015 5:50 am

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.


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 4 guests