emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* babel output as LaTeX code: help please!
@ 2015-03-10 17:25 Eric S Fraga
  2015-03-10 18:42 ` Thomas S. Dye
  0 siblings, 1 reply; 4+ messages in thread
From: Eric S Fraga @ 2015-03-10 17:25 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I am using babel with awk to generate some LaTeX code that I would like
exported and interpreted as LaTeX.  I have the following which works if
I were to use the src block directly but I wish to /call/ the src block
with different tables:

#+begin_src org
  ,* layout
  ,#+caption: Position of each circle
  ,#+tblname: solution
  |   | \(R_i\) |   \(r_i\) | \(\theta_i\) |  \(x\) |  \(y\) |
  |---+---------+-----------+--------------+--------+--------|
  | 1 |       6 | 19.834868 |     5.358859 |  11.95 | -15.83 |
  | 2 |       7 | 21.443075 |     0.101102 |  21.33 |   2.16 |
  | 3 |       8 | 19.005610 |     1.547045 |   0.45 |  19.00 |
  | 4 |       9 | 20.688749 |     3.604317 | -18.51 |  -9.24 |
  | 5 |      11 |  0.046762 |     3.863237 |  -0.04 |  -0.03 |
  ,#+TBLFM: $5=$3*cos($4);R%.2f::$6=$3*sin($4);R%.2f

  ,#+call: drawlayout[:stdin solution]()

  ,#+name: drawlayout
  ,#+header: :results raw
  ,#+begin_src awk
    BEGIN {
        print "#+begin_latex"
        print "\\begin{tikzpicture}[scale=0.1]"
        print "\\draw"
    }
    /^[0-9]/ {
        printf("(%f,%f) circle (%f) node {%d}\n", $5, $6, $2, $1);
    }
    END {
        print ";"
        print "\\end{tikzpicture}"
        print "#+end_latex"
    }
  ,#+end_src
#+end_src

I cannot figure out the magic incantation of [inside header arguments]
and [end header arguments] that will export the output of the awk block
when called as raw LaTeX code.

If I put ":results raw" and ":exports results" on the src block,
exporting that block works just fine.  The call however is wrapped in an
EXAMPLE block which does me no good!

Any suggestions welcome!

Thanks,
eric
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.1, Org release_8.3beta-843-ga5f1a3.dirty

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

* Re: babel output as LaTeX code: help please!
  2015-03-10 17:25 babel output as LaTeX code: help please! Eric S Fraga
@ 2015-03-10 18:42 ` Thomas S. Dye
  2015-03-10 19:14   ` Eric S Fraga
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas S. Dye @ 2015-03-10 18:42 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Hi,
>
> I am using babel with awk to generate some LaTeX code that I would like
> exported and interpreted as LaTeX.  I have the following which works if
> I were to use the src block directly but I wish to /call/ the src block
> with different tables:
>
> #+begin_src org
>   ,* layout
>   ,#+caption: Position of each circle
>   ,#+tblname: solution
>   |   | \(R_i\) |   \(r_i\) | \(\theta_i\) |  \(x\) |  \(y\) |
>   |---+---------+-----------+--------------+--------+--------|
>   | 1 |       6 | 19.834868 |     5.358859 |  11.95 | -15.83 |
>   | 2 |       7 | 21.443075 |     0.101102 |  21.33 |   2.16 |
>   | 3 |       8 | 19.005610 |     1.547045 |   0.45 |  19.00 |
>   | 4 |       9 | 20.688749 |     3.604317 | -18.51 |  -9.24 |
>   | 5 |      11 |  0.046762 |     3.863237 |  -0.04 |  -0.03 |
>   ,#+TBLFM: $5=$3*cos($4);R%.2f::$6=$3*sin($4);R%.2f
>
>   ,#+call: drawlayout[:stdin solution]()
>
>   ,#+name: drawlayout
>   ,#+header: :results raw
>   ,#+begin_src awk
>     BEGIN {
>         print "#+begin_latex"
>         print "\\begin{tikzpicture}[scale=0.1]"
>         print "\\draw"
>     }
>     /^[0-9]/ {
>         printf("(%f,%f) circle (%f) node {%d}\n", $5, $6, $2, $1);
>     }
>     END {
>         print ";"
>         print "\\end{tikzpicture}"
>         print "#+end_latex"
>     }
>   ,#+end_src
> #+end_src
>
> I cannot figure out the magic incantation of [inside header arguments]
> and [end header arguments] that will export the output of the awk block
> when called as raw LaTeX code.
>
> If I put ":results raw" and ":exports results" on the src block,
> exporting that block works just fine.  The call however is wrapped in an
> EXAMPLE block which does me no good!
>
> Any suggestions welcome!

Have you tried

#+call: drawlayout[:stdin solution]() :results raw

or,

#+call: drawlayout[:stdin solution]() :results latex

which should make the print "#+begin_latex" etc. lines of drawlayout redundant?

All the best,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: babel output as LaTeX code: help please!
  2015-03-10 18:42 ` Thomas S. Dye
