Pedro Andres Aranda Gutierrez <[email protected]> writes:

> Longer answer at home.
>
> IMHO, even when we are using the low-level #+ATTR_LATEX: :caption, I would 
> expect at least the 
> \caption{…} to be generated. 
>
> Other structures and parts of the #+ATTR_LATEX behave like that: 
> i.e. they put parameters inside LaTeX constructs (and be they as frugal as 
> […].
> So I would expect this #+ATTR_LATEX: :caption to ‘do something more’ that 
> just dropping the text there.
>
> WDYT?

There is handling of :caption in #+attr_latex inside ox-latex:

(defun org-latex--caption/label-string (element info)
  "Return caption and label LaTeX string for ELEMENT.
...
  (let* ((label (org-latex--label element info nil t))
          ...
         (caption-from-attr-latex (plist-get attr :caption)))
    (cond
     ((org-string-nw-p caption-from-attr-latex)
      (concat caption-from-attr-latex "\n"))

As you can see, the expectation is that :caption will have fully
formatted custom caption definition, be it \captionof, \caption, or
something else.

The commit that added this feature is very explicit:

7767f8eae1328530f624b04e625a4643dbe5d9b5
Author:     Feng Shu <[email protected]>
AuthorDate: Sat Jun 29 23:04:03 2013 +0800
Commit:     Nicolas Goaziou <[email protected]>
CommitDate: Tue Jul 2 19:01:15 2013 +0200

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,org-latex--org-table): Tiny change.
* doc/org.texi (@LaTeX{} specific attributes): Document `:caption'
attribute of #+ATTR_LATEX.

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 |
|---+---|

There is also manual entry:

‘:caption’
     Use ‘CAPTION’ keyword to set a simple caption for a table (see
     *note Captions::).  For custom captions, use ‘:caption’ attribute,
     which accepts raw LaTeX code.  ‘:caption’ value overrides ‘CAPTION’
     value.

Admittedly, it may explain a bit more about what "raw LaTeX code" refers to.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to