# Reducing LATEX_HEADER clutter at the top of my org files

I often write notes in org mode and export them to latex. However, because some documents are complex I need to include many latex packages at the top like so:

Is it possible to store all the latex header commands (\usepackage, macros definitions etc.) in a separate tex file so that I can just have a single line include at the top of the org file? This will reduce a lot of the clutter and make it easier for me to add packages.

You can make use of a #+SETUPFILE:

Put all of these settings in a file, for example ./setup/setupfile.org, and then include them into your document with

#+SETUPFILE: ./setup/setupfile.org

In this file, you can also include #+OPTIONS:, #+AUTHOR, and similar in-buffer settings. What's even more useful, is that if you load the #+SETUPFILE: first, you can then override some of these configurations with local settings.

Another solution is to make use of #+INCLUDE: "./setup/more-settings.org" src org (note the ") which simply includes the file contents as org source. This is a little more versatile, as there can more than one #+INCLUDE where there (afaik) can be only one #+SETUPFILE.

Finally, to hide the clutter visually, you can also put all of these local settings in a drawer (i.e., between a line with :DRAWER: and a line with :END:), and simply hide them with tab.

• In my practical experience the drawer solution is the most convenient and fastest way of working with headers. – Dieter.Wilhelm May 29 '18 at 7:04

An alternative solution is to check/customize the variable org-latex-packages-alist - add there all your needed \usepackage{...}.

This variable is declared in and used by the ox-latex, so your org configuration must have an declaration (require 'os-latex). This way no lines to add to org documents, except the title.

As for macros, an usual place to store is the yasnippet package, if you use it.

An alternative solution is to use a non exported headline to wrap configuration:

#+AUTHOR:
#+STARTUP: showall
...

The advantage of this solution vs drawers is that you can easily include sophisticated configuration, such as LaTeX blocks

#+BEGIN_EXPORT LATEX
...
#+END_EXPORT

which are not read (by default) when in drawers.

The advantage of this solution vs configuration files (setupfile or include) is that you can easily change the configuration since it is included in the current file.

Finally, if you want this headline to remain closed by default when opening you org file, you can use the following syntax: