From mboxrd@z Thu Jan 1 00:00:00 1970 From: feng shu Subject: [need help] How to add a caption to table with #+attr_latex :caption \bicaption{...}{...} Date: Sat, 29 Jun 2013 09:08:29 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d04428f1a21c8bb04e040a2a7 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsjqA-0005ds-Oh for emacs-orgmode@gnu.org; Fri, 28 Jun 2013 21:20:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UsjeQ-0007qI-QM for emacs-orgmode@gnu.org; Fri, 28 Jun 2013 21:08:31 -0400 Received: from mail-we0-x241.google.com ([2a00:1450:400c:c03::241]:48991) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsjeQ-0007q8-Gg for emacs-orgmode@gnu.org; Fri, 28 Jun 2013 21:08:30 -0400 Received: by mail-we0-f193.google.com with SMTP id q58so742578wes.8 for ; Fri, 28 Jun 2013 18:08:29 -0700 (PDT) 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: emacs-orgmode@gnu.org --f46d04428f1a21c8bb04e040a2a7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable HI: In my thesie, I need add a caption to table or figure with \bicaption{=E4=B8=AD=E6=96=87=E6=A0=87=E9=A2=98}{English title} I can't find the easy way to do this in org-mode ,so I add :caption to #+attr_latex: for example: #+attr_latex: :caption \bicaption{...}{....} But the below function doesn't work as expected, someone can help me? thanks! #+begin_src emacs-lisp (defun org-latex--caption/label-string (element info) "Return caption and label LaTeX string for ELEMENT. INFO is a plist holding contextual information. If there's no caption nor label, return the empty string. For non-floats, see `org-latex--wrap-label'." (let* ((label (org-element-property :name element)) (label-str (if (not (org-string-nw-p label)) "" (format "\\label{%s}" (org-export-solidify-link-text label)))) (main (org-export-get-caption element)) (short (org-export-get-caption element t)) (caption-from-latex-attr (plist-get (org-export-read-attribute :attr_latex element) :caption))) (cond ((and (not main) (equal label-str "")) (format "%s" caption-from-latex-attr)) ((not main) (concat label-str "\n" (format "%s" caption-from-latex-attr))) ;; 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)))))) #+end_src --f46d04428f1a21c8bb04e040a2a7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
HI:

In my thesie, I need add a= caption to table or figure with \bicaption{=E4=B8=AD=E6=96=87=E6=A0=87=E9= =A2=98}{English title}

I can't find the easy way to do thi= s in org-mode ,so=C2=A0 I add :caption=C2=A0 to #+attr_latex:
=C2=A0
for example:

#+attr_latex:=C2=A0 :ca= ption \bicaption{...}{....}


But the below function do= esn't work as expected, someone can help me?=C2=A0 thanks!

#+begin_src emacs-lisp
(defun org-latex--caption/label-string (element info)
=C2=A0 "Retur= n caption and label LaTeX string for ELEMENT.

INFO is a plist holdin= g contextual information.=C2=A0 If there's no
caption nor label, ret= urn the empty string.

For non-floats, see `org-latex--wrap-label'."
=C2=A0 (let* = ((label (org-element-property :name element))
=C2=A0=C2=A0=C2=A0 =C2=A0(= label-str (if (not (org-string-nw-p label)) ""
=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (format "\\label= {%s}"
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 (org-export-solidify-link-text label))))
=C2=A0=C2=A0=C2=A0= =C2=A0(main (org-export-get-caption element))
=C2=A0=C2=A0=C2=A0 =C2=A0= (short (org-export-get-caption element t))
=C2=A0=C2=A0=C2=A0 =C2=A0(cap= tion-from-latex-attr (plist-get (org-export-read-attribute :attr_latex elem= ent) :caption)))
=C2=A0=C2=A0=C2=A0 (cond
=C2=A0=C2=A0=C2=A0=C2=A0 ((and (not main) (equa= l label-str "")) (format "%s" caption-from-latex-attr))=
=C2=A0=C2=A0=C2=A0=C2=A0 ((not main) (concat label-str "\n" (= format "%s" caption-from-latex-attr)))
=C2=A0=C2=A0=C2=A0=C2=A0 ;; Option caption format with short name.
=C2= =A0=C2=A0=C2=A0=C2=A0 (short (format "\\caption[%s]{%s%s}\n"
= =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (org-export-data s= hort info)
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 labe= l-str
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (org-expo= rt-data main info)))
=C2=A0=C2=A0=C2=A0=C2=A0 ;; Standard caption format.
=C2=A0=C2=A0=C2=A0= =C2=A0 (t (format "\\caption{%s%s}\n" label-str (org-export-data = main info))))))

#+end_src
--f46d04428f1a21c8bb04e040a2a7--