Re: Clarification on :results file vs. :results graphics file

2022-11-04 Thread Leo Butler
On Fri, Nov 04 2022, Ihor Radchenko  wrote:

> Leo Butler  writes:
>
>>>> @@ -145,7 +151,7 @@ This example is from 
>>>> [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tuto
>>>>  ,#+name: 3d-maxima
>>>>  ,#+header: :file images/maxima-3d.png
>>>>  ,#+header: :exports results
>>>> -,#+header: :results graphics
>>>> +,#+header: :results graphics file
>>>
>>> Using graphics together with file does not make sense.
>>
>> Ok. But I am not sure the code agrees with you. In ob-core.el,
>>  ...
>>
>> Is it, in your opinion, ob-maxima's responsibility to add "graphics" to
>> :result-params when :results file is specified?
>
> No.

Thank you for correcting yourself and me. I had arrived at the same
conclusion and was going to retract that `patch' to ob-maxima.el.

Leo


Re: [BUG] ob-doc-maxima.org and ob-maxima.el

2022-11-03 Thread Leo Butler
Hi Ihor,

On Thu, Nov 03 2022, Ihor Radchenko  wrote:

> Leo Butler  writes:
>
>> In worg's documentation of ob-maxima.el[fn:1], there are several bugs.
>
> Thanks for reporting!

Thank you for the feedback. I will comment inline below.

>
>> 1. In the subsection `Inline Display of Maxima LaTeX Output', the
>> results are missing.
>
> It is because source block evaluation is disabled on server side when
> generating WORG website from org sources.

Ahhh! Of course.

>
> You basically need to evaluate the code block manually to have it
> present in the original file without a need to evaluate during export.
>
> I do not have maxima on my system. It would be welcome if you evaluate
> the code blocks with missing results manually and submit a patch with.

Attached.

>
>> ... This is because the code block is named
>> `solve-maxima', the same as in the section `Solver'. Export results in
>> that output being put in the `Solver' section (I don't know if that
>> should be considered a bug in Org).
>
> No, the source block in the Solver section is different. It just has
> the same name. Name duplicate should be fixed indeed.

That was fixed in the patch I sent, and the attached one.

>
>> 2. In `3D Plots', the header arguments do not result in a link to a
>> generated file being created on evaluation of the code block. I am
>> unsure if this is a bug in Org, ob-maxima.el or ob-doc-maxima.org or
>> what.
>> On reading the description of the =:results graphics=
>> header[fn:2], it looks like there is blame to go around.
>
> Makes sense. Can you please report this inconsistency in more details in
> a separate email? It looks like something is not right with ob-maxima
> code in the treatment of :results graphics.

Sure. I was playing with ob-doc-octave.org, too, and I see that there is
a similar problem there.

>
>> @@ -145,7 +151,7 @@ This example is from 
>> [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tuto
>>  ,#+name: 3d-maxima
>>  ,#+header: :file images/maxima-3d.png
>>  ,#+header: :exports results
>> -,#+header: :results graphics
>> +,#+header: :results graphics file
>
> Using graphics together with file does not make sense.

Ok. But I am not sure the code agrees with you. In ob-core.el,
`org-babel-graphical-output-file' is defined as:

(defun org-babel-graphical-output-file (params)
  "File where a babel block should send graphical output, per PARAMS.
Return nil if no graphical output is expected.  Raise an error if
the output file is ill-defined."
  (let ((file (cdr (assq :file params
(cond (file (and (member "graphics" (cdr (assq :result-params params)))
 file))
 ...

Is it, in your opinion, ob-maxima's responsibility to add "graphics" to
:result-params when :results file is specified?

> We should probably fix ob-maxima with :results file first.
> Ideally, the code here should be simply
> ,#+header: :results file

The attached patch to lisp/ob-maxima.el makes the example work with your
suggested header.

>
>>  #+begin_example
>> -,#+NAME: solve-maxima
>> -,#+HEADER: :exports none
>> -,#+BEGIN_SRC maxima :results raw
>> +,#+NAME: tex-maxima
>> +,#+HEADER: :exports results
>> +,#+BEGIN_SRC maxima :results latex
>
> This will break WORG page. We are exporting to HTML, not latex and the
> results wrapped into #+begin_export latex will not be exported to the
> website. What's wrong with raw?

Yes, you are right about WORG. I was testing by building a pdf and
didn't think to build the html page. My mistake. The patch I am sending
builds a working html page.

There is a problem, though. When evaluating the code block

#+NAME: tex-maxima
#+HEADER: :exports results
#+BEGIN_SRC maxima :results raw
  tex(exp(-x)/x);
#+END_SRC

multiple times, the results are appended below each other. Adding the
option `drawer', or changing the results to latex (or html), prevents
this. I will open a separate email report about this.

Leo

diff --git a/org-contrib/babel/languages/ob-doc-maxima.org b/org-contrib/babel/languages/ob-doc-maxima.org
index 810c9ef4..eb760eff 100644
--- a/org-contrib/babel/languages/ob-doc-maxima.org
+++ b/org-contrib/babel/languages/ob-doc-maxima.org
@@ -111,7 +111,9 @@ powers of 12, where the powers are passed with a variable.
   print(12^x);
 #+end_src
 
-#+results: test-maxima
+Which produces the result:
+
+#+RESULTS: test-maxima
 : 26.06280316745402
 
 ** Solver
@@ -137,6 +139,14 @@ Of course, =maxima= is more than a calculator.
   print(solution);
 #+end_src
 
+Which produces the result:
+
+#+RESULTS: solve-maxima
+: solve: solution:
+: x = - 4
+:  x = 4
+: [%t1, %t2] 
+
 ** 3D pl

[PATCH] Re: Maxima code blocks does not work in windows revisited

2022-11-03 Thread Leo Butler
On Thu, Nov 03 2022, Max Nikulin  wrote:

> On 03/11/2022 17:01, Fraga, Eric wrote:
>> On Thursday,  3 Nov 2022 at 09:35, Max Nikulin wrote:
>>> maxima --very-quiet -r "batchload(\"c:\\Temp\\maxima-XX.max\")"$
>> Should the $ not be within the quotes?
>
> Does "$" have any special meaning in cmd.exe? I do not mind that it
> should be inside `format' first argument.
>
> I do not have a Windows machine to test and not motivated enough to
> try Emacs in wine.

Max, a minor modification of the test you sent earlier shows that when
system-type is ms-dos, the placement does not matter (the command-line
is the same); but for gnu/linux, placement matters and Eric is right
(the command-lines are not the same and the dollar sign needs to be
escaped).

I have attached a patch that puts the dollar sign in the right place for
both. The existing tests pass when running 'make test'.

Leo

From 423340175a354463c82fac2b4b3a404391e67eb5 Mon Sep 17 00:00:00 2001
From: Leo Butler 
Date: Thu, 3 Nov 2022 10:39:28 -0500
Subject: [PATCH] lisp/ob-maxima.el: correct placement of $ in command string

* ob-maxima.el (org-babel-maxima:execute): Commit 6156b57bdf2b fixed a
quoting problem encountered on windows. However, the dollar sign ($)
is part of the maxima command string and needs to be escaped on
gnu/linux.

Reported by: Eric Fraga
Ref:
https://list.orgmode.org/950eb41c-1c8a-c891-af8d-276f6a452...@electrum-bikes.pl/T/#m4b5a54551604e5b3ec21f317c4a31b547ccada68

TINYCHANGE
---
 lisp/ob-maxima.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el
index dba12d7b6..e3dfbb668 100644
--- a/lisp/ob-maxima.el
+++ b/lisp/ob-maxima.el
@@ -81,10 +81,10 @@ This function is called by `org-babel-execute-src-block'."
 	(result
 	 (let* ((cmdline (or (cdr (assq :cmdline params)) ""))
 		(in-file (org-babel-temp-file "maxima-" ".max"))
-		(cmd (format "%s --very-quiet -r %s$ %s"
+		(cmd (format "%s --very-quiet -r %s %s"
 			 org-babel-maxima-command
  (shell-quote-argument
-  (format "batchload(%S)" in-file))
+  (format "batchload(%S)$" in-file))
  cmdline)))
 	   (with-temp-file in-file (insert (org-babel-maxima-expand body params)))
 	   (message cmd)
-- 
2.35.1



Re: Maxima code blocks does not work in windows revisited

2022-11-02 Thread Leo Butler
On Wed, Nov 02 2022, Max Nikulin  wrote:

> On 02/11/2022 11:47, Ihor Radchenko wrote:
 (for reference, this email is a followup of
 https://orgmode.org/list/ca+ikm3wqa33xp4c3pvv+f2a-gn0dbezsdx6vf2crd+37+u6...@mail.gmail.com)
>
> Ihor, you recently applied an alternative patch to Org main
> branch. Emacs tree still has ob-maxima.el with single quotes around
> batchload.
>
> Nikolay Kudryavtsev. Re: [PATCH] ob-maxima.el: Fix execution on MS
> Windows. Thu, 30 Dec 2021 23:54:10 +0300. 
> https://list.orgmode.org/8cd49b4c-9342-a77f-d665-402c41432...@gmail.com
>
>> diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el
>> index dba12d7b6..52423db18 100644
>> --- a/lisp/ob-maxima.el
>> +++ b/lisp/ob-maxima.el
>> @@ -84,7 +84,7 @@ (defun org-babel-execute:maxima (body params)
>>  (cmd (format "%s --very-quiet -r %s$ %s"
>>   org-babel-maxima-command
>>   (shell-quote-argument
>> -  (format "batchload(%S)" in-file))
>> +  (format "\"batchload(\\\"%S\\\")\"" in-file))
>
> Notice that code in the message you cited has "%s" and does not have
> `shell-quote-argument'. Extra quotes may discard effect of existing 
> double pass escaping.

Yes, OP should try this solution first. If it fails, then there is
some problem in `shell-quote-argument' that needs to be fixed.

My 2c.
Leo


[BUG] ob-doc-maxima.org and ob-maxima.el

2022-11-02 Thread Leo Butler
Hi,

In worg's documentation of ob-maxima.el[fn:1], there are several bugs.


1. In the subsection `Inline Display of Maxima LaTeX Output', the
results are missing. This is because the code block is named
`solve-maxima', the same as in the section `Solver'. Export results in
that output being put in the `Solver' section (I don't know if that
should be considered a bug in Org). On the webpage, the errant output
has been deleted. The correct output in both sections should be
included.

2. In `3D Plots', the header arguments do not result in a link to a
generated file being created on evaluation of the code block. I am
unsure if this is a bug in Org, ob-maxima.el or ob-doc-maxima.org or
what. On reading the description of the =:results graphics=
header[fn:2], it looks like there is blame to go around. Related: in
ob-doc-octave.org, the graphics example only includes a =:results file=
header argument.

The attached patch to ob-doc-maxima.org fixes only the documentation
issues:

1. Present the correct output of code block `solve-maxima'.
2. Add the header argument `file' to the `3d-maxima' example to create a
correct link and graphics file.
3. Rename the tex code block to `tex-maxima' and change the results type
to =latex= to generate correct output.

TIA,
Leo Butler

[fn:1]
https://orgmode.org/worg//org-contrib/babel/languages/ob-doc-maxima.html
[fn:2] (info "(org) Results of Evaluation")

diff --git a/org-contrib/babel/languages/ob-doc-maxima.org b/org-contrib/babel/languages/ob-doc-maxima.org
index 810c9ef4..f1388187 100644
--- a/org-contrib/babel/languages/ob-doc-maxima.org
+++ b/org-contrib/babel/languages/ob-doc-maxima.org
@@ -137,6 +137,12 @@ Of course, =maxima= is more than a calculator.
   print(solution);
 #+end_src
 
+#+RESULTS: solve-maxima
+: solve: solution:
+: x = - 4
+:  x = 4
+: [%t1, %t2] 
+
 ** 3D plots
 With =gnuplot= installed (4.0 or higher), 3D graphics are possible.
 This example is from [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tutorial on the maxima/gnuplot interface]].
@@ -145,7 +151,7 @@ This example is from [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tuto
 ,#+name: 3d-maxima
 ,#+header: :file images/maxima-3d.png
 ,#+header: :exports results
-,#+header: :results graphics
+,#+header: :results graphics file
 ,#+begin_src maxima 
   programmode: false;
   plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50],[gnuplot_pm3d,true]);
@@ -154,14 +160,14 @@ This example is from [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tuto
 
 #+name: 3d-maxima
 #+header: :file images/maxima-3d.png
-#+header: :results graphics
 #+header: :exports results
+#+header: :results graphics file
 #+begin_src maxima 
   programmode: false;
   plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50],[gnuplot_pm3d,true]);
 #+end_src
 
-#+results: 3d-maxima
+#+RESULTS: 3d-maxima
 [[file:images/maxima-3d.png]]
 
 ** Inline Display of Maxima LaTeX Output
@@ -170,19 +176,24 @@ This example is from [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tuto
   example.
 
 #+begin_example
-,#+NAME: solve-maxima
-,#+HEADER: :exports none
-,#+BEGIN_SRC maxima :results raw
+,#+NAME: tex-maxima
+,#+HEADER: :exports results
+,#+BEGIN_SRC maxima :results latex
   tex(exp(-x)/x);
 ,#+END_SRC
 #+end_example
 
-#+NAME: solve-maxima
+#+NAME: tex-maxima
 #+HEADER: :exports results
-#+BEGIN_SRC maxima :results raw
+#+BEGIN_SRC maxima :results latex
   tex(exp(-x)/x);
 #+END_SRC
 
+#+RESULTS: tex-maxima
+#+begin_export latex
+$${{e^ {- x }}\over{x}}$$
+#+end_export
+
 *** Toggle inline display of latex code
 Latex code in org mode can be displayed inline by 'C-c C-x
 C-l'. To remove the inline display 'C-c C-c' is used. This is


Re: [O] Maxima code blocks does not work in windows revisited

2022-11-01 Thread Leo Butler
On Tue, Nov 01 2022, Mati  wrote:

> On 01.11.2022 09:04, Ihor Radchenko wrote:
>
>> Do you mean that you changed the code at line 82 inside
>> org-babel-execute:maxima to
>>
>>   (let* ((cmdline (or (cdr (assoc :cmdline params)) ""))
>>(in-file (org-babel-temp-file "maxima-" ".max"))
>>  (cmd (format "%s --very-quiet -r \"batchload(\\\"%s\\\")$\" %s"
>>   org-babel-maxima-command in-file cmdline)))
>>
>> ??
>>
>> (for reference, this email is a followup of
>> https://orgmode.org/list/ca+ikm3wqa33xp4c3pvv+f2a-gn0dbezsdx6vf2crd+37+u6...@mail.gmail.com)
>
> yes, of course only part of it

Please don't make people guess at what you have done. Ihor, in
particular, does a huge amount of work on Org. Making him and us guess
only makes that work harder.

> I am testing maxima-mode now (not in org) and it works, but is broken
> on windows. Looks like there are many more problems with syntax.

I am interested to know what is broken in maxima-mode. Please
explain with examples.

Best,
Leo


Re: Export of this table fails LuaLaTeX compilation

2022-10-13 Thread Leo Butler
On Thu, Oct 13 2022, Max Nikulin  wrote:

> On 13/10/2022 09:44, Ihor Radchenko wrote:
>> Max Nikulin writes:
>> 
>>> I am considering \noalign{} instead of \relax. I was never aware of its
>>> effect, but accordingly to The TeXbook it should keep TeX in vertical
>>> mode without any action due to empty argument. (Actually I surprised
>>> that \relax causes any change of internal state besides parser.)
>> If \noalign has less side effects compared to \relax, I'd prefer
>> \noalign. Can you confirm this?
>
> My understanding of TeX is not solid enough to confirm this. From The
> TeXbook I have an impression that \noalign is added specially for 
> table-like blocks to be used immediately after \cr (low level command
> similar to \\). So I would not use it outside of tables however it may 
> be safe. I am not aware of problems with \\\noalign{} in tables. The
> exact effect of \relax is not clear to me yet. I do not have an
> example of negative effect of \relax similar to \hline but outside of
> tables.
>
> I can try to ask for a better suggestion at stackexchange, but I am
> unsure if the question will be noticed by some person from a TeX
> engine or core LaTeX developers or at least with better understanding
> of TeX internals.
>
>>> Unfortunately \noalign{} just as \relax will not allow @@latex:[1cm]@@
>>> on the next line, perhaps @@latex:\noalign{\vskip 1cm}@@ is a workaround
>>> to introduce additional vertical space.
>> What you are talking about appears to be abusing our exporter. We
>> give
>> no guarantees about how \\ is going to be exported internally into
>> LaTeX. We should have no obligation to keep use-cases like this.
>
> On the other hand LaTeX backend was transparent to such hacks, so the
> change might be breaking to some users. That is why conditionally
> adding \noalign{} or \relax if \\ is not followed by an export snippet
> may be a better solution.
>
>>> I never used \\* or \\*[10pt] variants of the command. Current stable
>>> release should has problems when the line next to \\ starts from * that
>>> is not bold marker, besides square brackets.
>> I feel like I am missing what you are talking about here.
>
> The rabbit hole is deeper than I thought. The \\ command has its star
> counterpart \\* to prevent page break at this point, and both of them 
> allow optional [] argument. In vanilla LaTeX2e space is
> allowed between \\ and *. However \usepackage{amsmath} redefines \\
> command. It still can recognize following *, but only on the same
> line. Unsure if it is a bug or feature. So before your commit the
> following is not a problem in *default* Org configuration:
>
> Star\\
> @@ignore:@@* on the next line.
>
> Star and brackets\\
> *[1em] on the next line.
>
> | Star |
> | * in the next row. |
> |-|
> | Star and brackets |
> | *[1em] in the next row. |
>
> However it might be if someone changes list of default
> packages. Adding \noalign{} and \relax should fix the issue just for
> square brackets.
>
> So at least as a temporary fix \noalign{} should be used for tables
> instead of \relax to mitigate negative effect of the recent patch.
>
> P.S. Packages like longtable might bring more surprises.

Maybe Org should not use \\ to end lines in a latex-exported table?
The fact that it has many variations argues against its use in Org, IMO.

My suggestion is to use the TeX command \cr.

Or, define a command in the exported latex, something like

\newcommand{\orgcr}{\cr}

and end rows in a table with \orgcr.

Someone who really wants \\ with its variations can redefine \orgcr and
everyone else can just enjoy the simplicity of Org.

Leo


[BUG] beamer export

2022-09-28 Thread Leo Butler
The following Org document shows a bug in the beamer exporter.

#+TITLE: Writing Beamer presentations in org-mode
#+AUTHOR:Eric S Fraga
#+AUTHOR:(bug report by Leo Butler)
#+EMAIL: e.fr...@ucl.ac.uk
#+DATE:  2010-03-30 Tue
#+DESCRIPTION: 
#+KEYWORDS: 
#+LANGUAGE:  en
#+OPTIONS:   H:2 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 
path:https://orgmode.org/org-info.js
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+HTML_LINK_UP:
#+HTML_LINK_HOME:
#+LATEX_COMPILER: lualatex
#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]
#+COLUMNS: %40ITEM %10BEAMER_env(Env) %9BEAMER_envargs(Env Args) 
%4BEAMER_col(Col) %10BEAMER_extra(Extra)


* A Bug Report about the Beamer Tutorial

** 
#+begin_src elisp :exports both
(org-version)
#+end_src

#+RESULTS:
: 9.5.2

** The bug
The [[https://orgmode.org/worg/exporters/beamer/tutorial.html][Beamer tutorial 
by Eric Fraga]]
([[https://orgmode.org/worg/exporters/beamer/tutorial.html]]) has an
example that shows how to create a two column frame using org. The
first column is not identified, though.

** The Org code
Here is the org code.
\tiny
#+begin_src org :exports code
  ,** Two columns
  ,*** A block   :B_ignoreheading:BMCOL:
  :PROPERTIES:
  :BEAMER_env: ignoreheading
  :BEAMER_col: 0.4
  :END:
  - this slide consists of two columns
  - the first (left) column has no heading and consists of text
  - the second (right) column has an image and is enclosed in an
@example@ block

  ,*** A screenshot:BMCOL:B_example:
  :PROPERTIES:
  :BEAMER_col: 0.6
  :BEAMER_env: example
  :END:
  ,#+ATTR_LaTeX: :width \textwidth
  [[./a-simple-slide.png]]
#+end_src

** The \LaTeX{} code
Here is the generated \LaTeX{} code. I needed to add comment characters (%) to 
each line due to a bug in the =verbatim= environment.\pause
\tiny
#+begin_src latex :exports code
  % \begin{frame}[label={sec:orgcc0ebff}]{Two columns}
  % \begin{itemize}
  % \item this slide consists of two columns
  % \item the first (left) column has no heading and consists of text
  % \item the second (right) column has an image and is enclosed in an
  % @example@ block
  % \end{itemize}

  % \begin{column}{0.6\columnwidth}
  % \begin{example}[A screenshot]
  % \begin{center}
  % \includegraphics[width=\textwidth]{./a-simple-slide.png}
  % \end{center}
  % \end{example}
  % \end{column}
  % \end{columns}
  % \end{frame}
#+end_src
\pause\normalsize
The first =itemize= environment should have been wrapped by a =column= 
environment inside the =columns= environment.


Re: table format during html export

2022-02-16 Thread Leo Butler
Juan Manuel MacĂ­as  writes:

> Hi Leo,
>
> Leo Butler writes:
>
>> Hello,
>>
>> I have some tables like
>>
>> | a | b |
>> | c | d |
>>
>> I would like to have this export (in html) to something like
>>
>> | a  b |
>> | c  d |
>>
>> i.e., add a vertical bar on the extreme left and right.
>>
>> I have searched the org manual and online and I can't find a
>> solution.
>>
>> TIA,
>> Leo
>>
>
> You can modify the attributes for a certain table, for example like this:
>
> #+ATTR_HTML: :border 2 :cellspacing 0 :cellpadding 6 :rules none :frame vsides
> | a | b |
> | c | d |
>
> For all tables, you can apply a value to
> `org-html-table-default-attributes', locally or globally:
>
> #+begin_src emacs-lisp
> (setq org-html-table-default-attributes
>   '(:border "2" :cellspacing "0" :cellpadding "6" :rules "none" :frame 
> "vsides"))
> #+end_src

Thank you! That did exactly what I wanted.

Leo



table format during html export

2022-02-15 Thread Leo Butler
Hello,

I have some tables like

| a | b |
| c | d |

I would like to have this export (in html) to something like

| a  b |
| c  d |

i.e., add a vertical bar on the extreme left and right.

I have searched the org manual and online and I can't find a
solution.

TIA,
Leo



<    1   2