emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Short captions
@ 2020-02-11  4:20 Anthony Cowley
  2020-02-11 13:14 ` Fraga, Eric
  0 siblings, 1 reply; 5+ messages in thread
From: Anthony Cowley @ 2020-02-11  4:20 UTC (permalink / raw)
  To: Emacs Org-Mode Help

I am having trouble understanding how short captions are supposed to work. Consider this org document:

#+begin_src org
,#+title: Short Caption Test
,#+author: Org User

,#+label: table1
,#+caption[This is table1]: And here go on at length in a longer caption.
| Name | Favorite Number |
|------+-----------------|
| Sue  | 42              |
| Tom  | 99              |

,#+label: table2
,#+caption[This is table2]: But *with* /this/ table, the /short/ caption is *lost*.
| Name  | Favorite Color |
|-------+----------------|
| Alice | Red            |
| Bob   | Also Red       |

,#+label: table3
,#+caption[This is table3]: No org markup is used in this long caption, but some $\LaTeX$ is!
| Number | Favorite Person |
|--------+-----------------|
| 0      | Zed             |
| 1      | Solo            |
#+end_src

When I export it as a LaTeX file, the captions are:

#+begin_src latex
\caption[This is table1]{\label{table1}And here go on at length in a longer caption.}
#+end_src

#+begin_src latex
\caption[\textbf{lost}]{\label{table2}But \textbf{with} \emph{this} table, the \emph{short} caption is \textbf{lost}.}
#+end_src

and

#+begin_src latex
\caption{\label{table3}No org markup is used in this long caption, but some \(\LaTeX\) is!}
#+end_src

The first matches my expectations. The second is an example of taking the last bit of markup as the short caption. The third seems to lose the short caption altogether.

When I look at 

#+begin_src emacs-lisp
(org-element-map 
    (org-element-parse-buffer) 
    'table 
  (lambda (x) (org-element-property :caption x)))
#+end_src

Only the first caption seems to have the short caption in the parse results at all. Is this a bug, or should I avoid using markup in captions?

Thank you,
Anthony

#+begin_src emacs-lisp
(org-version)
#+end_src

#+RESULTS:
: 9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Short captions
  2020-02-11  4:20 Short captions Anthony Cowley
@ 2020-02-11 13:14 ` Fraga, Eric
  2020-02-11 19:50   ` Anthony Cowley
  0 siblings, 1 reply; 5+ messages in thread
From: Fraga, Eric @ 2020-02-11 13:14 UTC (permalink / raw)
  To: Anthony Cowley; +Cc: Emacs Org-Mode Help

On Monday, 10 Feb 2020 at 23:20, Anthony Cowley wrote:
> I am having trouble understanding how short captions are supposed to
> work. Consider this org document:

[...]

> The first matches my expectations. The second is an example of taking
> the last bit of markup as the short caption. The third seems to lose
> the short caption altogether.

I can confirm (with a slightly out of date org) this behaviour which
does seem to be inconsistent and/or wrong.  However, I wasn't able to
find any discussion of short captions in the org manual so I'm not sure
if there are caveats on their use.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.2-199-ga557cf

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Short captions
  2020-02-11 13:14 ` Fraga, Eric
@ 2020-02-11 19:50   ` Anthony Cowley
  2020-02-12  8:17     ` Bastien
  2020-02-12 10:13     ` Fraga, Eric
  0 siblings, 2 replies; 5+ messages in thread
From: Anthony Cowley @ 2020-02-11 19:50 UTC (permalink / raw)
  To: Fraga, Eric; +Cc: Emacs Org-Mode Help


Fraga, Eric writes:

> On Monday, 10 Feb 2020 at 23:20, Anthony Cowley wrote:
>> I am having trouble understanding how short captions are supposed to
>> work. Consider this org document:
>
> [...]
>
>> The first matches my expectations. The second is an example of taking
>> the last bit of markup as the short caption. The third seems to lose
>> the short caption altogether.
>
> I can confirm (with a slightly out of date org) this behaviour which
> does seem to be inconsistent and/or wrong.  However, I wasn't able to
> find any discussion of short captions in the org manual so I'm not sure
> if there are caveats on their use.

They are described in section 12.8 Captions <https://orgmode.org/manual/Captions.html#Captions>

I think this patch fixes the issue:

diff -ruN A/org-element.el B/org-element.el
--- A/org-element.el	2019-12-03 10:28:06.000000000 -0500
+++ B/org-element.el	2020-02-11 14:47:45.564452900 -0500
@@ -4018,14 +4018,15 @@
 	       (parsed? (member kwd org-element-parsed-keywords))
 	       ;; Find main value for any keyword.
 	       (value
-		(let ((beg (match-end 0))
-		      (end (save-excursion
-			     (end-of-line)
-			     (skip-chars-backward " \t")
-			     (point))))
-		  (if parsed?
-		      (org-element--parse-objects beg end nil restrict)
-		    (org-trim (buffer-substring-no-properties beg end)))))
+                (save-match-data 
+		  (let ((beg (match-end 0))
+		        (end (save-excursion
+			       (end-of-line)
+			       (skip-chars-backward " \t")
+			       (point))))
+		    (if parsed?
+		        (org-element--parse-objects beg end nil restrict)
+		      (org-trim (buffer-substring-no-properties beg end))))))
 	       ;; If KWD is a dual keyword, find its secondary value.
 	       ;; Maybe parse it.
 	       (dual? (member kwd org-element-dual-keywords))


Anthony

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Short captions
  2020-02-11 19:50   ` Anthony Cowley
@ 2020-02-12  8:17     ` Bastien
  2020-02-12 10:13     ` Fraga, Eric
  1 sibling, 0 replies; 5+ messages in thread
From: Bastien @ 2020-02-12  8:17 UTC (permalink / raw)
  To: Anthony Cowley; +Cc: Emacs Org-Mode Help, Fraga, Eric

Hi Anthony,

I applied a slightly different fix (just moving save-match-data down
the s-expression).  Thanks for reporting this and for the fix!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Short captions
  2020-02-11 19:50   ` Anthony Cowley
  2020-02-12  8:17     ` Bastien
@ 2020-02-12 10:13     ` Fraga, Eric
  1 sibling, 0 replies; 5+ messages in thread
From: Fraga, Eric @ 2020-02-12 10:13 UTC (permalink / raw)
  To: Anthony Cowley; +Cc: Emacs Org-Mode Help

On Tuesday, 11 Feb 2020 at 14:50, Anthony Cowley wrote:
> They are described in section 12.8 Captions

Thanks.  Missed that.  I was looking in the LaTeX export section of the
manual which doesn't mention short captions!  And, actually, the
:caption option for tables, say, doesn't seem to support such?

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.2-199-ga557cf

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-12 10:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-11  4:20 Short captions Anthony Cowley
2020-02-11 13:14 ` Fraga, Eric
2020-02-11 19:50   ` Anthony Cowley
2020-02-12  8:17     ` Bastien
2020-02-12 10:13     ` Fraga, Eric

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).