1

I would like to create a LaTeX file from several different other LaTeX files that might use different definitions of the same macros or might use incompatible packages.

Is it possible to have within a same LaTeX file different “preambles” corresponding to different parts?

If not, do you suggest any idea?

edit

Here is what I want to achieve. It is for a webapp: several users type their LaTeX file with their own preamble. They only type the body of the document and maintain two other files: a file of macros and a file of “\usepackages{...}”. Then I want to use their files and put them in a “global” .tex file, with additional content (header, etc.)

I want to make this process automatic.

  • Sure thing! It depends on how you want to construct it. Incompatibilities are usually resolved using conditions (like package options or \if-statements). Could you provide more detail regarding what you have in mind? – Werner Jan 28 '18 at 7:43
  • @Werner I have updated the question. – Colas Jan 28 '18 at 9:38
  • 1
    So you wanto to merge the usepackage files? And this automatic? Do you look for something like tex.ac.uk/FAQ-multidoc.html? Please add what you really want to do with some details how files will look and about which kind of packages we are talking. – TeXnician Jan 28 '18 at 11:09
  • latex will not include a package twice so most of the time it's going to be Ok to input all the "usepackage" files from all of the documents. – David Carlisle Jan 28 '18 at 20:31
4

The short answer is no; LaTeX is designed around the model of typesetting single document only.

The combine package attempts to combine documents with multiple preambles but it's not a seamless process by any means. For some combinations of packages it works okay, but for other packages it simply fails.

I would generally recommend you try to organise the system so that each user's document is typeset to a separate PDF file and then the PDF files are combined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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