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?
Asked
Active
Viewed 279 times
1
-
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. – Henri Menke Jul 06 '20 at 04:18
-
Does this answer your question? Is it possible to create a LaTeX preamble "header"? – AndréC Jul 06 '20 at 04: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 – sachin rawat Jul 06 '20 at 05:32
-
I mean the title work as a function – sachin rawat Jul 06 '20 at 05:35
-
Just remove that title from the shared preamble file and place it into each individual file's preamble. – leandriis Jul 06 '20 at 06:06
1 Answers
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.
Pulkit Verma
- 113
-
3why is it a bad idea? also it is more idiomatic latex to save it as
something.styand then use\usepackagerather than\inputto input it. – David Carlisle Jul 06 '20 at 08: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. – Pulkit Verma Jul 06 '20 at 18:43