Simplify setting the ox-export local buffer variables
This commit is contained in:
parent
a3f825e61b
commit
02bf1bda54
83
README.org
83
README.org
@ -1,6 +1,6 @@
|
||||
#+title: Emacs setup for use with LaTeX, Org, and Python
|
||||
#+author: Gerard Vermeulen
|
||||
#+latex_class: article-1+2+3
|
||||
#+latex_class: article-local
|
||||
#+latex_class_options: [11pt,a4paper,english,svgnames,tables]
|
||||
#+setupfile: "setup-include.org"
|
||||
#+include: "setup-include.org"
|
||||
@ -2015,59 +2015,50 @@ Listing [[lst:use-latex-header-1]], [[lst:use-latex-header-2]], [[lst:use-latex-
|
||||
:CUSTOM_ID: sec:advanced-latex-export-settings
|
||||
:END:
|
||||
|
||||
[[https://emacs.stackexchange.com/questions/47347/customizing-org-latex-title-command-to-edit-title-page][How to customize =org-latex-title-command= only in this buffer]]
|
||||
Listing [[lst:ox-latex-emacs-lisp-setup]] initializes the buffer local variables
|
||||
=org-latex-classes=, =org-latex-title-command=, =org-latex-toc-command=, and
|
||||
=org-latex-subtitle-format=. Listing [[lst/title-page]] is a template to initialize
|
||||
=org-latex-title-command=. Type {{{kbd(M-x org-latex-classes)}}}, {{{kbd(M-x
|
||||
org-latex-subtitle-format)}}}, {{{kbd(M-x org-latex-title-command)}}}, and
|
||||
{{{kbd(M-x org-latex-toc-command)}}} to read how those variables control
|
||||
exporting from Org-mode to LaTeX.
|
||||
|
||||
#+caption[Define =my-ox-latex-export-buffer-local-variables=]:
|
||||
#+caption: Define =my-ox-latex-export-buffer-local-variables=.
|
||||
#+name: lst:emacs-lisp-setup-defun
|
||||
#+caption[Define buffer local =ox-latex= variables]:
|
||||
#+caption: Define buffer local =-ox-latex= variables.
|
||||
#+header: :var title-page=lst/title-page
|
||||
#+name: lst:ox-latex-emacs-lisp-setup
|
||||
#+begin_src emacs-lisp :results silent
|
||||
(defun my-ox-latex-export-buffer-local-variables (title-page)
|
||||
(with-eval-after-load 'ox
|
||||
(make-variable-buffer-local 'org-export-before-parsing-hook)
|
||||
(cl-pushnew #'org-latex-header-blocks-filter
|
||||
org-export-before-parsing-hook))
|
||||
(when (require 'ox-latex nil 'noerror)
|
||||
(make-variable-buffer-local 'org-latex-classes)
|
||||
(cl-pushnew '("article-local"
|
||||
"\\documentclass[11pt]{article}
|
||||
(when (require 'ox-latex nil 'noerror)
|
||||
;; https://emacs.stackexchange.com/questions/47347/
|
||||
;; customizing-org-latex-title-command-to-edit-title-page
|
||||
(make-variable-buffer-local 'org-latex-classes)
|
||||
(cl-pushnew '("article-local"
|
||||
"\\documentclass[11pt]{article}
|
||||
[NO-DEFAULT-PACKAGES]
|
||||
[PACKAGES]
|
||||
[EXTRA]"
|
||||
("\\section{%s}" . "\\section*{%s}")
|
||||
("\\subsection{%s}" . "\\subsection*{%s}")
|
||||
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|
||||
("\\paragraph{%s}" . "\\paragraph*{%s}")
|
||||
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
|
||||
org-latex-classes :key #'car :test #'equal)
|
||||
("\\section{%s}" . "\\section*{%s}")
|
||||
("\\subsection{%s}" . "\\subsection*{%s}")
|
||||
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|
||||
("\\paragraph{%s}" . "\\paragraph*{%s}")
|
||||
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
|
||||
org-latex-classes :key #'car :test #'equal)
|
||||
|
||||
(make-variable-buffer-local 'org-latex-title-command)
|
||||
(setq org-latex-title-command (concat title-page))
|
||||
(make-variable-buffer-local 'org-latex-title-command)
|
||||
(setq org-latex-title-command (concat title-page))
|
||||
|
||||
(make-variable-buffer-local 'org-latex-toc-command)
|
||||
(setq org-latex-toc-command
|
||||
(mapconcat 'identity '(""
|
||||
"\\tableofcontents\\label{toc}"
|
||||
"\\listoffigures"
|
||||
"\\listoflistings"
|
||||
"\\listoftables"
|
||||
"\\newpage"
|
||||
"") "\n"))
|
||||
(make-variable-buffer-local 'org-latex-toc-command)
|
||||
(setq org-latex-toc-command
|
||||
(mapconcat 'identity '(""
|
||||
"\\tableofcontents\\label{toc}"
|
||||
"\\listoffigures"
|
||||
"\\listoflistings"
|
||||
"\\listoftables"
|
||||
"\\newpage"
|
||||
"") "\n"))
|
||||
|
||||
(make-variable-buffer-local 'org-latex-subtitle-format)
|
||||
(setq org-latex-subtitle-format "")))
|
||||
#+end_src
|
||||
|
||||
Listing [[lst:emacs-lisp-setup-call]] initializes the buffer local variables
|
||||
=org-export-before-parsing-hook=, =org-latex-classes=,
|
||||
=org-latex-title-command=, =org-latex-toc-command=, and
|
||||
=org-latex-subtitle-format=.
|
||||
|
||||
#+caption[Call =my-ox-latex-export-local-variables=]:
|
||||
#+caption: Use the setup macro for =ox-latex=.
|
||||
#+name: lst:emacs-lisp-setup-call
|
||||
#+header: :var title-page=lst/title-page
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
(my-ox-latex-export-buffer-local-variables title-page)
|
||||
(make-variable-buffer-local 'org-latex-subtitle-format)
|
||||
(setq org-latex-subtitle-format ""))
|
||||
#+end_src
|
||||
|
||||
#+caption[Show a title-page example for =org-latex-title-command=]:
|
||||
|
Loading…
Reference in New Issue
Block a user