emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* where to place caption so babel results include caption?
@ 2019-11-06  9:55 Ken Mankoff
  2019-11-06 16:05 ` Berry, Charles
  0 siblings, 1 reply; 4+ messages in thread
From: Ken Mankoff @ 2019-11-06  9:55 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

If I have a babel block that generates a table and I'd like latex attributes associated with that table, it seems to work well if I do this:

#+NAME: foo
#+BEGIN_SRC bash :results table
echo "${RANDOM}|${RANDOM}|"
echo "${RANDOM}|${RANDOM}|"
#+END_SRC

#+caption: foo
#+latex_attr: :placement [!h]
#+RESULTS: foo
| 17326 | 29919 |
| 30565 |  9548 |


And I can re-run the babel block and CAPTION and ATTR_LATEX remain.

But if I want to clean with =[C-u] C-c C-v k= or (org-babel-remove-result-one-or-many) and regenerate =C-c C-v C-b= or (org-babel-execute-buffer), then this happens:


#+RESULTS: foo
| 17225 | 29253 |
| 18433 | 27388 |

#+caption: foo
#+latex_attr: :placement [!h]

If I place CAPTION and LATEX_ATTR above the babel block it isn't exported correctly. Is there some way to have this work?

Thanks,

  -k.

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

* Re: where to place caption so babel results include caption?
  2019-11-06  9:55 where to place caption so babel results include caption? Ken Mankoff
@ 2019-11-06 16:05 ` Berry, Charles
  2019-11-06 16:53   ` Ken Mankoff
  0 siblings, 1 reply; 4+ messages in thread
From: Berry, Charles @ 2019-11-06 16:05 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: emacs-orgmode



> On Nov 6, 2019, at 1:55 AM, Ken Mankoff <mankoff@gmail.com> wrote:
> 
> Hello,
> 
> If I have a babel block that generates a table and I'd like latex attributes associated with that table, it seems to work well if I do this:
> 
> #+NAME: foo
> #+BEGIN_SRC bash :results table
> echo "${RANDOM}|${RANDOM}|"
> echo "${RANDOM}|${RANDOM}|"
> #+END_SRC
> 
> #+caption: foo
> #+latex_attr: :placement [!h]
> #+RESULTS: foo
> | 17326 | 29919 |
> | 30565 |  9548 |
> 
> 
> And I can re-run the babel block and CAPTION and ATTR_LATEX remain.
> 
> But if I want to clean with =[C-u] C-c C-v k= or (org-babel-remove-result-one-or-many) and regenerate =C-c C-v C-b= or (org-babel-execute-buffer), then this happens:
> 
> 
> #+RESULTS: foo
> | 17225 | 29253 |
> | 18433 | 27388 |
> 
> #+caption: foo
> #+latex_attr: :placement [!h]
> 
> If I place CAPTION and LATEX_ATTR above the babel block it isn't exported correctly. Is there some way to have this work?
> 


Maybe use something like

M-: (org-babel-map-src-blocks nil (org-babel-insert-result "" '("replace"))) RET

to scrub the existing result values without removing the '#+RESULTS' line.

??

HTH,

Chuck

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

* Re: where to place caption so babel results include caption?
  2019-11-06 16:05 ` Berry, Charles
@ 2019-11-06 16:53   ` Ken Mankoff
  2019-11-09 22:28     ` Ken Mankoff
  0 siblings, 1 reply; 4+ messages in thread
From: Ken Mankoff @ 2019-11-06 16:53 UTC (permalink / raw)
  To: Berry, Charles; +Cc: emacs-orgmode


On 2019-11-06 at 17:05 +01, Berry, Charles <ccberry@ucsd.edu> wrote...
> M-: (org-babel-map-src-blocks nil (org-babel-insert-result ""
> '("replace"))) RET
>
> HTH,

Yes that helps! A simple solution. Thank you.

  -k.

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

* Re: where to place caption so babel results include caption?
  2019-11-06 16:53   ` Ken Mankoff
@ 2019-11-09 22:28     ` Ken Mankoff
  0 siblings, 0 replies; 4+ messages in thread
From: Ken Mankoff @ 2019-11-09 22:28 UTC (permalink / raw)
  To: Berry, Charles; +Cc: emacs-orgmode


On 2019-11-06 at 17:53 +01, Ken Mankoff <mankoff@gmail.com> wrote...
> On 2019-11-06 at 17:05 +01, Berry, Charles <ccberry@ucsd.edu> wrote...
>> M-: (org-babel-map-src-blocks nil (org-babel-insert-result ""
>> '("replace"))) RET

An improvement: Don't insert #+results: if they don't already exist:

(org-babel-map-src-blocks nil
    (if (org-babel-where-is-src-block-result)
        (org-babel-insert-result "" '("replace"))))

  -k.

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

end of thread, other threads:[~2019-11-09 22:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-06  9:55 where to place caption so babel results include caption? Ken Mankoff
2019-11-06 16:05 ` Berry, Charles
2019-11-06 16:53   ` Ken Mankoff
2019-11-09 22:28     ` Ken Mankoff

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).