# Typesetting multiple TeX files

Q1. Is there an existing template with the following features:

(1) Multiple files, which I can typeset individually (as and when necessary).

(2) A single .bib file from which I can cite in different chapters, with links to the appendix and weblink.

Also, this is a very basic question, please let me know how to typeset the master and individual tex files as well.

Q2. Perhaps another silly question: can I say compile instead of typeset?

-
Welcome to TeX.SE! I've edited your post a bit, mainly by removing the thanks line and salutation (as omitting these items is the style of this group). –  Mico Jan 19 '12 at 19:15
I would recommend the standalone package, and personally don't see anything wrong with compile vs typeset. –  Peter Grill Jan 19 '12 at 19:19

To answer Q1, imagine you have master.tex, indiv1.tex and indiv2.tex. The challenge is to typeset master.tex, which includes indiv1.tex and indiv2.tex (with a bibliography) and to typeset indiv1.tex and indiv2.tex separately, also with a bibliography. The bibliography file is named "biblio.bib".

To solve the problem, create a single file named preamble.tex that each of master.tex, indiv1.tex, and indiv2.tex will include. In preamble put the following, which configures your bibliography and creates a command to conditionally include it:

%% Using biblatex to define the bibliograph.
\usepackage[natbib=true,style=authoryear,backend=bibtex8]{biblatex}

% Used by included files to know they
% are NOT standalone
\usepackage{ifthen}
\newboolean{standaloneFlag}
\setboolean{standaloneFlag}{true}

%% Command to conditionally typeset a bibliography.
\newcommand{\standaloneBib}{%%
\ifthenelse{\boolean{standaloneFlag}}%%
{\printbibliography}{}}


Change indiv1.tex and indiv2.tex to start with the following header and end with the \standaloneBib command:

\documentclass[12pt]{report}
\usepackage{standalone}
\input{preamble}
\begin{document}
...
\standaloneBib
\end{document}


However, in master.tex, you set the standaloneFlag value to false, \input the individual files, and always print the bibliography:

\documentclass[12pt]{report}
\usepackage{standalone}
\input{preamble}
\begin{document}
\setboolean{standaloneFlag}{false}
...
\input{indiv1}
\input{indiv2}
...
\printbibliography
\end{document}


Now you can run pdflatex on indiv1 or indiv2 and only that chapter will be typeset, with a bibliography. If you run pdflatex on master, it will typeset all chapters, including the bibliography.

-
Thanks a lot your help. I added "amscd, amsfonts, amsmath, amssymb, amstext, hyperref, graphicx" to your template I need some help with bibliographies. I have references of the following types (fr older files) \bibitem[Prescott, E. (1998)] {Prescott98} Prescott, E. 1998. \href{minneapolisfed.org/publications_papers/pub_display.cfm?id=761} {\emph{Business Cycle Research: Methods and Problems.}} FRB Minneapolis Working Paper 590. \end{thebibliography} How can I incorporate this kind of references with links in Justin's template? –  bakul Jan 20 '12 at 23:27
The simplest thing to do is turn those items into BiBTeX entries and put them in biblio.bib. Please mark my response as an answer! –  Justin Bailey Jan 20 '12 at 23:43