emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Diego Zamboni <diego@zzamboni.org>
To: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: [matlab src is always exported to latex!!]
Date: Tue, 13 Oct 2020 14:11:12 +0200	[thread overview]
Message-ID: <CAGY83EdzjOWcPOEdY4E_H1aS7uaOLe0M-H6qqM_ZPtByXRd=Eg@mail.gmail.com> (raw)
In-Reply-To: <874kmy5phz.fsf@mat.ucm.es>

[-- Attachment #1: Type: text/plain, Size: 2386 bytes --]

Uwe,

In my testing (using octave since I don't have matlab, but I hope it's
similar), using = :exports none :results output raw= seems to produce the
desired output:

#+begin_src octave :exports results :results output raw
close all
N = 3; % number of chebyshev nodes
n = 1; % polytropic index
iters = 1; % iterations
j=[0 1 2 3];
z=cos((pi*j)/3);
y=1-(0.5*(z+1)).^2;
a=n*(8);
a2=eye(3+1)*a;
disp('\begin{align*}')
disp('A_{1,k-1}&=')
disp('\begin{pmatrix}')
fprintf('%g &%g &%g &%g\\\\\n',a2')
disp('\end{pmatrix}=OK\\')
disp('\end{align*}')
#+end_src

#+RESULTS:
\begin{align*}
A_{1,k-1}&=
\begin{pmatrix}
8 &0 &0 &0\\
0 &8 &0 &0\\
0 &0 &8 &0\\
0 &0 &0 &8\\
\end{pmatrix}=OK\\
\end{align*}

Which renders the matrix correctly. I first tried with =:exports results=,
but that for some reason results in the results being included twice in the
LaTeX output. I'm not sure why.

Hope this helps,
--Diego


On Tue, Oct 13, 2020 at 1:36 PM Uwe Brauer <oub@mat.ucm.es> wrote:

> >>> "AB" == Arne Babenhauserheide <arne_bab@web.de> writes:
>
> > Uwe Brauer <oub@mat.ucm.es> writes:
>
> >> That did not work: I tried
> >> #+begin_src matlab  :results output
> >>
> >> But when I exported the org file to latex, the matlab code was also
> >> exported. Strange
>
> > Do you use :exports results?
>
> > :results output switches to show what is printed to stdout
>
> See my answer to Eric
>
> It does not do want I want
> #+begin_src matlab :exports results
> close all
> N = 3; % number of chebyshev nodes
> n = 1; % polytropic index
> iters = 1; % iterations
> j=[0 1 2 3];
> z=cos((pi*j)/3);
> y=1-(0.5*(z+1)).^2;
> a=n*(8);
> a2=eye(3+1)*a;
> disp('\begin{align*}')
> disp('A_{1,k-1}&=')
> disp('\begin{pmatrix}')
> fprintf('%g &%g &%g &%g\\\\\n',a2')
> disp('\end{pmatrix}=OK\\')
> disp('\end{align*}')
> #+end_src
>
> Leads to
>
> \begin{verbatim}
> \begin{align*}
> A_{1,k-1}&=
> \begin{pmatrix}
> 8 &0 &0 &0\\
> 0 &8 &0 &0\\
> 0 &0 &8 &0\\
> 0 &0 &0 &8\\
> \end{pmatrix}=OK\\
> \end{align*}
> \end{verbatim}
>
> So at the moment the only solution I can think of is to use the code I
> posted
>
> (defun my-latex-filter-src-blocks (text backend info)
>   "Remove source blocks from latex export."
>   (when (org-export-derived-backend-p backend 'latex)
>     "%% [removed source block]\n"))
>
> (add-to-list 'org-export-filter-src-block-functions
>          'my-latex-filter-src-blocks)
>

[-- Attachment #2: Type: text/html, Size: 3526 bytes --]

  reply	other threads:[~2020-10-13 12:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13  6:29 org mode with babel source: execute all source blocks, don't export them to latex Uwe Brauer
2020-10-13  7:04 ` Diego Zamboni
2020-10-13  7:26   ` [matlab src is always exported to latex!!] (was: org mode with babel source: execute all source blocks, don't export them to latex) Uwe Brauer
2020-10-13  8:31     ` [solution of sorts] (was: [matlab src is always exported to latex!!]) Uwe Brauer
2020-10-13  8:31     ` [matlab src is always exported to latex!!] Eric S Fraga
2020-10-13 11:31       ` Uwe Brauer
2020-10-13  8:44     ` [matlab src is always exported to latex!!] (was: org mode with babel source: execute all source blocks, don't export them to latex) Dr. Arne Babenhauserheide
2020-10-13 11:34       ` [matlab src is always exported to latex!!] Uwe Brauer
2020-10-13 12:11         ` Diego Zamboni [this message]
2020-10-13 12:56           ` Uwe Brauer
2020-10-13 12:59             ` Eric S Fraga
2020-10-13 17:21               ` Uwe Brauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGY83EdzjOWcPOEdY4E_H1aS7uaOLe0M-H6qqM_ZPtByXRd=Eg@mail.gmail.com' \
    --to=diego@zzamboni.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).