====== TeX and LaTeX ====== ===== Book and chapters ===== We would like to process the entire book and each chapter separately. Each chapter is inside its subdirectory **''Ch''** and its pictures in the subsubdirectory **''Ch''****''/pics''** . The BibTeX bibliography is in the file **''bibnet.bib''** in the main directory. We put common styles and commands in the file **''preamble.sty''**. \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{preamble}[2024/01/19 bibnet book LaTeX style] ... \usepackage{amsmath} \makeindex{topic} \setcounter{tocdepth}{2} \renewcommand{\topfraction}{0.9} \newenvironment{remark}{\medbreak\par\noindent\textbf{Remark:}\ }{\QED} \newcommand{\network}[1]{\mathcal{#1}} \newcommand{\WA}{\mathbf{W\!\!A}} ... \endinput The template for the book % book.tex \newif\ifHeader %\Headertrue \Headerfalse \newif\ifBook \Booktrue %\Bookfalse \newif\ifChapter \Chapterfalse \ifBook \documentclass[a4paper,twoside]{WileySev} \else \documentclass{WileySev} \fi \newcommand*{\BuildingFromMainFile}{} \usepackage{subfiles} \usepackage{preamble} \usepackage[nottoc]{tocbibind} \graphicspath{{./pics}{./Ch01/pics/}{./Ch02/pics/}{./Ch03/pics/}{./Ch04/pics/}} \begin{document} \booktitle{Analysis of bibliographic networks} ... % Ch01: Introduction \subfile{Ch01/ChIntro} % Ch02: Introduction to networks \subfile{Ch02/ChBibNets} ... \clearpage \bibliographystyle{acm} \bibliography{bibnet} \end{document} For processing a chapter **''Ch''** separately (in the chapter's directory) we have to add to it some additional code at its beginning and its end. % ChBibnets.tex % Ch02: Introduction to networks \ifdefined\BuildingFromMainFile \else\documentclass{../WileySev} \usepackage{import} \import{../}{preamble.sty} \setcounter{chapter}{1}\setcounter{page}{101} \offprintinfo{Analysis of bibliographic networks\\ \today \quad \clock}{V. Batagelj, D. Maltseva} \graphicspath{{./pics}{../Ch01/pics/}{../Ch02/pics/}{../Ch03/pics/}{../Ch04/pics/}} \begin{document}\fi \chapter{Bibliographic networks}\label{ch:bibnets} ... CHAPTER BODY \ifdefined\BuildingFromMainFile \else\bibliographystyle{acm}\bibliography{../bibnet}\end{document}\fi \endinput Saving the start/end chapter code in the main directory on files **''StartChapter.tex''** and **''EndChapter.tex''** we get a more readable chapter template % ChBibnets.tex % Ch02: Introduction to networks \input{../StartChapter.tex} \ifdefined\BuildingFromMainFile\else\setcounter{chapter}{1}\setcounter{page}{101}\fi % =================== Start Chapter ================================= \chapter{Bibliographic networks}\label{ch:bibnets} ... CHAPTER BODY % =================== End Chapter ================================== \input{../EndChapter.tex} To get the book/chapter bibliography right, we have to process the corresponding file several times pdflatex ChBibnets bibtex ChBibnets pdflatex ChBibnets pdflatex ChBibnets ==== Links ==== - C:\Users\vlado\test\TeX\bibsub2 - https://www.overleaf.com/learn/latex/Management_in_a_large_project - https://georgepavlides.info/writing-a-latex-book-with-multiple-subfiles-and-a-single-bibliography-file/ - https://copyprogramming.com/howto/how-to-use-chapterbib-package-syntax - https://chenzhijin.com/en/article/Use%20chapterbib%20with%20subfile/