From: Feng Shu <tumashu@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [need help] How to add a caption to table with #+attr_latex :caption \bicaption{...}{...}
Date: Sun, 30 Jun 2013 07:32:06 +0800 [thread overview]
Message-ID: <87mwq88pe1.fsf@gmail.com> (raw)
In-Reply-To: 874nchnif0.fsf@pank.eu
Rasmus <rasmus@gmx.us> writes:
> 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. . .
---------------------------
#+caption: ä¸ææ é¢
#+caption: English Title
| 1 | 2 |
---------------------------
I think this is the best document construct, simple and intuitive.
But, realizing this feature need some dirty hack, the main reason is
that \bicaption often a custom latex command, fig caption and table
caption are different in option, for example:
\bicaption[å¾]{...}[fig]{...}
\bicaption{å¾}{fig}{...}{...}
\bicaption{...}{...}
\bicaption[表]{...}[Table]{}
...
>
> 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 is a very useful tip, thanks!
>
> It will export this document 'correctly':
> #+begin_src org
> #+TITLE: my test doc
> #+CAPTION: -\a ## 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
--
prev parent reply other threads:[~2013-06-30 2:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-29 1:08 [need help] How to add a caption to table with #+attr_latex :caption \bicaption{...}{...} feng shu
2013-06-29 13:41 ` Rasmus
2013-06-29 23:32 ` Feng Shu [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mwq88pe1.fsf@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.