From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] (update) Add :caption attribute to #+ATTR_LATEX property Date: Sun, 30 Jun 2013 13:46:26 +0200 Message-ID: <878v1rstwt.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtG5C-00082d-1r for emacs-orgmode@gnu.org; Sun, 30 Jun 2013 07:46:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtG5A-00064e-HZ for emacs-orgmode@gnu.org; Sun, 30 Jun 2013 07:46:17 -0400 Received: from mail-we0-x236.google.com ([2a00:1450:400c:c03::236]:38732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtG5A-00064O-Ax for emacs-orgmode@gnu.org; Sun, 30 Jun 2013 07:46:16 -0400 Received: by mail-we0-f182.google.com with SMTP id p60so2478339wes.41 for ; Sun, 30 Jun 2013 04:46:14 -0700 (PDT) In-Reply-To: (feng shu's message of "Sun, 30 Jun 2013 07:10:14 +0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: feng shu Cc: emacs-orgmode@gnu.org Hello, feng shu writes: > This is the updated patch of "Add :caption attribute to #+ATTR_LATEX > property" > If possible, please include it to master Thanks for your patch. I agree that #+CAPTION isn't ready for complex caption commands (nor that it should), so a :caption attribute may be useful. Though, it must be documented in the manual (see "12.7.4 LaTeX specific attributes"). In particular, documentation should insist on the fact that: 1. :caption attribute has precedence over #+caption keyword 2. :caption attribute is only meaningful special caption commands, i.e., this isn't the standard way to set a caption in Org. 3. This is a raw command, nothing in it will be interpreted by Org. Here are some comments about the code: > + (caption-from-attr-latex (plist-get (org-export-read-attribute :attr_latex element) :caption))) You can use the following slightly shorter sexp: (caption-from-attr-latex (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))))))) Here you can include the "then" part in the `cond', and use `org-string-nw-p': (cond ((org-string-nw-p caption-from-attr-latex) (concat caption-from-attr-latex "\n")) ((and (not main) (equal label-str "")) "") ...) > (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)) Be careful here: (plist-get attr :caption) will be non-nil if :caption is set to the empty string. It may be bulkier to use: (org-string-nw-p (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)) Ditto. Regards, -- Nicolas Goaziou