@ 2015-03-10 19:14   ` Eric S Fraga
  2015-03-10 19:49     ` Thomas S. Dye
  0 siblings, 1 reply; 4+ messages in thread
From: Eric S Fraga @ 2015-03-10 19:14 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode

On Tuesday, 10 Mar 2015 at 08:42, Thomas S. Dye wrote:

[...]

> Have you tried
>
> #+call: drawlayout[:stdin solution]() :results raw
>
> or,
>
> #+call: drawlayout[:stdin solution]() :results latex
>
> which should make the print "#+begin_latex" etc. lines of drawlayout redundant?

Both work perfectly.  Many thanks!

The documentation confused me.  I see now that the end header arguments
are not to be enclosed in [] whereas the inside ones are.  The
documentation shows this in the example but the syntax seems to imply
that the []s are required -- but in hindsight I guess the []s mean
optional in this case.  However, they are not optional for the inside
arguments...

Ummm, the documentation is definitely confusing but I'm not sure how to
improve it other than by adding a sentence making this explicit?

Thanks again,
eric
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.1, Org release_8.3beta-843-ga5f1a3.dirty

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

* Re: babel output as LaTeX code: help please!
  2015-03-10 19:14   ` Eric S Fraga
@ 2015-03-10 19:49     ` Thomas S. Dye
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas S. Dye @ 2015-03-10 19:49 UTC (permalink / raw)
  To: emacs-orgmode

Aloha Eric,

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Tuesday, 10 Mar 2015 at 08:42, Thomas S. Dye wrote:
>
> [...]
>
>> Have you tried
>>
>> #+call: drawlayout[:stdin solution]() :results raw
>>
>> or,
>>
>> #+call: drawlayout[:stdin solution]() :results latex
>>
>> which should make the print "#+begin_latex" etc. lines of drawlayout redundant?
>
> Both work perfectly.  Many thanks!
>
> The documentation confused me.  I see now that the end header arguments
> are not to be enclosed in [] whereas the inside ones are.  The
> documentation shows this in the example but the syntax seems to imply
> that the []s are required -- but in hindsight I guess the []s mean
> optional in this case.  However, they are not optional for the inside
> arguments...
>
> Ummm, the documentation is definitely confusing but I'm not sure how to
> improve it other than by adding a sentence making this explicit?

Perhaps the confusion comes from the fact that the syntax for #+call
lines differs from inline evaluation?  Inline evaluation requires [] for
the end header argument, but [] aren't used for the end header argument
of #+call lines.

I agree that this difference isn't easy to spot among all the ([<>]).
Perhaps a sentence pointing out the difference would be useful?

All the best,
Tom
-- 
Thomas S. Dye
http://www.tsdye.com

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

end of thread, other threads:[~2015-03-10 19:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-10 17:25 babel output as LaTeX code: help please! Eric S Fraga
2015-03-10 18:42 ` Thomas S. Dye
2015-03-10 19:14   ` Eric S Fraga
2015-03-10 19:49     ` Thomas S. Dye

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