Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing a book. I am trying to build a preamble in such a way that there is master.tex and different files for different chapters, preface, contents etc. I am 4/10 in latex knowledge. I will be highly obliged if somebody help me to build a master latex preamble to write a book. Thanks

share|improve this question
5  
I think you'll need to qualify your requirements way more than this for an objective answer to be possible. –  Joseph R. Jan 5 at 1:43
    
Welcome to TeX.SX! You can have a look on our starter guide to familiarize yourself further with our format. –  cmhughes Jan 5 at 1:48
    
You don't want a different file for the contents, though. That is just one line in your master file (\tableofcontents) since latex will construct this automatically. (At least, there is a specific file for this but it is generated by latex and you don't need to think about it.) It would be especially helpful if you could post what you have so far and explain what it does or doesn't do that you care about. –  cfr Jan 5 at 2:03
1  
If you need anything other than the standard \include{file} for each chapter that is in a separate file, you will need to give more details of your requirements. –  David Carlisle Jan 5 at 2:09

1 Answer 1

The basic structure would be to have some directory, /book/, then have subdirectories:

  1. /book/tex/ which would contain the actual chapters in their own files; so, things like chapter-0.tex, preface.tex, chapter-29.tex, bibliography.tex, etc.
  2. /book/img/ which would have the images, if you have any.

You would probably want to isolate your macros in its own file, like /book/macros.tex.

Note you would want to keep track of the front matter apart from the main-matter (see, e.g., this thread for example).

Then your book would be /book/book.tex. You would run this through LaTeX. Its preamble would be:

\documentclass{book}
\input{macros}

\title{The Great American Novel}
\author{Alex Nelson}
\date{\today}

\begin{document}
\frontmatter
\maketitle
\tableofcontents
\include{tex/preface} % if you have a preface, or foreward, include them here
\mainmatter
\include{tex/chapter-0}
\include{tex/chapter-1}
% ... 
\backmatter
\appendix
\include{tex/appendix-0}
% ...
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.