#+TITLE: Demo of mathml and maxima * An example ** Set up of the printer If you have version =5.46+= of Maxima, this Maxima code can be used. #+name: startup #+begin_src maxima :tangle ./startup.mac :exports code :results none (load("alt-display"), set_alt_display(1,lambda([x],false)), set_alt_display(2,mathml_display), display2d:true, linenum:0); #+end_src Otherwise, for older versions, this Lisp-ified Maxima code can be used. #+begin_src maxima :tangle ./startup.lisp :exports code :results none :noweb yes #$ <> #$ #+end_src The code loads the =alt-display= package. It sets the 1d printer to print nothing, so input is not echoed; it sets the 2d printer to use the =mathml_display= function, which is provided by =alt-display=. ** A simple example The code block #+name: example.org #+begin_src org :exports code :results replace ,#+name: example.mac ,#+header: :exports both ,#+header: :results raw ,#+header: :wrap "export odt" ,#+header: :batch batch ,#+header: :cmdline --no-init --very-quiet --preload ./startup.lisp ,#+begin_src maxima genmatrix(lambda([i,j], random(100)/random(100)), 4,4); ,#+end_src #+end_src #+RESULTS: example.org #+name: example.mac #+header: :exports both #+header: :results raw #+header: :wrap "export odt" #+header: :batch batch #+header: :cmdline --no-init --very-quiet --preload ./startup.lisp #+begin_src maxima genmatrix(lambda([i,j], random(100)/random(100)), 4,4); #+end_src produces the following output: #+RESULTS: example.mac #+begin_export odt mlabel %o 1 , 6 2 5 4 91 29 85 98 3 7 13 20 13 39 20 19 4 97 6 1 43 39 23 13 36 53 60 71 4 3 #+end_export A small amount of hand-editing will give something better. ** A re-think The code seems correct, so let's save the results of the code block to file and use the exporter to correctly handle it. #+name: rethink.org #+begin_src org :exports code :results replace ,#+name: rethink.mac ,#+header: :exports both ,#+header: :results file ,#+header: :file ./snippet.mml ,#+header: :batch batch ,#+header: :cmdline --no-init --very-quiet --preload ./startup.lisp ,#+begin_src maxima genmatrix(lambda([i,j], random(100)/random(100)), 4,4); ,#+end_src #+end_src #+RESULTS: rethink.org #+name: rethink.mac #+header: :exports both #+header: :results file #+header: :file ./snippet.mml #+header: :batch batch #+header: :cmdline --no-init --very-quiet --preload ./startup.lisp #+begin_src maxima genmatrix(lambda([i,j], random(100)/random(100)), 4,4); #+end_src produces the following output: #+RESULTS: rethink.mac [[file:./snippet.mml]]