1

Can we store a latex preamble into another file to avoid writing all same stuff in another file.If we can then can we change the title in another Tex file?

5
  • Yes, it is possible but this is generally a bad idea. Such a shared preamble tends to grow in complexity over time such that older documents don't compile with the newer version anymore. Also loading a huge bunch of unnecessary packages will make document compilation horribly slow. Jul 6, 2020 at 4:18
  • Does this answer your question? Is it possible to create a LaTeX preamble "header"?
    – AndréC
    Jul 6, 2020 at 4:56
  • Yes but Partially sir. Suppose I have define title in that file and I want to change title in every Tex document so can I do this Jul 6, 2020 at 5:32
  • I mean the title work as a function Jul 6, 2020 at 5:35
  • Just remove that title from the shared preamble file and place it into each individual file's preamble.
    – leandriis
    Jul 6, 2020 at 6:06

1 Answer 1

2

Yes. Write your preamble in a tex file, lets say, preamble.tex

In the main file, where you want to add the preamble, just use

\input{preamble.tex}

This is in general, a bad idea though. I hope you have a good justification of using it in this way though.

2
  • 2
    why is it a bad idea? also it is more idiomatic latex to save it as something.sty and then use \usepackage rather than \input to input it. Jul 6, 2020 at 8:52
  • "Can we store a latex preamble into another file to avoid writing all same stuff in another file.If we can then can we change the title in another Tex file" From the question, it felt like Sachin wants to use the same preamble including information like Title in multiple files. If not maintained correctly, it might be changed to accommodate something in one document, but the same changes might behave differently in another document. It's very easy to mess up when using the same preamble with document-specific information in multiple documents. Jul 6, 2020 at 18:43

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.