5

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.

5
  • Yes you're right. Actually I tried both "koma-article" and "scrartcl", but in both cases I get the same error message. Apr 16, 2017 at 9:23
  • @Schweinebacke: I added the codes to my .emacs. But when I evaluate it, I get error messages. For the (require 'org-latex) code: "cannot open load file: no such a file, org-latex" (I translate, in my pc it is in french). For the (add-to-list…) code, I see: "symbol's value as variable is void: org-export-latex-classes". I didn't know I should install packages in order to export to a Koma class. Maybe it would be easier just to change it manually once the doc is exported... Apr 16, 2017 at 10:39
  • @Schweinebacke yes I deleted comment, thanks Apr 16, 2017 at 11:48
  • 2
    Try it with (require 'ox-latex) and (add-to-list 'org-latex-classes '...). Apr 16, 2017 at 11:57
  • @ArashEsbati: Yes it works, thanks. So the correct code for the list, in which we must add the scrartcl class, is org-latex-classes, and not org-export-latex-classes as said in the org-mode website. Anyway I wonder why koma-script is not included by default in the org-mode recognized classes list, since it is widely used as an alternative to the latex standard classes. Thank you everybody for your help. Apr 16, 2017 at 12:38

1 Answer 1

10

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}"))))

You must log in to answer this question.

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