comparison lisp/org/org-export-latex.el @ 100448:cea079b68b76

2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-refile): Avoid refiling to within the region to be refiled. * org-export-latex.el (org-export-latex-special-chars): Replace special characters also in tables. * org-agenda.el (org-agenda-change-all-lines): New argument FORCE-TAGS. (org-agenda-set-tags): Cet the new tags and pas them to `org-format-agenda-item'. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-export-latex.el (org-export-latex-classes): Add longable as a default package to all classes. (org-export-latex-tables): Handle the longtable attribute and the align attribute. * org-table.el (orgtbl-to-generic): Handle tables that start with a hline. * org-export-latex.el (org-export-latex-emphasis-alist): Switch to \verb for colde-like snippets. (org-export-as-latex): Fix issues with region export. * org.el (org-up-heading-safe): Speed up function by using a direct regexp search. (org-olpa): New variable. (org-get-outline-path): Speed-up path constructions in cases where this is possible because the entire hierarchy is scanned anyway. (org-refile-get-location): Don't compare the truenames of files, this is too slow. (org-goto-max-level): New option. (org-goto): Use `org-goto-max-level'. 2008-12-16 Tassilo Horn <tassilo@member.fsf.org> * org-gnus.el (org-gnus-article-link, org-gnus-article-link): Strip angle brackets from message-ids in the former and don't do it in the latter. (org-gnus-follow-link): Open summary reliable, even if the last messages were deleted, and handle empty groups, too. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-export-latex.el (org-export-latex-emphasis-alist): Use \verb instead of \texttt for the =...= and ~===~ emphasis environments. (org-export-as-latex): Remove any old :org-license-to-kill text properties. (org-export-as-latex): Pass RBEG to `org-export-latex-first-lines'. (org-export-latex-make-header): Add some hard space after the table of contents. (org-export-latex-first-lines): Accept RBEG argument. Mark exported text so that it will be excuded in further steps. * org-table.el (org-table-get-specials): Make @0 reference the last line in a table. (org-table-recalculate): Improve docstring. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-log-done): Fix docstring. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-html-format-image): Fix bugs. * org-export-latex.el (org-export-latex-tables) (org-export-latex-links): Implement attribute, label, and caption handling. * org-exp.el (org-export-html-style-default): Add style definitions for the figure div. (org-export-preprocess-string, org-export-as-html): Implement attribute, label, and caption handling. (org-export-attach-captions-and-attributes): New function. (org-export-html-format-image): New function. (org-format-org-table-html): Implement attribute, label, and caption handling. * org.el (org-find-text-property-in-string): New function. (org-extract-attributes): Use the property org-attr instead of org-attrobutes, because this property is now set with the #+ATTR lines. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-compat.el (org-substring-no-properties): Fix for XEmacs, for the case that FROM is nil. * org.el (org-before-first-heading-p): New function. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-as-html): Do not add a space before enforces line breaks. (org-export-as-html): Close paragraph before blockquote and verse tags. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-id.el (org-id-locations-file): Wrap file name with `convert-standard-filename'. (org-id-files): New variable. (org-id-use-hash): New option. (org-id-update-id-locations): Also search in all files current listed in `org-id-files'. Convert the resulting alist to a hash if the user customation says so. (org-id-locations-save): Handle he case if `org-id-locations' is a hash. (org-id-locations-load): Convert the alist to a hash. (org-id-add-location): Handle the hast case. (kill-emacs-hook): Make sure id locations are saved when Emacs is exited. (org-id-hash-to-alist, org-id-alist-to-hash) (org-id-paste-tracker): New functions.
author Carsten Dominik <dominik@science.uva.nl>
date Tue, 16 Dec 2008 13:28:37 +0000
parents c851df8e004e
children ba23e35d3eaf
comparison
equal deleted inserted replaced
100447:f84c0729a0e9 100448:cea079b68b76
2 ;; 2 ;;
3 ;; Copyright (C) 2007, 2008 Free Software Foundation, Inc. 3 ;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4 ;; 4 ;;
5 ;; Emacs Lisp Archive Entry 5 ;; Emacs Lisp Archive Entry
6 ;; Filename: org-export-latex.el 6 ;; Filename: org-export-latex.el
7 ;; Version: 6.14 7 ;; Version: 6.15a
8 ;; Author: Bastien Guerry <bzg AT altern DOT org> 8 ;; Author: Bastien Guerry <bzg AT altern DOT org>
9 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org> 9 ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
10 ;; Keywords: org, wp, tex 10 ;; Keywords: org, wp, tex
11 ;; Description: Converts an org-mode buffer into LaTeX 11 ;; Description: Converts an org-mode buffer into LaTeX
12 ;; URL: http://www.cognition.ens.fr/~guerry/u/org-export-latex.el 12 ;; URL: http://www.cognition.ens.fr/~guerry/u/org-export-latex.el
89 '(("article" 89 '(("article"
90 "\\documentclass[11pt,a4paper]{article} 90 "\\documentclass[11pt,a4paper]{article}
91 \\usepackage[utf8]{inputenc} 91 \\usepackage[utf8]{inputenc}
92 \\usepackage[T1]{fontenc} 92 \\usepackage[T1]{fontenc}
93 \\usepackage{graphicx} 93 \\usepackage{graphicx}
94 \\usepackage{longtable}
94 \\usepackage{hyperref}" 95 \\usepackage{hyperref}"
95 ("\\section{%s}" . "\\section*{%s}") 96 ("\\section{%s}" . "\\section*{%s}")
96 ("\\subsection{%s}" . "\\subsection*{%s}") 97 ("\\subsection{%s}" . "\\subsection*{%s}")
97 ("\\subsubsection{%s}" . "\\subsubsection*{%s}") 98 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
98 ("\\paragraph{%s}" . "\\paragraph*{%s}") 99 ("\\paragraph{%s}" . "\\paragraph*{%s}")
100 ("report" 101 ("report"
101 "\\documentclass[11pt,a4paper]{report} 102 "\\documentclass[11pt,a4paper]{report}
102 \\usepackage[utf8]{inputenc} 103 \\usepackage[utf8]{inputenc}
103 \\usepackage[T1]{fontenc} 104 \\usepackage[T1]{fontenc}
104 \\usepackage{graphicx} 105 \\usepackage{graphicx}
106 \\usepackage{longtable}
105 \\usepackage{hyperref}" 107 \\usepackage{hyperref}"
106 ("\\part{%s}" . "\\part*{%s}") 108 ("\\part{%s}" . "\\part*{%s}")
107 ("\\chapter{%s}" . "\\chapter*{%s}") 109 ("\\chapter{%s}" . "\\chapter*{%s}")
108 ("\\section{%s}" . "\\section*{%s}") 110 ("\\section{%s}" . "\\section*{%s}")
109 ("\\subsection{%s}" . "\\subsection*{%s}") 111 ("\\subsection{%s}" . "\\subsection*{%s}")
111 ("book" 113 ("book"
112 "\\documentclass[11pt,a4paper]{book} 114 "\\documentclass[11pt,a4paper]{book}
113 \\usepackage[utf8]{inputenc} 115 \\usepackage[utf8]{inputenc}
114 \\usepackage[T1]{fontenc} 116 \\usepackage[T1]{fontenc}
115 \\usepackage{graphicx} 117 \\usepackage{graphicx}
118 \\usepackage{longtable}
116 \\usepackage{hyperref}" 119 \\usepackage{hyperref}"
117 ("\\part{%s}" . "\\part*{%s}") 120 ("\\part{%s}" . "\\part*{%s}")
118 ("\\chapter{%s}" . "\\chapter*{%s}") 121 ("\\chapter{%s}" . "\\chapter*{%s}")
119 ("\\section{%s}" . "\\section*{%s}") 122 ("\\section{%s}" . "\\section*{%s}")
120 ("\\subsection{%s}" . "\\subsection*{%s}") 123 ("\\subsection{%s}" . "\\subsection*{%s}")
161 (defcustom org-export-latex-emphasis-alist 164 (defcustom org-export-latex-emphasis-alist
162 '(("*" "\\textbf{%s}" nil) 165 '(("*" "\\textbf{%s}" nil)
163 ("/" "\\emph{%s}" nil) 166 ("/" "\\emph{%s}" nil)
164 ("_" "\\underline{%s}" nil) 167 ("_" "\\underline{%s}" nil)
165 ("+" "\\texttt{%s}" nil) 168 ("+" "\\texttt{%s}" nil)
166 ("=" "\\texttt{%s}" nil) 169 ("=" "\\verb|%s|" nil)
167 ("~" "\\texttt{%s}" t)) 170 ("~" "\\verb|%s|" t))
168 "Alist of LaTeX expressions to convert emphasis fontifiers. 171 "Alist of LaTeX expressions to convert emphasis fontifiers.
169 Each element of the list is a list of three elements. 172 Each element of the list is a list of three elements.
170 The first element is the character used as a marker for fontification. 173 The first element is the character used as a marker for fontification.
171 The second element is a formatting string to wrap fontified text with. 174 The second element is a formatting string to wrap fontified text with.
172 The third element decides whether to protect converted text from other 175 The third element decides whether to protect converted text from other
355 (with-current-buffer (buffer-base-buffer) 358 (with-current-buffer (buffer-base-buffer)
356 buffer-file-name)) 359 buffer-file-name))
357 (error "Need a file name to be able to export"))) 360 (error "Need a file name to be able to export")))
358 361
359 (message "Exporting to LaTeX...") 362 (message "Exporting to LaTeX...")
363 (remove-text-properties (point-min) (point-max)
364 '(:org-license-to-kill nil))
360 (org-update-radio-target-regexp) 365 (org-update-radio-target-regexp)
361 (org-export-latex-set-initial-vars ext-plist arg) 366 (org-export-latex-set-initial-vars ext-plist arg)
362 (let* ((wcf (current-window-configuration)) 367 (let* ((wcf (current-window-configuration))
363 (opt-plist org-export-latex-options-plist) 368 (opt-plist org-export-latex-options-plist)
364 (region-p (org-region-active-p)) 369 (region-p (org-region-active-p))
402 (t (get-buffer-create to-buffer))) 407 (t (get-buffer-create to-buffer)))
403 (find-file-noselect filename))) 408 (find-file-noselect filename)))
404 (odd org-odd-levels-only) 409 (odd org-odd-levels-only)
405 (header (org-export-latex-make-header title opt-plist)) 410 (header (org-export-latex-make-header title opt-plist))
406 (skip (cond (subtree-p nil) 411 (skip (cond (subtree-p nil)
407 (region-p t) 412 (region-p nil)
408 ;; never skip first lines when exporting a subtree
409 (t (plist-get opt-plist :skip-before-1st-heading)))) 413 (t (plist-get opt-plist :skip-before-1st-heading))))
410 (text (plist-get opt-plist :text)) 414 (text (plist-get opt-plist :text))
411 (first-lines (if skip "" (org-export-latex-first-lines))) 415 (first-lines (if skip "" (org-export-latex-first-lines rbeg)))
412 (coding-system (and (boundp 'buffer-file-coding-system) 416 (coding-system (and (boundp 'buffer-file-coding-system)
413 buffer-file-coding-system)) 417 buffer-file-coding-system))
414 (coding-system-for-write (or org-export-latex-coding-system 418 (coding-system-for-write (or org-export-latex-coding-system
415 coding-system)) 419 coding-system))
416 (save-buffer-coding-system (or org-export-latex-coding-system 420 (save-buffer-coding-system (or org-export-latex-coding-system
418 (region (buffer-substring 422 (region (buffer-substring
419 (if region-p (region-beginning) (point-min)) 423 (if region-p (region-beginning) (point-min))
420 (if region-p (region-end) (point-max)))) 424 (if region-p (region-end) (point-max))))
421 (string-for-export 425 (string-for-export
422 (org-export-preprocess-string 426 (org-export-preprocess-string
423 region :emph-multiline t 427 region
424 :for-LaTeX t 428 :emph-multiline t
425 :comments nil 429 :for-LaTeX t
426 :tags (plist-get opt-plist :tags) 430 :comments nil
427 :priority (plist-get opt-plist :priority) 431 :tags (plist-get opt-plist :tags)
428 :todo-keywords (plist-get opt-plist :todo-keywords) 432 :priority (plist-get opt-plist :priority)
429 :add-text (if (eq to-buffer 'string) nil text) 433 :todo-keywords (plist-get opt-plist :todo-keywords)
430 :skip-before-1st-heading skip 434 :add-text (if (eq to-buffer 'string) nil text)
431 :select-tags (plist-get opt-plist :select-tags) 435 :skip-before-1st-heading skip
432 :exclude-tags (plist-get opt-plist :exclude-tags) 436 :select-tags (plist-get opt-plist :select-tags)
433 :LaTeX-fragments nil))) 437 :exclude-tags (plist-get opt-plist :exclude-tags)
438 :LaTeX-fragments nil)))
434 439
435 (set-buffer buffer) 440 (set-buffer buffer)
436 (erase-buffer) 441 (erase-buffer)
437 442
438 (and (fboundp 'set-buffer-file-coding-system) 443 (and (fboundp 'set-buffer-file-coding-system)
449 "\n\n")) 454 "\n\n"))
450 455
451 ;; insert lines before the first headline 456 ;; insert lines before the first headline
452 (unless (or skip (eq to-buffer 'string)) 457 (unless (or skip (eq to-buffer 'string))
453 (insert first-lines)) 458 (insert first-lines))
454
455 ;; handle the case where the region does not begin with a section
456 (when region-p
457 (insert (with-temp-buffer
458 (insert string-for-export)
459 (org-export-latex-first-lines))))
460 459
461 ;; export the content of headlines 460 ;; export the content of headlines
462 (org-export-latex-global 461 (org-export-latex-global
463 (with-temp-buffer 462 (with-temp-buffer
464 (insert string-for-export) 463 (insert string-for-export)
731 "\n\n" 730 "\n\n"
732 ;; table of contents 731 ;; table of contents
733 (when (and org-export-with-toc 732 (when (and org-export-with-toc
734 (plist-get opt-plist :section-numbers)) 733 (plist-get opt-plist :section-numbers))
735 (cond ((numberp toc) 734 (cond ((numberp toc)
736 (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\n" 735 (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n"
737 (min toc (plist-get opt-plist :headline-levels)))) 736 (min toc (plist-get opt-plist :headline-levels))))
738 (toc (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\n" 737 (toc (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n"
739 (plist-get opt-plist :headline-levels)))))))) 738 (plist-get opt-plist :headline-levels))))))))
740 739
741 (defun org-export-latex-first-lines (&optional comments) 740 (defun org-export-latex-first-lines (&optional beg)
742 "Export the first lines before first headline. 741 "Export the first lines before first headline.
743 COMMENTS is either nil to replace them with the empty string or a 742 If BEG is non-nil, the is the beginning of he region."
744 formatting string like %%%%s if we want to comment them out."
745 (save-excursion 743 (save-excursion
746 (goto-char (point-min)) 744 (goto-char (or beg (point-min)))
747 (if (org-at-heading-p) (beginning-of-line 2)) 745 (if (org-at-heading-p) (beginning-of-line 2))
748 (let* ((pt (point)) 746 (let* ((pt (point))
749 (end (if (and (re-search-forward "^\\* " nil t) 747 (end (if (re-search-forward "^\\*+ " nil t)
750 (not (eq pt (match-beginning 0))))
751 (goto-char (match-beginning 0)) 748 (goto-char (match-beginning 0))
752 (goto-char (point-max))))) 749 (goto-char (point-max)))))
753 (org-export-latex-content 750 (prog1
754 (org-export-preprocess-string 751 (org-export-latex-content
755 (buffer-substring (point-min) end) 752 (org-export-preprocess-string
756 :for-LaTeX t 753 (buffer-substring pt end)
757 :emph-multiline t 754 :for-LaTeX t
758 :add-text nil 755 :emph-multiline t
759 :comments nil 756 :add-text nil
760 :skip-before-1st-heading nil 757 :comments nil
761 :LaTeX-fragments nil))))) 758 :skip-before-1st-heading nil
759 :LaTeX-fragments nil))
760 (add-text-properties pt (max pt (1- end))
761 '(:org-license-to-kill t))))))
762 762
763 (defun org-export-latex-content (content &optional exclude-list) 763 (defun org-export-latex-content (content &optional exclude-list)
764 "Convert CONTENT string to LaTeX. 764 "Convert CONTENT string to LaTeX.
765 Don't perform conversions that are in EXCLUDE-LIST. Recognized 765 Don't perform conversions that are in EXCLUDE-LIST. Recognized
766 conversion types are: quotation-marks, emphasis, sub-superscript, 766 conversion types are: quotation-marks, emphasis, sub-superscript,
853 853
854 (defun org-export-latex-quotation-marks () 854 (defun org-export-latex-quotation-marks ()
855 "Export quotation marks depending on language conventions." 855 "Export quotation marks depending on language conventions."
856 (let* ((lang (plist-get org-export-latex-options-plist :language)) 856 (let* ((lang (plist-get org-export-latex-options-plist :language))
857 (quote-rpl (if (equal lang "fr") 857 (quote-rpl (if (equal lang "fr")
858 '(("\\(\\s-\\)\"" "«~") 858 '(("\\(\\s-\\)\"" "«~")
859 ("\\(\\S-\\)\"" "~»") 859 ("\\(\\S-\\)\"" "~»")
860 ("\\(\\s-\\)'" "`")) 860 ("\\(\\s-\\)'" "`"))
861 '(("\\(\\s-\\)\"" "``") 861 '(("\\(\\s-\\)\"" "``")
862 ("\\(\\S-\\)\"" "''") 862 ("\\(\\S-\\)\"" "''")
863 ("\\(\\s-\\)'" "`"))))) 863 ("\\(\\s-\\)'" "`")))))
864 (mapc (lambda(l) (goto-char (point-min)) 864 (mapc (lambda(l) (goto-char (point-min))
875 (goto-char (point-min)) 875 (goto-char (point-min))
876 (mapc (lambda(c) 876 (mapc (lambda(c)
877 (goto-char (point-min)) 877 (goto-char (point-min))
878 (while (re-search-forward c nil t) 878 (while (re-search-forward c nil t)
879 ;; Put the point where to check for org-protected 879 ;; Put the point where to check for org-protected
880 (unless (or (get-text-property (match-beginning 2) 'org-protected) 880 ; (unless (or (get-text-property (match-beginning 2) 'org-protected);
881 (org-at-table-p)) 881 ; (org-at-table-p))
882 (unless (get-text-property (match-beginning 2) 'org-protected)
882 (cond ((member (match-string 2) '("\\$" "$")) 883 (cond ((member (match-string 2) '("\\$" "$"))
883 (if (equal (match-string 2) "\\$") 884 (if (equal (match-string 2) "\\$")
884 (replace-match (concat (match-string 1) "$" 885 (replace-match (concat (match-string 1) "$"
885 (match-string 3)) t t) 886 (match-string 3)) t t)
886 (replace-match (concat (match-string 1) "\\$" 887 (replace-match (concat (match-string 1) "\\$"
1033 (while (re-search-forward "^\\([ \t]*\\)|" nil t) 1034 (while (re-search-forward "^\\([ \t]*\\)|" nil t)
1034 ;; FIXME really need to save-excursion? 1035 ;; FIXME really need to save-excursion?
1035 (save-excursion (org-table-align)) 1036 (save-excursion (org-table-align))
1036 (let* ((beg (org-table-begin)) 1037 (let* ((beg (org-table-begin))
1037 (end (org-table-end)) 1038 (end (org-table-end))
1038 (raw-table (buffer-substring-no-properties beg end)) 1039 (raw-table (buffer-substring beg end))
1039 fnum fields line lines olines gr colgropen line-fmt align) 1040 fnum fields line lines olines gr colgropen line-fmt align
1041 caption label attr floatp longtblp)
1040 (if org-export-latex-tables-verbatim 1042 (if org-export-latex-tables-verbatim
1041 (let* ((tbl (concat "\\begin{verbatim}\n" raw-table 1043 (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
1042 "\\end{verbatim}\n"))) 1044 "\\end{verbatim}\n")))
1043 (apply 'delete-region (list beg end)) 1045 (apply 'delete-region (list beg end))
1044 (insert (org-export-latex-protect-string tbl))) 1046 (insert (org-export-latex-protect-string tbl)))
1045 (progn 1047 (progn
1048 (setq caption (org-find-text-property-in-string
1049 'org-caption raw-table)
1050 attr (org-find-text-property-in-string
1051 'org-attributes raw-table)
1052 label (org-find-text-property-in-string
1053 'org-label raw-table)
1054 longtblp (and attr (stringp attr)
1055 (string-match "\\<longtable\\>" attr))
1056 align (and attr (stringp attr)
1057 (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr)
1058 (match-string 1 attr))
1059 floatp (or caption label))
1046 (setq lines (split-string raw-table "\n" t)) 1060 (setq lines (split-string raw-table "\n" t))
1047 (apply 'delete-region (list beg end)) 1061 (apply 'delete-region (list beg end))
1048 (when org-export-table-remove-special-lines 1062 (when org-export-table-remove-special-lines
1049 (setq lines (org-table-clean-before-export lines))) 1063 (setq lines (org-table-clean-before-export lines)))
1050 ;; make a formatting string to reflect aligment 1064 ;; make a formatting string to reflect aligment
1074 ;; maybe remove the first and last "|" 1088 ;; maybe remove the first and last "|"
1075 (when (and (not org-export-latex-tables-column-borders) 1089 (when (and (not org-export-latex-tables-column-borders)
1076 (string-match "^\\(|\\)?\\(.+\\)|$" line-fmt)) 1090 (string-match "^\\(|\\)?\\(.+\\)|$" line-fmt))
1077 (setq line-fmt (match-string 2 line-fmt))) 1091 (setq line-fmt (match-string 2 line-fmt)))
1078 ;; format alignment 1092 ;; format alignment
1079 (setq align (apply 'format 1093 (unless align
1080 (cons line-fmt 1094 (setq align (apply 'format
1081 (mapcar (lambda (x) (if x "r" "l")) 1095 (cons line-fmt
1082 org-table-last-alignment)))) 1096 (mapcar (lambda (x) (if x "r" "l"))
1097 org-table-last-alignment)))))
1083 ;; prepare the table to send to orgtbl-to-latex 1098 ;; prepare the table to send to orgtbl-to-latex
1084 (setq lines 1099 (setq lines
1085 (mapcar 1100 (mapcar
1086 (lambda(elem) 1101 (lambda(elem)
1087 (or (and (string-match "[ \t]*|-+" elem) 'hline) 1102 (or (and (string-match "[ \t]*|-+" elem) 'hline)
1088 (split-string (org-trim elem) "|" t))) 1103 (split-string (org-trim elem) "|" t)))
1089 lines)) 1104 lines))
1090 (when insert 1105 (when insert
1091 (insert (org-export-latex-protect-string 1106 (insert (org-export-latex-protect-string
1092 (orgtbl-to-latex 1107 (concat
1093 lines `(:tstart ,(concat "\\begin{tabular}{" align "}")))) 1108 (if longtblp
1109 (concat "\\begin{longtable}{" align "}\n")
1110 (if floatp "\\begin{table}[htb]\n"))
1111 (if (or floatp longtblp)
1112 (format
1113 "\\caption{%s%s}"
1114 (if label (concat "\\\label{" label "}") "")
1115 (or caption "")))
1116 (if longtblp "\\\\\n" "\n")
1117 (if (not longtblp) "\\begin{center}\n")
1118 (if (not longtblp) (concat "\\begin{tabular}{" align "}\n"))
1119 (orgtbl-to-latex
1120 lines
1121 `(:tstart nil :tend nil
1122 :hlend ,(if longtblp
1123 (format "\\\\
1124 \\hline
1125 \\endhead
1126 \\hline\\multicolumn{%d}{r}{Continued on next page}\\
1127 \\endfoot
1128 \\endlastfoot" (length org-table-last-alignment))
1129 nil)))
1130 (if (not longtblp) (concat "\n\\end{tabular}"))
1131 (if longtblp "\n" "\n\\end{center}\n")
1132 (if longtblp
1133 "\\end{longtable}"
1134 (if floatp "\\end{table}"))))
1094 "\n\n"))))))) 1135 "\n\n")))))))
1095 1136
1096 (defun org-export-latex-fontify () 1137 (defun org-export-latex-fontify ()
1097 "Convert fontification to LaTeX." 1138 "Convert fontification to LaTeX."
1098 (goto-char (point-min)) 1139 (goto-char (point-min))
1120 (while (re-search-forward org-bracket-link-analytic-regexp nil t) 1161 (while (re-search-forward org-bracket-link-analytic-regexp nil t)
1121 (org-if-unprotected 1162 (org-if-unprotected
1122 (goto-char (match-beginning 0)) 1163 (goto-char (match-beginning 0))
1123 (let* ((re-radio org-export-latex-all-targets-re) 1164 (let* ((re-radio org-export-latex-all-targets-re)
1124 (remove (list (match-beginning 0) (match-end 0))) 1165 (remove (list (match-beginning 0) (match-end 0)))
1125 (type (match-string 2))
1126 (raw-path (org-extract-attributes (match-string 3))) 1166 (raw-path (org-extract-attributes (match-string 3)))
1127 (full-raw-path (concat (match-string 1) raw-path)) 1167 (full-raw-path (concat (match-string 1) raw-path))
1128 (desc (match-string 5)) 1168 (desc (match-string 5))
1169 (type (or (match-string 2)
1170 (if (or (file-name-absolute-p raw-path)
1171 (string-match "^\\.\\.?/" raw-path))
1172 "file")))
1173 (caption (org-find-text-property-in-string 'org-caption raw-path))
1174 (attr (org-find-text-property-in-string 'org-attributes raw-path))
1175 (label (org-find-text-property-in-string 'org-label raw-path))
1176 (floatp (or label caption))
1129 imgp radiop 1177 imgp radiop
1130 ;; define the path of the link 1178 ;; define the path of the link
1131 (path (cond 1179 (path (cond
1132 ((member type '("http" "https" "ftp")) 1180 ((member type '("http" "https" "ftp"))
1133 (concat type ":" raw-path)) 1181 (concat type ":" raw-path))
1135 (setq radiop t)) 1183 (setq radiop t))
1136 ((equal type "mailto") 1184 ((equal type "mailto")
1137 (concat type ":" raw-path)) 1185 (concat type ":" raw-path))
1138 ((equal type "file") 1186 ((equal type "file")
1139 (if (and (or (org-file-image-p (expand-file-name raw-path)) 1187 (if (and (or (org-file-image-p (expand-file-name raw-path))
1140 (string-match "\\.eps$" raw-path)) 1188 (string-match "\\.\\(pdf\\|jpg\\|ps\\|eps\\)$"
1189 raw-path))
1141 (equal desc full-raw-path)) 1190 (equal desc full-raw-path))
1142 (setq imgp t) 1191 (setq imgp t)
1143 (progn (when (string-match "\\(.+\\)::.+" raw-path) 1192 (progn (when (string-match "\\(.+\\)::.+" raw-path)
1144 (setq raw-path (match-string 1 raw-path))) 1193 (setq raw-path (match-string 1 raw-path)))
1145 (if (file-exists-p raw-path) 1194 (if (file-exists-p raw-path)
1148 :LaTeX org-export-latex-options-plist) 1197 :LaTeX org-export-latex-options-plist)
1149 raw-path)))))))) 1198 raw-path))))))))
1150 ;; process with link inserting 1199 ;; process with link inserting
1151 (apply 'delete-region remove) 1200 (apply 'delete-region remove)
1152 (cond ((and imgp (plist-get org-export-latex-options-plist :inline-images)) 1201 (cond ((and imgp (plist-get org-export-latex-options-plist :inline-images))
1153 (insert (format "\\includegraphics[%s]{%s}" 1202 (insert
1154 ;; image option should be set be a comment line 1203 (concat
1155 org-export-latex-image-default-option 1204 (if floatp "\\begin{figure}[htb]\n")
1156 (expand-file-name raw-path)))) 1205 (format "\\centerline{\\includegraphics[%s]{%s}}\n"
1206 (or attr org-export-latex-image-default-option)
1207 (expand-file-name raw-path))
1208 (if floatp
1209 (format "\\caption{%s%s}\n"
1210 (if label (concat "\\label{" label "}"))
1211 (or caption "")))
1212 (if floatp "\\end{figure}\n"))))
1157 (radiop (insert (format "\\hyperref[%s]{%s}" 1213 (radiop (insert (format "\\hyperref[%s]{%s}"
1158 (org-solidify-link-text raw-path) desc))) 1214 (org-solidify-link-text raw-path) desc)))
1159 ((not type) 1215 ((not type)
1160 (insert (format "\\hyperref[%s]{%s}" 1216 (insert (format "\\hyperref[%s]{%s}"
1161 (org-solidify-link-text raw-path) desc))) 1217 (org-solidify-link-text raw-path) desc)))
1165 (defvar org-latex-entities) ; defined below 1221 (defvar org-latex-entities) ; defined below
1166 (defvar org-latex-entities-regexp) ; defined below 1222 (defvar org-latex-entities-regexp) ; defined below
1167 1223
1168 (defun org-export-latex-preprocess () 1224 (defun org-export-latex-preprocess ()
1169 "Clean stuff in the LaTeX export." 1225 "Clean stuff in the LaTeX export."
1170
1171 ;; Preserve line breaks 1226 ;; Preserve line breaks
1172 (goto-char (point-min)) 1227 (goto-char (point-min))
1173 (while (re-search-forward "\\\\\\\\" nil t) 1228 (while (re-search-forward "\\\\\\\\" nil t)
1174 (add-text-properties (match-beginning 0) (match-end 0) 1229 (add-text-properties (match-beginning 0) (match-end 0)
1175 '(org-protected t))) 1230 '(org-protected t)))