I want to combine several latex files. I started with 'combine' package. I encounter a error of \newcounter{par}
. Then I moved to using input or include, but then I faced unrecognized document class. Here is my example.
This is my main(mother) file
\documentclass[12pt]{article}
\usepackage{lipsum}
\title{dsjgk}%
\author{gfdl}%
\date{today}%
\begin{document}
\section{first file}
\input{1}
\end{document}
And then here is the other file(child, or subfile)
\documentclass[12pt]{article}
\usepackage{lipsum}
\begin{document}
\section{Something 1}
HERErfhwejlkfhsfhkjsdhjklfdshjk fd
jfhgkldf
kjfshjlksfdh\\\
fhkjsdhgld
jkdskjd
\\
jfkkgjdhf
\lipsum
\end{document}
And here is the error:
`C:\Users\Yashar\Desktop\test\1.tex
! LaTeX Error: Can be used only in preamble.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.1 \documentclass
[12pt]{article}
?
! Emergency stop.`
I will appreciate if you can help me on this.
Best Answer
use a main file of the form
then to have a document for just section 1 have
and the shared body of the section is in
body1.tex
and of course for section2 and any other sections have a
body2.tex
with the shared content and a wrapper document that includes it. Note that the wrapper document including the individual sections might use a different class or options to the main document, depending on requirements.