emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: feng shu <tumashu@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property
Date: Sun, 30 Jun 2013 07:10:14 +0800	[thread overview]
Message-ID: <CAJpRBmcSnspGJ5FyMBo32ApiGuePGATufUJCLAZLt0-pBftg2g@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 575 bytes --]

This is the updated patch of  "Add :caption attribute to #+ATTR_LATEX
property"
If possible, please include it to master

------------------------------------------------------------------------------------------------------------------------

This feature is very useful when you export org to latex with custom
caption command, for example:

#+ATTR_LATEX: :caption \BiTableCaption{caption 1}{caption 2}
|---+---|
| x | y |
|---+---|
| 1 | 2 |
|---+---|

----------------------------------------------------------------------------------------------------------------------

[-- Attachment #1.2: Type: text/html, Size: 696 bytes --]

[-- Attachment #2: 0001-Add-caption-attribute-to-ATTR_LATEX-property.patch --]
[-- Type: application/octet-stream, Size: 3238 bytes --]

From eb8b665ba1e2717c40b86048f3edb3495b9c628e Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@gmail.com>
Date: Sat, 29 Jun 2013 23:04:03 +0800
Subject: [PATCH] Add `:caption' attribute to #+ATTR_LATEX property

* lisp/ox-latex.el (org-latex--caption/label-string): Add ability,
  which can build a caption string from `:caption' attribute of #+ATTR_LATEX.
(org-latex--inline-image): Tiny change.
(org-latex--org-table): Tiny change.

This feature is very useful when you export org to latex with custom
caption command, for example:

\#+ATTR_LATEX: :caption \BiTableCaption{caption 1}{caption 2}
|---+---|
| x | y |
|---+---|
| 1 | 2 |
|---+---|
---
 lisp/ox-latex.el |   29 ++++++++++++++++-------------
 1 个文件被修改,插入 16 行(+),删除 13 行(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 09928a4..36c2565 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -881,17 +881,20 @@ For non-floats, see `org-latex--wrap-label'."
 		      (format "\\label{%s}"
 			      (org-export-solidify-link-text label))))
 	 (main (org-export-get-caption element))
-	 (short (org-export-get-caption element t)))
-    (cond
-     ((and (not main) (equal label-str "")) "")
-     ((not main) (concat label-str "\n"))
-     ;; Option caption format with short name.
-     (short (format "\\caption[%s]{%s%s}\n"
-		    (org-export-data short info)
-		    label-str
-		    (org-export-data main info)))
-     ;; Standard caption format.
-     (t (format "\\caption{%s%s}\n" label-str (org-export-data main info))))))
+	 (short (org-export-get-caption element t))
+	 (caption-from-attr-latex (plist-get (org-export-read-attribute :attr_latex element) :caption)))
+    (if (and caption-from-attr-latex (not (equal caption-from-attr-latex "")))
+	(concat caption-from-attr-latex "\n")
+      (cond
+       ((and (not main) (equal label-str "")))
+       ((not main) (concat label-str "\n"))
+       ;; Option caption format with short name.
+       (short (format "\\caption[%s]{%s%s}\n"
+		      (org-export-data short info)
+		      label-str
+		      (org-export-data main info)))
+       ;; Standard caption format.
+       (t (format "\\caption{%s%s}\n" label-str (org-export-data main info)))))))
 
 (defun org-latex-guess-inputenc (header)
   "Set the coding system in inputenc to what the buffer is.
@@ -1655,7 +1658,7 @@ used as a communication channel."
 		  (cond ((and (not float) (plist-member attr :float)) nil)
 			((string= float "wrap") 'wrap)
 			((string= float "multicolumn") 'multicolumn)
-			((or float (org-element-property :caption parent))
+			((or float (org-element-property :caption parent) (plist-get attr :caption))
 			 'figure))))
 	 (placement
 	  (let ((place (plist-get attr :placement)))
@@ -2333,7 +2336,7 @@ This function assumes TABLE has `org' as its `:type' property and
 			 ((and (not float) (plist-member attr :float)) nil)
 			 ((string= float "sidewaystable") "sidewaystable")
 			 ((string= float "multicolumn") "table*")
-			 ((or float (org-element-property :caption table))
+			 ((or float (org-element-property :caption table) (plist-get attr :caption))
 			  "table")))))
 	 ;; Extract others display options.
 	 (fontsize (let ((font (plist-get attr :font)))
-- 
1.7.10.4


             reply	other threads:[~2013-06-29 23:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-29 23:10 feng shu [this message]
2013-06-30 11:46 ` [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property Nicolas Goaziou
2013-06-30 14:27   ` feng shu
2013-06-30 20:27     ` Bastien
2013-06-30 23:08       ` feng shu
2013-07-01 13:10         ` Bastien
2013-07-01 21:38         ` Nicolas Goaziou
2013-07-01 23:58           ` feng shu
2013-07-02 17:03             ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJpRBmcSnspGJ5FyMBo32ApiGuePGATufUJCLAZLt0-pBftg2g@mail.gmail.com \
    --to=tumashu@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).