Re: Short captions

2020-02-12 Thread Fraga, Eric
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



Re: Short captions

2020-02-12 Thread Bastien
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



Re: Short captions

2020-02-11 Thread Anthony Cowley


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.el2019-12-03 10:28:06.0 -0500
+++ B/org-element.el2020-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



Re: Short captions

2020-02-11 Thread Fraga, Eric
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



Short captions

2020-02-10 Thread Anthony Cowley
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



[O] Bug in LaTeX export with short captions

2015-09-10 Thread Suvayu Ali
Hi,

When I export the following table to latex,

  #+name: tab:foo
  #+caption[/s/-weights]: /s/-weights.
  | A | B | C |D |
  |---+---+---+--|
  | 70347 | 10885 | 68502 | 4021 |
  | 68458 | 20310 | 66683 | 5853 |
  | 69418 | 22329 | 67617 | 6431 |
  | 71336 | 28674 | 69479 | 8160 |

I get the following:

  \begin{table}[htb]
  \caption[\emph{s}-weights]{\label{tab:foo}
  weights]: \emph{s}-weights.}
  \centering
  \begin{tabular}{}
  A & B & C & D\\
  \hline
  70347 & 10885 & 68502 & 4021\\
  68458 & 20310 & 66683 & 5853\\
  69418 & 22329 & 67617 & 6431\\
  71336 & 28674 & 69479 & 8160\\
  \end{tabular}
  \end{table}

Note the extra "weights]:" in the long caption.  This happens whenever
there is some kind of emphasis in the short caption: /s/, *s*, etc.

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.



Re: [O] Bug in LaTeX export with short captions

2015-09-10 Thread Nicolas Goaziou
Hello,

Suvayu Ali  writes:

> When I export the following table to latex,
>
>   #+name: tab:foo
>   #+caption[/s/-weights]: /s/-weights.
>   | A | B | C |D |
>   |---+---+---+--|
>   | 70347 | 10885 | 68502 | 4021 |
>   | 68458 | 20310 | 66683 | 5853 |
>   | 69418 | 22329 | 67617 | 6431 |
>   | 71336 | 28674 | 69479 | 8160 |
>
> I get the following:
>
>   \begin{table}[htb]
>   \caption[\emph{s}-weights]{\label{tab:foo}
>   weights]: \emph{s}-weights.}
>   \centering
>   \begin{tabular}{}
>   A & B & C & D\\
>   \hline
>   70347 & 10885 & 68502 & 4021\\
>   68458 & 20310 & 66683 & 5853\\
>   69418 & 22329 & 67617 & 6431\\
>   71336 & 28674 & 69479 & 8160\\
>   \end{tabular}
>   \end{table}
>
> Note the extra "weights]:" in the long caption.  This happens whenever
> there is some kind of emphasis in the short caption: /s/, *s*, etc.

Fixed. Thank you.


Regards,

-- 
Nicolas Goaziou