From 5cbb38e25a2d2eae7c3c688d347f80619ecb8463 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Thu, 1 Jul 2010 08:07:17 -0700 Subject: [PATCH] add short-names to #+captions with support for latex export captions specified with the following syntax #+CAPTION: [shortname]{longname} will have their short and longnames handled appropriately. Thanks to Robert Cunningham for suggesting this feature. * lisp/org-exp.el (org-export-attach-captions-and-attributes): adding a shortname attribute to caption strings under the symbol name org-caption-shortn. * lisp/org-latex.el (org-export-latex-tables): handling caption short names on table export (org-export-latex-convert-table.el-table): handling caption short names on table.el type table export (org-export-latex-links): handling caption short names on link/image export (org-export-latex-format-image): now takes an optional argument specifying a caption short name --- lisp/org-exp.el | 6 +++++- lisp/org-latex.el | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index cf09799..80f6e11 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1607,12 +1607,15 @@ table line. If it is a link, add it to the line containing the link." "^[ \t]*\\(|[^-]\\)" "\\|" "^[ \t]*\\[\\[.*\\]\\][ \t]*$")) - cap attr label end) + cap shortn attr label end) (while (re-search-forward re nil t) (cond ((match-end 1) (progn (setq cap (concat cap (if cap " " "") (org-trim (match-string 1)))) + (when (string-match "\\[\\(.*\\)\\]{\\(.*\\)}" cap) + (setq shortn (match-string 1 cap) + cap (match-string 2 cap))) (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max))))) ((match-end 2) (progn @@ -1629,6 +1632,7 @@ table line. If it is a link, add it to the line containing the link." (point-at-eol))) (add-text-properties (point-at-bol) end (list 'org-caption cap + 'org-caption-shortn shortn 'org-attributes attr 'org-label label)) (if label (push (cons label label) target-alist)) diff --git a/lisp/org-latex.el b/lisp/org-latex.el index e800bc1..d725fc8 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -1576,7 +1576,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (org-table-last-column-widths (copy-sequence org-table-last-column-widths)) fnum fields line lines olines gr colgropen line-fmt align - caption label attr floatp longtblp) + caption shortn label attr floatp longtblp) (if org-export-latex-tables-verbatim (let* ((tbl (concat "\\begin{verbatim}\n" raw-table "\\end{verbatim}\n"))) @@ -1585,6 +1585,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (progn (setq caption (org-find-text-property-in-string 'org-caption raw-table) + shortn (org-find-text-property-in-string + 'org-caption-shortn raw-table) attr (org-find-text-property-in-string 'org-attributes raw-table) label (org-find-text-property-in-string @@ -1652,8 +1654,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (if floatp "\\begin{table}[htb]\n")) (if floatp (format - "\\caption{%s%s}" - (if label (concat "\\\label{" label "}") "") + "\\caption%s{%s%s}" + (if shortn (concat "[" shortn "]") "") (or caption ""))) (if (and longtblp caption) "\\\\\n" "\n") (if (and org-export-latex-tables-centered (not longtblp)) @@ -1680,10 +1682,11 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (defun org-export-latex-convert-table.el-table () "Replace table.el table at point with LaTeX code." - (let (tbl caption label line floatp attr align rmlines) + (let (tbl caption shortn label line floatp attr align rmlines) (setq line (buffer-substring (point-at-bol) (point-at-eol)) label (org-get-text-property-any 0 'org-label line) caption (org-get-text-property-any 0 'org-caption line) + shortn (org-get-text-property-any 0 'org-caption-shortn line) attr (org-get-text-property-any 0 'org-attributes line) align (and attr (stringp attr) (string-match "\\