0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-25 03:32:51 +00:00

Collect packages to a variable

This commit is contained in:
Carsten Dominik 2010-03-30 18:06:55 +02:00
parent cc2d79d5ac
commit a6544ef711
2 changed files with 62 additions and 82 deletions

View file

@ -91,84 +91,28 @@
(defcustom org-export-latex-classes (defcustom org-export-latex-classes
'(("article" '(("article"
"\\documentclass[11pt]{article} "\\documentclass[11pt]{article}"
\\usepackage[AUTO]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{float}
\\usepackage{wrapfig}
\\usepackage{soul}
\\usepackage{t1enc}
\\usepackage{textcomp}
\\usepackage{marvosym}
\\usepackage{wasysym}
\\usepackage{latexsym}
\\usepackage{amssymb}
\\usepackage{hyperref}"
("\\section{%s}" . "\\section*{%s}") ("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")) ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("report" ("report"
"\\documentclass[11pt]{report} "\\documentclass[11pt]{report}"
\\usepackage[AUTO]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{float}
\\usepackage{wrapfig}
\\usepackage{soul}
\\usepackage{t1enc}
\\usepackage{textcomp}
\\usepackage{marvosym}
\\usepackage{wasysym}
\\usepackage{latexsym}
\\usepackage{amssymb}
\\usepackage{hyperref}"
("\\part{%s}" . "\\part*{%s}") ("\\part{%s}" . "\\part*{%s}")
("\\chapter{%s}" . "\\chapter*{%s}") ("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}") ("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")) ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
("book" ("book"
"\\documentclass[11pt]{book} "\\documentclass[11pt]{book}"
\\usepackage[AUTO]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{float}
\\usepackage{wrapfig}
\\usepackage{soul}
\\usepackage{t1enc}
\\usepackage{textcomp}
\\usepackage{marvosym}
\\usepackage{wasysym}
\\usepackage{latexsym}
\\usepackage{amssymb}
\\usepackage{hyperref}"
("\\part{%s}" . "\\part*{%s}") ("\\part{%s}" . "\\part*{%s}")
("\\chapter{%s}" . "\\chapter*{%s}") ("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}") ("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")) ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
("beamer" ("beamer"
"\\documentclass{beamer} "\\documentclass{beamer}"
\\usepackage[AUTO]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{float}
\\usepackage{wrapfig}
\\usepackage{soul}
\\usepackage{t1enc}
\\usepackage{textcomp}
\\usepackage{marvosym}
\\usepackage{wasysym}
\\usepackage{latexsym}
\\usepackage{amssymb}
\\usepackage{hyperref}"
org-beamer-sectioning org-beamer-sectioning
)) ))
"Alist of LaTeX classes and associated header and structure. "Alist of LaTeX classes and associated header and structure.
@ -184,16 +128,17 @@ The header string
----------------- -----------------
The HEADER-STRING is the header that will be inserted into the LaTeX file. The HEADER-STRING is the header that will be inserted into the LaTeX file.
It should contain the \\documentclass macro, package call via \\usepackage It should really only contain the contain the \\documentclass macro.
and anything else you would always like to have in the header. Note that If can also contain package calls via \\usepackage, but it should only
the header will be augmented with additional usepackage statements do so if any packages absolutely must be loaded before the packages given
according to the variable `org-export-latex-packages-alist', and also with in `org-export-latex-default-packages-alist' and
lines specified via \"#+LaTeX_HEADER:\". `org-export-latex-packages-alist'. Lines specified via \"#+LaTeX_HEADER:\"
If the header definition contains \"\\usepackage[AUTO]{inputenc}\", AUTO are also added.
will automatically be replaced with a coding system derived from `org-export-latex-default-packages-alist' contains
`buffer-file-coding-system'. See also the variable \"\\usepackage[AUTO]{inputenc}\", AUTO will automatically be replaced with
`org-export-latex-inputenc-alist' for a way to influence this mechanism. a coding system derived from `buffer-file-coding-system'. See also the
variable `org-export-latex-inputenc-alist' for a way to influence this
mechanism.
The sectioning structure The sectioning structure
------------------------ ------------------------
@ -1172,14 +1117,17 @@ OPT-PLIST is the options plist for current buffer."
(org-export-apply-macros-in-string org-export-latex-header) (org-export-apply-macros-in-string org-export-latex-header)
"\n" "\n"
;; insert information on LaTeX packages ;; insert information on LaTeX packages
(when org-export-latex-packages-alist (when (or org-export-latex-default-packages-alist
org-export-latex-packages-alist)
(concat (concat
(mapconcat (lambda(p) (mapconcat (lambda(p)
(if (equal "" (car p)) (if (equal "" (car p))
(format "\\usepackage{%s}" (cadr p)) (format "\\usepackage{%s}" (cadr p))
(format "\\usepackage[%s]{%s}" (format "\\usepackage[%s]{%s}"
(car p) (cadr p)))) (car p) (cadr p))))
org-export-latex-packages-alist "\n") (append org-export-latex-default-packages-alist
org-export-latex-packages-alist)
"\n")
"\n")) "\n"))
;; insert additional commands in the header ;; insert additional commands in the header
(org-export-apply-macros-in-string (org-export-apply-macros-in-string

View file

@ -2907,10 +2907,8 @@ When nil, just push out a message."
:type 'boolean) :type 'boolean)
(defcustom org-format-latex-header "\\documentclass{article} (defcustom org-format-latex-header "\\documentclass{article}
\\usepackage{amssymb}
\\usepackage[usenames]{color} \\usepackage[usenames]{color}
\\usepackage{amsmath} \\usepackage{amsmath}
\\usepackage{latexsym}
\\usepackage[mathscr]{eucal} \\usepackage[mathscr]{eucal}
\\pagestyle{empty} % do not remove \\pagestyle{empty} % do not remove
% The settings below are copied from fullpage.sty % The settings below are copied from fullpage.sty
@ -2934,16 +2932,45 @@ appears on the page."
(defvar org-format-latex-header-extra nil) (defvar org-format-latex-header-extra nil)
;; The following variable is defined here because is it also used ;; The following variables are defined here because is it also used
;; when formatting latex fragments. Originally it was part of the ;; when formatting latex fragments. Originally it was part of the
;; LaTeX exporter, which is why the name includes "export". ;; LaTeX exporter, which is why the name includes "export".
(defcustom org-export-latex-packages-alist nil (defcustom org-export-latex-default-packages-alist
"Alist of packages to be inserted in the header. '(("AUTO" . "inputenc")
Each cell is of the format \( \"option\" . \"package\" \)." ("T1" . "fontenc")
("" . "graphicx")
("" . "longtable")
("" . "float")
("" . "wrapfig")
("" . "soul")
("" . "t1enc")
("" . "textcomp")
("" . "marvosym")
("" . "wasysym")
("" . "latexsym")
("" . "amssymb")
("" . "hyperref"))
"Alist of default packages to be inserted in the header. DON'T CHANGE THIS.
Unless abslutely necessary that is.
All the packages in this list are needed by one part or another of Org-mode
to function properly. Therefore you should, not modify this variable unless
you know what you are doing. The one reason to change it anyway is that
you might be loading some other package that conflicts with one of the default
packages.
Each cell is of the format \( \"options\" . \"package\" \)."
:group 'org-export-latex :group 'org-export-latex
:type '(repeat :type '(repeat
(list (list
(string :tag "option") (string :tag "options")
(string :tag "package"))))
(defcustom org-export-latex-packages-alist nil
"Alist of packages to be inserted in the header.
Each cell is of the format \( \"options\" . \"package\" \)."
:group 'org-export-latex
:type '(repeat
(list
(string :tag "options")
(string :tag "package")))) (string :tag "package"))))
(defgroup org-appearance nil (defgroup org-appearance nil
@ -15141,6 +15168,7 @@ Some of the options can be changed using the variable
(setq hash (sha1 (prin1-to-string (setq hash (sha1 (prin1-to-string
(list org-format-latex-header (list org-format-latex-header
org-format-latex-header-extra org-format-latex-header-extra
org-export-latex-default-packages-alist
org-export-latex-packages-alist org-export-latex-packages-alist
org-format-latex-options org-format-latex-options
forbuffer txt))) forbuffer txt)))
@ -15213,14 +15241,18 @@ Some of the options can be changed using the variable
(if (eq bg 'default) (setq bg (org-dvipng-color :background))) (if (eq bg 'default) (setq bg (org-dvipng-color :background)))
(with-temp-file texfile (with-temp-file texfile
(insert org-format-latex-header (insert org-format-latex-header
(if org-export-latex-packages-alist (if (or org-export-latex-default-packages-alist
org-export-latex-packages-alist)
(concat "\n" (concat "\n"
(mapconcat (lambda(p) (mapconcat (lambda(p)
(if (equal "" (car p)) (if (equal "" (car p))
(format "\\usepackage{%s}" (cadr p)) (format "\\usepackage{%s}" (cadr p))
(format "\\usepackage[%s]{%s}" (format "\\usepackage[%s]{%s}"
(car p) (cadr p)))) (car p) (cadr p))))
org-export-latex-packages-alist "\n")) (append
org-export-latex-default-packages-alist
org-export-latex-packages-alist)
"\n"))
"") "")
(if org-format-latex-header-extra (if org-format-latex-header-extra
(concat "\n" org-format-latex-header-extra) (concat "\n" org-format-latex-header-extra)