I am writing thesis in LaTeX and I am beginner in LaTeX. I read about combining files into main file, but it didn't help me much and my problem persists. I am giving minimal code what I am trying to do. Please help me with this problem. Compiler doesn't compile files when it encounters table or figure code and it seems that \usepackage is necessary for individual files as well.
%MAIN.tex
\documentclass[a4paper,12pt,oneside,openright,draft]{book}
\input{preamble}
\begin{document}
\frontmatter
\tableofcontents
\listoffigures
\listoftables
\mainmatter
\include{Chapter1}
\include{Chapter2}
\end{document}
%% end of MAIN.tex-------------------------
%%preamble.tex
\usepackage{microtype}
\usepackage[demo]{graphicx}
\usepackage{index}
\usepackage{ctable}
\usepackage{tabls}
\newcommand{\head}[1]{\textbf{#1}}
%%end of preamble.tex-------------------------
%%starting chapter1.tex
\chapter{Main chapter}
\section{First section of the first chapter}
\subsection{subsec 1}
\subsubsection{subsubsec 1}
\subsubsection{subsubsec 2}
\subsection{subsec 2}
{\Large Here's figure} \\
\begin{figure}[h!]
\centering
\includegraphics{test}
\caption{test {\index {new figures}}}
\label{fig:test1}
\end{figure}
%%end of chapter1.tex-------------------------
%%starting chapter2.tex
\chapter{Tables}
\begin{tabular}{cccc}
& \multicolumn{2}{c}{Input} & \multicolumn{1}{c}{Output}\\
& \head{A} & \head{B} & \head{C} \\
\cmidrule[1pt](l){1-3} \cmidrule[1pt](lr){4-4}
\multirow{3}{*}{Data} & 10 & 20 & 30\\
& 40 & 60 & 100\\
& 25 & 50 & 75\\
\bottomrule[1.5pt]
\vspace{2mm}
\caption{My table}
\end{tabular}
%end
Thanks for your suggestions. I modified my code, but still errors are there. I cannot figure out where I am going wrong. When I compile individual Chapter 2, there are no errors. But when I combine it to the main file, there is error
!missing \cr inserted
Main file:
\documentclass[a4paper,12pt,oneside,openright,draft]{book}
\input{preamble}
\begin{document}
\newcommand{\head}[1]{\textbf{#1}}
\frontmatter
\tableofcontents
\listoffigures
\listoftables
\mainmatter
\include{Chapter1}
\include{Chapter2}
\end{document}
Chapter 1
\chapter{Main chapter}
\section{First section of the first chapter}
\subsection{subsec 1}
\subsubsection{subsubsec 1}
\subsubsection{subsubsec 2}
\subsection{subsec 2}
{\Large Here's figure} \\
\begin{figure}[h!]
\centering
\includegraphics{test}
\caption{test}
\label{fig:test1}
\end{figure}
Chapter 2
\chapter{Tables}
\begin{table}
\begin{tabular}{cccc}
& \multicolumn{2}{c}{Input} & \multicolumn{1}{c}{Output}\\
& \head{A} & \head{B} & \head{C} \\
\cmidrule[1pt](l){1-3} \cmidrule[1pt](lr){4-4}
\multirow{3}{*}{Data} & 10 & 20 & 30\\
& 40 & 60 & 100\\
& 25 & 50 & 75\\
\bottomrule[1.5pt]
\end{tabular}
\vspace{2mm}
\caption{My table}
tabularenvironment. Did you try to compile only it to look for some errors? – Sigur Jan 10 '13 at 01:15\end{table}at the end, and now\newcommand{\head}[1]{\textbf{#1}}appears in both your main document and your preamble. It is not clear what you are doing when you say "compile individual Chapter 2", and "combine it to the main file". When TeX reports an error, you should normally get a file and line number associated to help you find out where the problem lies. – cyberSingularity Jan 10 '13 at 07:36