# How to load precompiled preamble from a specific folder?

According to this line How to speed up pdflatex for a very large document on MacOS X? . Precompile preamble significantly speed up pdflatex compilation.

The method is to generate a `precompile.fmt` file( which is 6MB in my case), then copy it to the folder contains the tex file, and add `%&precompile` to the first line of tex file.

I did so, and found it really speed up the compilation. But since the `precompile.fmt` file is a little bit large. I think to copy it to every tex folder is really a waste of disk space. So is there a way to load the same `precompile.fmt` file from the same location in different tex file?

• Go to the TeXShop Help Panel, select “Advanced Help” and then “Making and Using New TeX Formats”. – GuM Jun 4 '15 at 15:19
• are you working on a mac, or on some other platform? (if on a mac, tagging this question for that would be appropriate.) – barbara beeton Jun 4 '15 at 15:30
• @GustavoMezzetti I just figure out the way. Write the first line as `%& Path\precompile` – user15964 Jun 4 '15 at 15:31
• Well, sure. I thought you were looking for an automatized solution. Edit: but, after all, this is too. :-) – GuM Jun 4 '15 at 15:51
• @GustavoMezzetti What do you mean by "automatized solution“? I am currently using texstudio – user15964 Jun 4 '15 at 15:53

Move the `precompile.fmt` file in the folder

``````~/Library/texmf/web2c/pdftex
``````

creating the missing folders as you go.

On different TeX Live based distribution (the above path is good for MacTeX) the correct path would be

``````~/texmf/web2c/pdftex
``````

(assuming the standard setup is used).