emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Trying to use :post header argument to set #+ATTR_LATEX: line


From: L.C. Karssen
Subject: [O] Trying to use :post header argument to set #+ATTR_LATEX: line
Date: Mon, 22 Oct 2018 16:43:45 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

Dear list,

I'd like to create several tables from R and export those to a LaTeX
document. Because only input variable differs for the R code that
generates the tables, I thought I could use the :post header argument to
add the #+ATTR_LATEX: line I need to each of the outputs of my R source
code blocks.

I tried to follow the Org manual (section 14.8.2.27), but that doesn't
seem to work. My R results blocks all get colons in front of the output
and if I set :results drawer, I get the following error:

  org-babel-R-evaluate-session: Wrong type argument: listp,

followed by a double quoted string containing the data, excluding the
#+ATTR_LATEX line.


I have attached an example Org file that illustrates what I am trying to
achieve and where it goes wrong. I tested this using Emacs 26.1 of
2018-05-29 and Org 9.1.13 from elpa (2018-06-25).

In short, I'm trying the following:


#+name: attr_wrap
#+begin_src R :var data="" :results output
  cat("#+ATTR_LATEX: :environment tabularx  :width \\textwidth :align
Xrrr", "\n")
  data
#+end_src

#+name: create_table2
  #+begin_src R :rownames yes :colnames yes :var brand="Mazda" :post
attr_wrap(data=*this*)
  mtcars[grepl(brand, rownames(mtcars)), c("mpg", "cyl", "disp")]
#+end_src

And call it:
#+call: create_table2(brand="Toyota")

#+RESULTS:
: #+ATTR_LATEX: :environment tabularx  :width \textwidth :align Xrrr
:                X  mpg cyl  disp
: 1 Toyota Corolla 33.9   4  71.1
: 2  Toyota Corona 21.5   4 120.1

Note that the whole results block is preceded by a colon, instead
of the table being formatted by Org.


Thanks for any help!

Best regards,

Lennart.

-- 
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
L.C. Karssen
's-Hertogenbosch
The Netherlands

address@hidden
http://blog.karssen.org
GPG key ID: A88F554A
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

Attachment: org-source-block-post.org
Description: Text document

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]