Generate LaTeX from Maxima input - latex

I want to use Maxima to evaluate documents. It's easy to convert Maxima output into TeX:
(%i1) tex(5*x^2+sin(x)+c)$
$$\sin x+5\,x^2+c$$
However, it doesn't work for previously input lines:
(%i2) 5*x^2+sin(x)+c;
2
(%o2) sin(x) + 5 x + c
(%i3) tex(%i2);
\begin{verbatim}
(%i2)sin(x)+5*x^2+c;
\end{verbatim}
(%o3) (%i2)
After much research (including here which is close but no cigar) I've come up empty. Any insights?

Try this.
tex (''%i2);
or
apply (tex, [%i2]);

Related

How to separate lines of a LaTeX eqnarray in Haddock markup?

I can't seem to get this simple LaTeX code, embedded in a Haskell comment, to render properly when run through Haddock with HTML target:
\[
\begin{eqnarray}
y &=& f(x) \\
z &=& g(y)
\end{eqnarray}
\]
When I run the Haskell code containing the above comment through Haddock I see this in my browser:
[ begin{eqnarray} y &=& f(x) z &=& g(y)
end{eqnarray} ]
If I get rid of the double backslash at the end of the third line then both equations render properly, but they appear one after the other on the same line.
Does anyone know the correct way to separate lines of a eqnarray when writing LaTeX intended for Haddock processing?

R markdown inline formula (latex) not working

First time markdown user (and LaTex novice).
I'm trying to insert inline formulas using single $ as I have seen demonstrated in several places, including the R Markdown Reference Guide - but it's not working.
inline equation test: $x \leq 5 $ not working
is simply output as
"inline equation test: $x 5 $ not working"
It works fine using $$ to create a new line, but any tips how to get it working inline would be much appreciated.
And as so often happens, as soon as I ask a question, the answer comes to me.
inline equation test: $x \leq 5 $ not working
has a space before the closing $ and does not work.
inline equation test: $x \leq 5$ not working
has the space deleted and works just fine.

How to align multiple equations in Marp (a tool to convert .md files into PDF)?

I've been trying to find a solution to align multiple equations in Marp (a tool to convert .md files into PDF) but can't find a solution.
I tried using \begin{equation}......\end{equation}(which apparently is not supported in Marp), and various combinations of $....$, $$....$$
but can't find a hack.
I'm trying to generate something like :
but instead I get this:
here is my code:
$$ E_{\theta}[\theta] = \int_{\theta}\theta\ p(\theta)\ d\theta $$
$$ E_D[E_{\theta}[\theta|D]] = \int_D\Bigg\{\int_{\theta}\theta\ p(\theta|D)\ d\theta \Bigg\}\ p(D)\ dD $$
What am I missing. There is a solution for R Markdown, but I'm not sure if Marp supports R Markdown. I also can't find a way to import packages in Marp too.
Please help. Thanks.
Put $$ at the start and end of the equations - but not after each each equation.
Then separate each equation with \\.
Put an & before each equals (where you want it to align)
Use the \begin{aligned} and \end{aligned} function.
Here is a simple example:
$$\begin{aligned} 1 + 2 + 3 + 4 &= 10 \\
20 \times 80 &= 1600 \end{aligned}$$
Here is your example in this format:
$$\begin{aligned}E_{\theta}[\theta] &= \int_{\theta}\theta\ p(\theta)\ d\theta \\
E_D[E_{\theta}[\theta|D]] &= \int_D\Bigg\{\int_{\theta}\theta\ p(\theta|D)\ d\theta \Bigg\}\ p(D)\ dD \end{aligned}$$
These these examples when rendered:
math-alignement-results

How to output every `log` as `ln` in tex output in maxima?

So I tried
texput(%e, "\e"); texput(log, "\\ln");
But if I call the tex function:
tex(%e*log(3));
This gives:
$$\e\,\log 3$$
But I actually expected:
$$\e\,\ln 3$$
So my question is how to output every log as ln in tex output in maxima? Is that possible with texput?
Two things here, which are both completely not obvious; sorry about that. (1) Need to say nounify(log) and not just log in the call to texput. This is because log(3) is a so-called noun expression (as opposed to a verb expression). (2) Need to say prefix in the call to texput since log is typeset as a prefix operator in TeX.
(%i1) texput (nounify(log), "\\ln", prefix);
(%o1) \ln
(%i2) tex(log(3));
$$\ln3$$
(%o2) false
Oh, looks like we need a trailing space to separate the \ln from the 3.
(%i3) texput (nounify(log), "\\ln ", prefix);
(%o3) \ln
(%i4) tex(log(3));
$$\ln 3$$
(%o4) false
That seems to work as expected.

How to remove TeX displayed equation markups from the output of Maxima tex?

How to remove all $ signs from the output of, e.g., tex(x^2-5*x+6); ?
This question is more related to Maxima so I post it here.
Just use tex1 instead of tex. This way the output won't be enclosed inside $$ delimiters. You can find more details on these matters in the Maxima reference.
Writing set_tex_environment_default( "", "" ); in your script would do the same.
From maxima manual
(%i1) get_tex_environment_default ();
(%o1) [$$, $$]
(%i2) tex (f(x) + g(x));
$$g\left(x\right)+f\left(x\right)$$
(%o2) false
(%i3) set_tex_environment_default ("\\begin{equation}
", "
\\end{equation}");
(%o3) [\begin{equation}
,
\end{equation}]
(%i4) tex (f(x) + g(x));
\begin{equation}
g\left(x\right)+f\left(x\right)
\end{equation}
(%o4) false

Resources