I use emacs org-mode for keeping track of notes and todos. Sometimes I wish to export notes as a latex file, using the official company style. To get the correct heading styles I run the following elisp:
(add-to-list 'org-latex-classes
'("report"
"\\documentclass{report}"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
)
Unfortunately, this doesn't work in .emacs. I get the following error:
Debugger entered--Lisp error: (void-variable org-latex-classes)
(member (quote ("report" "\\documentclass{report}" ("\\chapter{%s}" . "\\chapter*{%s}") ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) org-latex-classes)
(if (member (quote ("report" "\\documentclass{report}" ("\\chapter{%s}" . "\\chapter*{%s}") ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) org-latex-classes) org-latex-classes (setq org-latex-classes (cons (quote ("report" "\\documentclass{report}" ("\\chapter{%s}" . "\\chapter*{%s}") ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) org-latex-classes)))
eval((if (member (quote ("report" "\\documentclass{report}" ("\\chapter{%s}" . "\\chapter*{%s}") ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) org-latex-classes) org-latex-classes (setq org-latex-classes (cons (quote ("report" "\\documentclass{report}" ("\\chapter{%s}" . "\\chapter*{%s}") ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) org-latex-classes))) nil)
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
command-execute(eval-last-sexp)
The command only works if I have run org-export-dispatch to export to PDF before running add-to-list.
I'm kind of a beginner at elisp and configuring Emacs, and even more of a beginner at using Latex. So if someone could tell me how to get the command to work in .emacs I would be very grateful. I'm guessing the list has not been created yet when .emacs is loaded, but I'm at a loss about how to make this work.
Best Answer
Use the following:
This adjusts the variable as soon as the ox-latex package is loaded.