Mercurial > emacs
diff lisp/org/org-export-latex.el @ 99139:8fa7ef477c04
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org-agenda.el (org-format-agenda-item)
(org-agenda-filter-make-matcher): Make sure tags are stored and
compared donwcased.
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-insert-todo-heading): Fix bug with force-heading
argument.
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org-exp.el (org-export-as-ascii): Handle the case that we are
bulishing from an indirect buffer.
* org-table.el (org-table-copy-down): Fix bug with time stamp
increment.
* org-mouse.el (org-mouse-features): New option.
(org-mode-hook): Turn on features depending on
`org-mouse-features'.
* org.el (org-insert-heading-respect-content): Force heading
creation.
(org-insert-heading): keep the folding state of the heading before
the inserted one.
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org-archive.el (org-archive-to-archive-sibling): Handle top
level headlines better.
2008-10-26 Bastien Guerry <bzg@altern.org>
* org-export-latex.el (org-export-latex-classes): Added
\usepackage{graphicx} to the default list of packages.
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org-agenda.el (org-agenda-filter): Renamed from
`org-agenda-filter-tags'.
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-entry-properties): Add CATEGORY property, iven if it
is not defined as a property in this entry.
(org-add-log-note): Mask prefix argument when immediately storing
the note.
* org-agenda.el (org-agenda-filter-effort-default-operator): New
option.
2008-10-26 James TD Smith <ahktenzero@mohorovi.cc>
* org.el (org-add-log-setup): Bugfix; code to find insertion point
after drawers was skipping ahead one line too many, so notes were
inserted after the first note instead of before it.
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org-agenda.el (org-agenda-filter-tags,org-agenda-filter-form):
New variables.
(org-prepare-agenda): Reset the filter tags.
(org-agenda-filter-by-tag, org-agenda-filter-by-tag-show-all):
Show filter tags in mode line.
* org-table.el (orgtbl-to-html): Bind `html-table-tag' for the
formatter.
* org-export-latex.el (org-latex-entities-regexp): New constant.
(org-export-as-pdf): Use two calls to `shell-command'.
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org-export-latex.el (org-export-latex-treat-sub-super-char):
Honor the {} value of the subsuperscript setting. Make sure that
longer subsuperscripts are typeset in a roman font.
* org.el (org-clock-update-time-maybe): Compute negative clock
intervals correctly.
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-add-log-setup): Respect
`org-log-state-notes-insert-after-drawers'.
(org-log-state-notes-insert-after-drawers): New option.
(org-todo-trigger-tag-changes): New function.
(org-todo): Call `org-todo-trigger-tag-changes'.
2008-10-26 James TD Smith <ahktenzero@mohorovi.cc>
* org.el (org-add-log-setup): Only skip drawers if the are
immediately after the scheduling keywords.
* org-clock.el (org-clock-in-switch-to-state): Allow this to be a
function
(org-clock-in): If `org-clock-in-switch-to-state' is a function,
call it with the current todo state to get the state to switch to
when clocking in.
(org-clock-in): Use org-indent-line-function to indent clock lines.
(org-clock-find-position): Fix indentation of empty clock drawers.
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org-publish.el (org-publish-org-to): Handle case when
org-export-to-pdf does return a file name, not a buffer.
(org-publish-org-to-pdf): New function.
* org-export-latex.el (org-export-as-pdf)
(org-export-as-pdf-and-open): New commands.
* org-table.el (org-table-eval-formula): Avoid parsing Calc's HMS
forms as ranges.
* org-export-latex.el (org-export-latex-lists): Ignore lists-like
things in protexted regions.
2008-10-26 Carsten Dominik <dominik@science.uva.nl>
* org-export-latex.el (org-export-latex-preprocess): Improve
quoting of LaTeX environments.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Sat, 25 Oct 2008 21:32:46 +0000 |
parents | e1cc41b9282d |
children | e3acb52d33e1 |
line wrap: on
line diff
--- a/lisp/org/org-export-latex.el Sat Oct 25 20:59:38 2008 +0000 +++ b/lisp/org/org-export-latex.el Sat Oct 25 21:32:46 2008 +0000 @@ -4,7 +4,7 @@ ;; ;; Emacs Lisp Archive Entry ;; Filename: org-export-latex.el -;; Version: 6.09a +;; Version: 6.10c ;; Author: Bastien Guerry <bzg AT altern DOT org> ;; Maintainer: Bastien Guerry <bzg AT altern DOT org> ;; Keywords: org, wp, tex @@ -36,6 +36,8 @@ ;; The interactive functions are similar to those of the HTML exporter: ;; ;; M-x `org-export-as-latex' +;; M-x `org-export-as-pdf' +;; M-x `org-export-as-pdf-and-open' ;; M-x `org-export-as-latex-batch' ;; M-x `org-export-as-latex-to-buffer' ;; M-x `org-export-region-as-latex' @@ -88,6 +90,7 @@ "\\documentclass[11pt,a4paper]{article} \\usepackage[utf8]{inputenc} \\usepackage[T1]{fontenc} +\\usepackage{graphicx} \\usepackage{hyperref}" ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") @@ -98,6 +101,7 @@ "\\documentclass[11pt,a4paper]{report} \\usepackage[utf8]{inputenc} \\usepackage[T1]{fontenc} +\\usepackage{graphicx} \\usepackage{hyperref}" ("\\part{%s}" . "\\part*{%s}") ("\\chapter{%s}" . "\\chapter*{%s}") @@ -108,6 +112,7 @@ "\\documentclass[11pt,a4paper]{book} \\usepackage[utf8]{inputenc} \\usepackage[T1]{fontenc} +\\usepackage{graphicx} \\usepackage{hyperref}" ("\\part{%s}" . "\\part*{%s}") ("\\chapter{%s}" . "\\chapter*{%s}") @@ -120,30 +125,38 @@ \(class-name header-string - (unnumbered-section numbered-section\) + (numbered-section . unnumbered-section\) ...\) A %s formatter is mandatory in each section string and will be -replaced by the title of the section." +replaced by the title of the section. + +Instead of a cons cell (numbered . unnumbered), you can also provide a list +of 2-4 elements, + + (numbered-open numbered-close) + +or + + (numbered-open numbered-close unnumbered-open unnumbered-close) + +providing opening and closing strings for an environment that should +represent the document section. The opening clause should have a %s +to represent the section title." :group 'org-export-latex - :type '(repeat + :type '(repeat (list (string :tag "LaTeX class") (string :tag "LaTeX header") - (cons :tag "Level 1" - (string :tag "Numbered") - (string :tag "Unnumbered")) - (cons :tag "Level 2" - (string :tag "Numbered") - (string :tag "Unnumbered")) - (cons :tag "Level 3" - (string :tag "Numbered") - (string :tag "Unnumbered")) - (cons :tag "Level 4" - (string :tag "Numbered") - (string :tag "Unnumbered")) - (cons :tag "Level 5" - (string :tag "Numbered") - (string :tag "Unnumbered"))))) + (repeat :tag "Levels" :inline t + (choice + (cons :tag "Heading" + (string :tag "numbered") + (string :tag "unnumbered)")) + (list :tag "Environment" + (string :tag "Opening (numbered) ") + (string :tag "Closing (numbered) ") + (string :tag "Opening (unnumbered)") + (string :tag "Closing (unnumbered)"))))))) (defcustom org-export-latex-emphasis-alist '(("*" "\\textbf{%s}" nil) @@ -224,6 +237,18 @@ :group 'org-export-latex :type 'coding-system) +(defgroup org-export-pdf nil + "Options for exporting Org-mode files to PDF, via LaTeX." + :tag "Org Export LaTeX" + :group 'org-export-latex + :group 'org-export) + +(defcustom org-export-pdf-remove-logfiles t + "Non-nil means, remove the logfiles produced by PDF production. +These are the .aux, .log, .out, and .toc files." + :group 'org-export-latex + :type 'boolean) + ;;; Autoload functions: ;;;###autoload @@ -454,6 +479,44 @@ (current-buffer)) (set-window-configuration wcf)))) +;;;###autoload +(defun org-export-as-pdf (arg &optional hidden ext-plist + to-buffer body-only pub-dir) + "Export as LaTeX, then process through to PDF." + (interactive "P") + (message "Exporting to PDF...") + (let* ((wconfig (current-window-configuration)) + (lbuf (org-export-as-latex arg hidden ext-plist + to-buffer body-only pub-dir)) + (file (buffer-file-name lbuf)) + (base (file-name-sans-extension (buffer-file-name lbuf))) + (pdffile (concat base ".pdf"))) + (and (file-exists-p pdffile) (delete-file pdffile)) + (message "Processing LaTeX file...") + (shell-command (format "pdflatex -interaction nonstopmode %s" + (shell-quote-argument file))) + (shell-command (format "pdflatex -interaction nonstopmode %s" + (shell-quote-argument file))) + (message "Processing LaTeX file...done") + (if (not (file-exists-p pdffile)) + (error "PDF file was not produced") + (set-window-configuration wconfig) + (when org-export-pdf-remove-logfiles + (dolist (ext '("aux" "log" "out" "toc")) + (setq file (concat base "." ext)) + (and (file-exists-p file) (delete-file file)))) + (message "Exporting to PDF...done") + pdffile))) + +;;;###autoload +(defun org-export-as-pdf-and-open (arg) + "Export as LaTeX, then process through to PDF, and open." + (interactive "P") + (let ((pdffile (org-export-as-pdf arg))) + (if pdffile + (org-open-file pdffile) + (error "PDF file was not produced")))) + ;;; Parsing functions: (defun org-export-latex-parse-global (level odd) @@ -554,12 +617,18 @@ (cond ;; Normal conversion ((<= level org-export-latex-sectioning-depth) - (let ((sec (nth (1- level) org-export-latex-sectioning))) - (insert (format (if num (car sec) (cdr sec)) heading) "\n")) - (when label (insert (format "\\label{%s}\n" label))) - (insert (org-export-latex-content content)) - (cond ((stringp subcontent) (insert subcontent)) - ((listp subcontent) (org-export-latex-sub subcontent)))) + (let* ((sec (nth (1- level) org-export-latex-sectioning)) + start end) + (if (consp (cdr sec)) + (setq start (nth (if num 0 2) sec) + end (nth (if num 1 3) sec)) + (setq start (if num (car sec) (cdr sec)))) + (insert (format start heading) "\n") + (when label (insert (format "\\label{%s}\n" label))) + (insert (org-export-latex-content content)) + (cond ((stringp subcontent) (insert subcontent)) + ((listp subcontent) (org-export-latex-sub subcontent))) + (if end (insert end "\n")))) ;; At a level under the hl option: we can drop this subsection ((> level org-export-latex-sectioning-depth) (cond ((eq org-export-latex-low-levels 'description) @@ -877,12 +946,15 @@ ((string-match "[({]?\\([^)}]+\\)[)}]?" string-after) (format "%s%s{%s}" string-before char (match-string 1 string-after)))))) - ((and subsup - (> (length string-after) 1) + ((and (> (length string-after) 1) + (or (eq subsup t) + (and (equal subsup '{}) (eq (string-to-char string-after) ?\{))) (string-match "[({]?\\([^)}]+\\)[)}]?" string-after)) - (format "$%s%s{%s}$" string-before char - (match-string 1 string-after))) - (subsup (concat "$" string-before char string-after "$")) + (format "%s$%s{%s}$" string-before char + (if (> (match-end 1) (1+ (match-beginning 1))) + (concat "\\mathrm{" (match-string 1 string-after) "}") + (match-string 1 string-after)))) + ((eq subsup t) (concat string-before "$" char string-after "$")) (t (org-export-latex-protect-string (concat string-before "\\" char "{}" string-after))))) (t (org-export-latex-protect-string @@ -1084,6 +1156,7 @@ (t (insert "\\texttt{" desc "}"))))))) (defvar org-latex-entities) ; defined below +(defvar org-latex-entities-regexp) ; defined below (defun org-export-latex-preprocess () "Clean stuff in the LaTeX export." @@ -1096,11 +1169,12 @@ ;; Preserve latex environments (goto-char (point-min)) - (while (search-forward "\\begin{" nil t) - (let ((start (progn (beginning-of-line) (point))) - (end (or (and (search-forward "\\end{" nil t) - (end-of-line) (point)) - (point-max)))) + (while (re-search-forward "^[ \t]*\\begin{\\([a-zA-Z]+\\)}" nil t) + (let* ((start (progn (beginning-of-line) (point))) + (end (or (and (re-search-forward + (concat "^[ \t]*\\end{" (match-string 1) "}" nil t) + (point-at-eol))) + (point-max)))) (add-text-properties start end '(org-protected t)))) ;; Convert LaTeX to \LaTeX{} @@ -1139,7 +1213,7 @@ ;; Protect LaTeX entities (goto-char (point-min)) - (while (re-search-forward (regexp-opt org-latex-entities) nil t) + (while (re-search-forward org-latex-entities-regexp nil t) (add-text-properties (match-beginning 0) (match-end 0) '(org-protected t))) @@ -1204,8 +1278,9 @@ "Convert lists to LaTeX." (goto-char (point-min)) (while (re-search-forward org-list-beginning-re nil t) - (beginning-of-line) - (insert (org-list-to-latex (org-list-parse-list t)) "\n"))) + (org-if-unprotected + (beginning-of-line) + (insert (org-list-to-latex (org-list-parse-list t)) "\n")))) (defconst org-latex-entities '("\\!" @@ -1383,6 +1458,15 @@ "\\vspace") "A list of LaTeX commands to be protected when performing conversion.") +(defconst org-latex-entities-regexp + (let (names rest) + (dolist (x org-latex-entities) + (if (string-match "[a-z][A-Z]$" x) + (push x names) + (push x rest))) + (concat "\\(" (regexp-opt (nreverse names)) "\\>\\)" + "\\|\\(" (regexp-opt (nreverse rest)) "\\)"))) + (provide 'org-export-latex) ;; arch-tag: 23c2b87d-da04-4c2d-ad2d-1eb6487bc3ad