Since I am using (almost) the same set up for my tex documents, I wonder if there is a way to create a preamble with my default packages and to recall it anytime I want to create a tex document.

If yes, how I can call this "default" preamble?

Thanks in advance


4 Answers 4


An option is to create a package (sty file) that consists to use your default package:

  [2015/11/18 MyPreamble]

\RequirePackage{graphicx} % Put the package you need as required package


Instead of putting \usepackage, you must use \RequirePackage to use them. You can also write \newcommand and so.

You can acces it by following the answers from this question: Where do I place my own .sty or .cls files, to make them available to all my .tex files?

You can call in your document \usepackage{mypreamble} and voila:



With my own preamble



As you could see I include graphicx in mypreamble.sty and I'm able to include a picture:

enter image description here

  • I am relative new to LaTex, so I would be grateful if you could give me a more detailed MWE :)
    – Yorgos
    Commented Nov 18, 2015 at 8:09
  • @Yorgos see my edit ;-) Commented Nov 18, 2015 at 8:15
  • 1
    You might add that you can put this in $HOME/texmf/tex/latex/local/ and it will be automatically found in any file. Commented Nov 18, 2015 at 17:20
  • 1
    @AndrewCashner I added it as a link to the question tex.stackexchange.com/questions/1137/… juste click on after installation ;-) (it's also explain the possibility for windows user) Commented Nov 18, 2015 at 17:23

Why you shouldn't do this

Since this is longer than a comment, I will add it as an answer even though it's an answer that recommends not doing what you are asking.

There are both conceptual and practical reasons for not doing so. Of course, if you find yourself producing particular kinds of documents with a similar structure, there may be grounds to create a custom class or package for that kind of document. But if you just find that in most of your documents you load the same sets of packages, I would not recommend this, but instead use your editor to save some sort of standard template documents.

Conceptual arguments

Conceptually, packages should add a specific set of functionality to a document of any kind.

Document classes, on the other hand, should provide the markup for a particular kind of document.

See the following question for some discussion of the distinction.

Now what you are suggesting seems to be neither of these, but rather is just the list of \usepackage commands (perhaps with some added macros) that you commonly use in most of your documents. This doesn't meet either of these criteria, and so should probably not be implemented as a package or a class.

Now if you do have needs for a particular functionality then of course creating your own package makes sense. For example, I have a package which I load when I write letters which contains macros for my signature etc. I also have created a class for writing conference abstracts, since they require very condensed formatting due to word/page size limits.

Practical reasons

Even if you use some packages very frequently, it's likely that you will not need every package you load in your default preamble in every document. So you will effectively be loading packages you don't need. For smaller packages this isn't much of an issue, but for large package like TikZ for example, this will increase the compilation time for those documents.

Creating a default preamble effectively hides the packages that any document is using from you. This means that you will have to remember which packages you always load if you ever need to look for documentation for example or to debug an error that might arise from one of the packages. This may not seem like a big deal, but in my experience it can get annoying quite quickly, because over time you will forget what's in your standard preamble. It makes more sense to have exactly the packages you need loaded explicitly in the preamble of each document you write.

Creating a default preamble also makes your documents much less portable. You can't just put them on a flash drive and use them on someone else's computer, unless you also copy over the preamble package. Nor can you upload them to journals or share them with collaborators (without sharing the preamble code too).

What you should do instead

If what you want to do is just have a bunch of packages loaded and a few other things, you should use your editor to save a template. I use TeXShop on the Mac, and it allows me to create "Stationery" files which are document templates which have a standard preamble which I can define. When I open a file using the Stationery I get a new blank document with anything I like already there. Then I can delete the packages I'm not using easily to create each document so that it conforms to the criteria above.

You can do the same in other editors too. TeXStudio has a "Make Template" function (in the File menu). Create a new document with the preamble you use the most and then choose "Make Template" from the File Menu. A dialogue box will show up which allows you to name it, and add a description (and even a licence). Once that's done, for subsequent documents you can use "New From Template" to open a new untitled document with that basic structure already filled in.

TeXworks also has such a function. You can create template files and store them in <resources>/templates and they will be available using the "New From Template" menu item.

  • Very interesting solution! Do you know how to apply it in TexStudio on Ubuntu 14.04?
    – Yorgos
    Commented Dec 23, 2015 at 9:07
  • 1
    @Yorgos Yes. I've updated my answer with some information about TeXStudio and TeXworks, both of which can do this.
    – Alan Munn
    Commented Dec 23, 2015 at 14:53
  • @AlanMunn I'm also a TexShop user and I'm familiar with the Stationery. TexShop also allows us to save "Templates". Is there a difference between Stationery and Templates? I've been kicking around stackexchange and other internet sights and no one seems to address this question.
    – HTG
    Commented Jan 28, 2017 at 18:48
  • @HTG I've never actually used the Templates menu, but it seems to be commented example documents, and choosing one inserts that code into the current document. I think they are intended to help new users. The Stationery route is more efficient, since it automatically creates a new document with the Stationery content in it. I could see a use for the Templates menu in another way, as a way to hold fragments of code you use a frequently.
    – Alan Munn
    Commented Jan 28, 2017 at 20:17

If you don't want to make a custom package, the other option is to put your preamble into a .tex file then use \input{file_path\preamble.tex} before you begin your document where file_path is the full path to preamble.tex.

  • 4
    this works but why not give the file a .sty extension and use \usepackage rather than \input? Commented Nov 18, 2015 at 11:00
  • 2
    @DavidCarlisle One advantage of \input: It allows you to also put the \documentclass to another file. Don't know if that's a good idea, but still.
    – jarauh
    Commented Nov 18, 2015 at 18:45
  • 1
    @jarauh You can also use different class with a package Commented Nov 19, 2015 at 7:24
  1. You can create a new .tex file only having your preamble and you can use in your file..
  2. My model Preamble file will only have these contents...


  1. Save only these details as a .tex file.(I am saving it as preamble.tex
  2. Then in your new file's folder copy and paste the preamble.tex
  3. Now just call this file into your new file, for example

your work



  1. Your preamble.tex file should not contain any codes like \end{document} ...etc
  2. Verify that the preamble.tex file is in your folder where your new file is there.
  • You should use \input{preamble}. The extension is not needed ;-) Commented Nov 25, 2015 at 10:07
  • ofcourse..its not necessory..but keeping will not harm..
    – David
    Commented Nov 25, 2015 at 10:36
  • It will not harm of course but people use extension everywhere after. And using extension with \includegraphic could create some trouble. But of course your question is totally fine ;-) Commented Nov 25, 2015 at 10:40
  • 1
    You are right..I also faced this problem earlier.. I have editted my answer..@RomainPicot
    – David
    Commented Nov 26, 2015 at 3:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .