emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [need help] How to add a caption to table with #+attr_latex :cap


From: Rasmus
Subject: Re: [O] [need help] How to add a caption to table with #+attr_latex :caption \bicaption{...}{...}
Date: Sat, 29 Jun 2013 15:41:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Hi Feng,

> In my thesie, I need add a caption to table or figure with
> \bicaption{中文标题}{English title}

I assume you'd still want to use the #+CAPTION-cookie, no?  If so, one
solution that comes to mind is writing captions like

#+CAPTION:  my-Asian-string (sorry about my ignorance)  MYSPLIT  
my-English-string

and write a filter using (org-split-string text MYSPLIT) and format it
as (format "\bicaption{%s}{%s}" LIST) if the length is two.  

Org perhaps regexps could be used to identify 'my-Asian-string'.

I'm not sure where to apply the filter, though, but a better solution
than the one below would use `org-export-get-caption' on the correct
elements at the correct time. . .

Here's a dirty, inelegant regexp filter that's run on the final
tex-string.

#+begin_src emacs-lisp
(defun org-latex-filter-split-caption (text backend info)
  "When ## is present in a string make a bicaption."
  (when (org-export-derived-backend-p backend 'latex 'beamer)
    (replace-regexp-in-string "\\\\caption{\\(.*?\\)[ \t]*\\\\#\\\\#[ 
\t]+?\\(.*\\)}"
                              "\\\\bicaption{\\1}{\\2}" text)
    ))

  (add-to-list 'org-export-filter-final-output-functions
               'org-latex-filter-split-caption)
#+end_src

It will export this document 'correctly':

#+begin_src org
#+TITLE: my test doc
#+CAPTION: 中文标题 ## english title
| 1 | 2 | 3 |

#+CAPTION: english title
| 2 | 3 |
#+end_src

Hope this inspires you to solve the problem in a more elegant manner.

–Rasmus

-- 
Enough with the bla bla!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]