emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* exporting org to latex, execute matlab before exporting
@ 2017-08-02 12:08 Uwe Brauer
  2017-08-03  7:42 ` [SOLVED] (was: exporting org to latex, execute matlab before exporting) Uwe Brauer
  2017-08-06 21:04 ` exporting org to latex, execute matlab before exporting Grant Rettke
  0 siblings, 2 replies; 6+ messages in thread
From: Uwe Brauer @ 2017-08-02 12:08 UTC (permalink / raw)
  To: emacs-orgmode

Hello

Take the following example

* Test section

This is a test
#+begin_src matlab :results output latex :exports results
X=[1,2,3,4,5,6,7];
p=[1/7 1/7 1/7 1/7 1/7 1/7 1/7];
E=X*p';
x2=X.*X;
E2=x2*p';
V=E2-E^2;
disp('\begin{align}')
fprintf('E[X]&=%g\\\\ \n', E)
fprintf('E^2[X]&=%g\\\\\n', E2)
fprintf('V[X]&=%g\n', V)
disp('\end{align}')
#+end_src

Executing the src block leads

#+RESULTS:
#+BEGIN_EXPORT latex
\begin{align}
E[X]&=4\\ 
E^2[X]&=20\\
V[X]&=4
\end{align}
#+END_EXPORT

Which is what I want. When I convert the org file to latex I am again
asked to execute the src block, which I don't want since it is already
executed. How can I avoid this question, without deleting the src block.
This is important if I have a lot of blocks which I already have
executed, and want to export the file without denying is executing every
time I am asked.

Thanks

Uwe Brauer 

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

* [SOLVED] (was: exporting org to latex, execute matlab before exporting)
  2017-08-02 12:08 exporting org to latex, execute matlab before exporting Uwe Brauer
@ 2017-08-03  7:42 ` Uwe Brauer
  2017-08-03  8:04   ` [NOT SOLVED: BUG?] (was: [SOLVED]) Uwe Brauer
  2017-08-06 21:04 ` exporting org to latex, execute matlab before exporting Grant Rettke
  1 sibling, 1 reply; 6+ messages in thread
From: Uwe Brauer @ 2017-08-03  7:42 UTC (permalink / raw)
  To: emacs-orgmode

>>> "Uwe" == Uwe Brauer <oub@mat.ucm.es> writes:


   > Which is what I want. When I convert the org file to latex I am again
   > asked to execute the src block, which I don't want since it is already
   > executed. How can I avoid this question, without deleting the src block.
   > This is important if I have a lot of blocks which I already have
   > executed, and want to export the file without denying is executing every
   > time I am asked.

To answer my own question put

# -*- org-export-babel-evaluate: nil -*-

At the beginning of the file.

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

* [NOT SOLVED: BUG?] (was: [SOLVED])
  2017-08-03  7:42 ` [SOLVED] (was: exporting org to latex, execute matlab before exporting) Uwe Brauer
@ 2017-08-03  8:04   ` Uwe Brauer
  2017-08-03 16:40     ` Berry, Charles
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Brauer @ 2017-08-03  8:04 UTC (permalink / raw)
  To: emacs-orgmode



I just checked and situation is absurd. Here is the minimal example:
,----
| 
| #+begin_src matlab   :results output latex :exports results 
| X=[1];
| disp('\begin{displaymath}')
| fprintf('X&=%g\\\\ \n', X)
| disp('\end{displaymath}')
| #+end_src
| 
| #+RESULTS:
| #+BEGIN_EXPORT latex
| \begin{displaymath}
| X&=1\\ 
| \end{displaymath}
| #+END_EXPORT
`----


When I set org-export-babel-evaluate nil, then the code is *not*
evaluated, *but* the code block *and* the result are exported.
,----
| 
| \begin{document}
| 
| \lstset{style=Matlab-editor,basicstyle=\mlttfamily,escapechar=",mlshowsectionrules=true,mathescape=true,morecomment=[s]{\%\{}{\%\}},language=Matlab,label= ,caption= ,captionpos=b,numbers=none}
| \begin{lstlisting}
| X=[1];
| disp('\begin{displaymath}')
| fprintf('X&=%g\\\\ \n', X)
| disp('\end{displaymath}')
| \end{lstlisting}
| 
| \begin{displaymath}
| X&=1\\ 
| \end{displaymath}
| \end{document}
`----

When I set org-export-babel-evaluate to t, export but say no to the
question whether or not to evaluate, *only* the result is exported,
which is what I want.
,----
| 
| \begin{document}
| 
| \begin{displaymath}
| X&=1\\ 
| \end{displaymath}
| \end{document}
`----

Is this a *bug*? I wait a day, then I will file a bug report.

Uwe Brauer 

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

* Re: [NOT SOLVED: BUG?] (was: [SOLVED])
  2017-08-03  8:04   ` [NOT SOLVED: BUG?] (was: [SOLVED]) Uwe Brauer
@ 2017-08-03 16:40     ` Berry, Charles
  2017-08-03 19:19       ` [NOT SOLVED: BUG?] Uwe Brauer
  0 siblings, 1 reply; 6+ messages in thread
From: Berry, Charles @ 2017-08-03 16:40 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-orgmode@gnu.org


