Document ClassesInclude child .tex with different class

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
Alberto
Posts: 2
Joined: Wed Oct 22, 2014 10:44 pm

Include child .tex with different class

Post by Alberto »

Hi there.

I'm required to do a document that uses a custom document class.

Now, I need to insert another child document with a completely different and custom document class and some packages that are not included in the main document.

I'm not sure how to do this, since using \input {doc.tex} gives me a

Code: Select all

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.3 \documentclass
                  [english]{scrreprt}
error.

I'm really new to LaTeX, since I have been using LyX for ages, but to do this work I need LaTeX since the document classes can't be used in LyX.

Compiling the child document yields no error, and compiling the main document without the \input{} also yields no error, so I'm not sure where to include the different packages and document classes for it to successfully compile.

Any help?

Thanks in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Include child .tex with different class

Post by Johannes_B »

You could do some trickery, but since both documents are pretty different, i suggest to use package pdfpages and simply include the whole (child) pdf as is into the main document.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Alberto
Posts: 2
Joined: Wed Oct 22, 2014 10:44 pm

Re: Include child .tex with different class

Post by Alberto »

Yes, it works. Thanks a lot.
Post Reply