I'm cofiguring emacs with org. Principally I wrote in emacs using .org file so i want a standard header file where i define al my "use package" file in particular:


so here I see that i can create a header.tex file containing the upper code, so in the template i can simply recall #+LaTex_header: \input{path/header.tex}.
So I want to define it in my configuration.org document, and when i star emacs i want that, in addition of inint.el file, i want that it produce also a header.tex that i can use. How can I do?


I think what you are trying to achieve does not really require the workaround of generating a header.tex file, though you could certainly do that with Emacs.

The best thing in your case would be to define a custom LaTeX class, so at the beginning of your .org file you would simply call #+LATEX_CLASS: myarticle, for example:

(add-to-list 'org-latex-classes
                   ("\\section{%s}" . "\\section*{%s}")
                   ("\\subsection{%s}" . "\\subsection*{%s}")
                   ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                   ("\\paragraph{%s}" . "\\paragraph*{%s}")
                   ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

Check out the documentation of ox-latex for more information.

| improve this answer | |
  • i try to implement this but it doesn't work. so i add (with-eval-after-load 'ox-latex before and it compile, but when i call the class from a test file it doesn't work. – acidwinzip 77 Jul 12 '18 at 15:58
  • sorry, #+LATEX_CLASS: myarticle. I just fixed the answer. Good point about with-eval-after-load as well, but that's a bit tangent to the question at hand. – dangom Jul 12 '18 at 16:01

You can solve your problem easily by configuring the variable org-packages-alist, as shown in documentation:

org-latex-packages-alist is a variable defined in ‘org.el’. Its value is nil

Documentation: Alist of packages to be inserted in every LaTeX header.

These will be inserted after ‘org-latex-default-packages-alist’. Each element is either a cell or a string.

A cell is of the format:

("options" "package" SNIPPET-FLAG)


Take care to insert packages which not conflict with already declared packages in variable org-latex-default-packages-alist - this one can be also customized.

This way you do not need any additional export file as header.

| improve this answer | |
  • But my aim is to not modify anithing except configuration.org, so everything I need to see is under that file – acidwinzip 77 Jul 12 '18 at 16:14

Thats a different solution but the result is better. I removes the need for an extra file. You can add

#+LATEX_HEADER: \usepackage{package}

To your org-file to do same. Or if you use ox-extra.

#+header: header: yes
#+begin_export latex

You just need the fix from: https://lists.gnu.org/archive/html/emacs-orgmode/2015-11/msg00427.html

| improve this answer | |

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.