> On Aug 3, 2017, at 1:04 AM, Uwe Brauer <oub@mat.ucm.es> wrote:
> 
> 
> 
> I just checked and situation is absurd. Here is the minimal example:
> [snip]
> 
> When I set org-export-babel-evaluate nil, then the code is *not*
> evaluated, *but* the code block *and* the result are exported.
> 
[snip]
> When I set org-export-babel-evaluate to t, export but say no to the
> question whether or not to evaluate, *only* the result is exported,
> which is what I want.
> 
> Is this a *bug*? I wait a day, then I will file a bug report.

No. It is *obsolete* and its replacement is not recommended for your application. 

,----[ C-h v org-export-babel-evaluate RET ]
| org-export-babel-evaluate is a variable defined in ‘org-compat.el’.
| Its value is t
| 
|   This variable is an alias for ‘org-export-use-babel’.
|   This variable is obsolete since Org 9.1;
|   use ‘org-export-use-babel’ instead.
| 
| Documentation:
| Switch controlling code evaluation and header processing during export.
| When set to nil no code will be evaluated as part of the export
| process and no header arguments will be obeyed.  When set to
| ‘inline-only’, only inline code blocks will be executed.  Users
| who wish to avoid evaluating code on export should use the header
| argument ‘:eval never-export’.
| 
| You can customize this variable.
| 
| [back]
`----

You want `:eval never-export'.


Chuck

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

* Re: [NOT SOLVED: BUG?]
  2017-08-03 16:40     ` Berry, Charles
@ 2017-08-03 19:19       ` Uwe Brauer
  0 siblings, 0 replies; 6+ messages in thread
From: Uwe Brauer @ 2017-08-03 19:19 UTC (permalink / raw)
  To: emacs-orgmode

>>> "Berry," == Berry, Charles <ccberry@ucsd.edu> writes:

    >> On Aug 3, 2017, at 1:04 AM, Uwe Brauer <oub@mat.ucm.es> wrote:
    >> 
    >> 
    >> 
    >> I just checked and situation is absurd. Here is the minimal example:
    >> [snip]
    >> 
    >> When I set org-export-babel-evaluate nil, then the code is *not*
    >> evaluated, *but* the code block *and* the result are exported.
    >> 
    > [snip]
    >> When I set org-export-babel-evaluate to t, export but say no to the
    >> question whether or not to evaluate, *only* the result is exported,
    >> which is what I want.
    >> 
    >> Is this a *bug*? I wait a day, then I will file a bug report.

    > No. It is *obsolete* and its replacement is not recommended for your application. 

Thanks I did not finish reading the documentation, my bad

So I tried
#+begin_src matlab  :results output latex :exports results  :eval never-export 
X=[1];
disp('\begin{displaymath}')
fprintf('X&=%g\\\\ \n', X)
disp('\end{displaymath}')
#+end_src

which then worked as expected. Before I played around with
code I found in
https://emacs.stackexchange.com/questions/17744/is-there-a-way-to-make-org-mode-ignore-src-blocks-when-exporting-to-html

But your suggestion is cleaner. Thanks

Uwe 

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

* Re: exporting org to latex, execute matlab before exporting
  2017-08-02 12:08 exporting org to latex, execute matlab before exporting Uwe Brauer
  2017-08-03  7:42 ` [SOLVED] (was: exporting org to latex, execute matlab before exporting) Uwe Brauer
@ 2017-08-06 21:04 ` Grant Rettke
  1 sibling, 0 replies; 6+ messages in thread
From: Grant Rettke @ 2017-08-06 21:04 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

On Wed, Aug 2, 2017 at 7:08 AM, Uwe Brauer <oub@mat.ucm.es> wrote:
> Which is what I want. When I convert the org file to latex I am again
> asked to execute the src block, which I don't want since it is already
> executed. How can I avoid this question, without deleting the src block.
> This is important if I have a lot of blocks which I already have
> executed, and want to export the file without denying is executing every
> time I am asked.

Never evaluate source-blocks or in-line-source-blocks *on export*.

#+NAME: org_gcr_2017-05-12_mara_FE5C21BF-9766-4277-A413-B3AF5C255C39
#+BEGIN_SRC emacs-lisp
(help/set-org-babel-default-header-args :eval "never-export")
(help/set-org-babel-default-inline-header-args :eval "never-export")
#+END_SRC

Never evaluate in-line-source-blocks *on export*.

#+NAME: org_gcr_2017-05-12_mara_DB816700-04B3-45D0-9847-490BBFE9DBA0
#+BEGIN_SRC emacs-lisp
(setq org-export-babel-evaluate nil)
#+END_SRC

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

end of thread, other threads:[~2017-08-06 21:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-02 12:08 exporting org to latex, execute matlab before exporting Uwe Brauer
2017-08-03  7:42 ` [SOLVED] (was: exporting org to latex, execute matlab before exporting) Uwe Brauer
2017-08-03  8:04   ` [NOT SOLVED: BUG?] (was: [SOLVED]) Uwe Brauer
2017-08-03 16:40     ` Berry, Charles
2017-08-03 19:19       ` [NOT SOLVED: BUG?] Uwe Brauer
2017-08-06 21:04 ` exporting org to latex, execute matlab before exporting Grant Rettke

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