[Tex/LaTex] Using KOMA-Script article with org-mode

koma-scriptorg-mode

I want to export a document from org-mode to latex with the KOMA-Script article class scrartcl. I thought it was as easy as to switch from article to book. So I put in my org file the following configuration (the doc is a subtree of a larger document):

:EXPORT_LATEX_CLASS: koma-article
:EXPORT_LATEX_CLASS_OPTIONS: [11pt,twoside,a4paper]

However, after I do the export comand, I get the error message :

Unknown latex class `koma-article'

I couldn't imagine that koma classes were not automatically recognized by org-mode. I've done some research on the web and tried this solution but it didn't work.

What's wrong ? Is there something obvious I'm not doing ?

Thanks for your help.

Added information after a coment: the correct name of the class is scrartcl and not koma-article. Actually I tried both names koma-article and scrartcl, but in both cases I get the same error message.

Best Answer

From org manual:

By default, the LaTeX output uses the class article.

You can change this globally by setting a different value for org-latex-default-class or locally by adding an option like #+LATEX_CLASS: myclass in your file, or with a EXPORT_LATEX_CLASS property that applies when exporting a region containing only this (sub)tree. The class must be listed in org-latex-classes. This variable defines a header template for each class, and allows you to define the sectioning structure for each class. You can also define your own classes there.

org-latex-classes is an association list with LaTeX classes and associated header and structure. Hence, you have to add your koma-article to this list. I suggest you put something like this in your init file:

(eval-after-load "ox-latex"
  '(add-to-list 'org-latex-classes
                '("koma-article" "\\documentclass{scrartcl}"
                  ("\\section{%s}" . "\\section*{%s}")
                  ("\\subsection{%s}" . "\\subsection*{%s}")
                  ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                  ("\\paragraph{%s}" . "\\paragraph*{%s}")
                  ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))

If you're using Emacs 24.4. or later, you can use:

(with-eval-after-load "ox-latex"
  (add-to-list 'org-latex-classes
               '("koma-article" "\\documentclass{scrartcl}"
                 ("\\section{%s}" . "\\section*{%s}")
                 ("\\subsection{%s}" . "\\subsection*{%s}")
                 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                 ("\\paragraph{%s}" . "\\paragraph*{%s}")
                 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))