Function: org-splice-latex-header

org-splice-latex-header is a byte-compiled function defined in org.el.gz.

Signature

(org-splice-latex-header TPL DEF-PKG PKG SNIPPETS-P &optional EXTRA)

Documentation

Fill a LaTeX header template TPL.

In the template, the following place holders will be recognized:

 [DEFAULT-PACKAGES] \usepackage statements for DEF-PKG
 [NO-DEFAULT-PACKAGES] do not include DEF-PKG
 [PACKAGES] \usepackage statements for PKG
 [NO-PACKAGES] do not include PKG
 [EXTRA] the string EXTRA
 [NO-EXTRA] do not include EXTRA

For backward compatibility, if both the positive and the negative place holder is missing, the positive one (without the "NO-") will be assumed to be present at the end of the template. DEF-PKG and PKG are assumed to be alists of options/packagename lists. EXTRA is a string. SNIPPETS-P indicates if this is run to create snippet images for HTML.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-splice-latex-header (tpl def-pkg pkg snippets-p &optional extra)
  "Fill a LaTeX header template TPL.
In the template, the following place holders will be recognized:

 [DEFAULT-PACKAGES]      \\usepackage statements for DEF-PKG
 [NO-DEFAULT-PACKAGES]   do not include DEF-PKG
 [PACKAGES]              \\usepackage statements for PKG
 [NO-PACKAGES]           do not include PKG
 [EXTRA]                 the string EXTRA
 [NO-EXTRA]              do not include EXTRA

For backward compatibility, if both the positive and the negative place
holder is missing, the positive one (without the \"NO-\") will be
assumed to be present at the end of the template.
DEF-PKG and PKG are assumed to be alists of options/packagename lists.
EXTRA is a string.
SNIPPETS-P indicates if this is run to create snippet images for HTML."
  (let (rpl (end ""))
    (if (string-match "^[ \t]*\\[\\(NO-\\)?DEFAULT-PACKAGES\\][ \t]*\n?" tpl)
	(setq rpl (if (or (match-end 1) (not def-pkg))
		      "" (org-latex-packages-to-string def-pkg snippets-p t))
	      tpl (replace-match rpl t t tpl))
      (when def-pkg (setq end (org-latex-packages-to-string def-pkg snippets-p))))

    (if (string-match "\\[\\(NO-\\)?PACKAGES\\][ \t]*\n?" tpl)
	(setq rpl (if (or (match-end 1) (not pkg))
		      "" (org-latex-packages-to-string pkg snippets-p t))
	      tpl (replace-match rpl t t tpl))
      (when pkg (setq end
		      (concat end "\n"
			      (org-latex-packages-to-string pkg snippets-p)))))

    (if (string-match "\\[\\(NO-\\)?EXTRA\\][ \t]*\n?" tpl)
	(setq rpl (if (or (match-end 1) (not extra))
		      "" (concat extra "\n"))
	      tpl (replace-match rpl t t tpl))
      (when (and extra (string-match "\\S-" extra))
	(setq end (concat end "\n" extra))))

    (if (string-match "\\S-" end)
	(concat tpl "\n" end)
      tpl)))