TeX and LaTeX

Book and chapters

We would like to process the entire book and each chapter separately. Each chapter <k> is inside its subdirectory Ch<k> and its pictures in the subsubdirectory Ch<k>/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<name> 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

vlado/work/bib/book/tex.txt · Last modified: 2024/01/20 16:04 by vlado
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki