|
From: Robert D. <rob...@gm...> - 2024-05-03 17:13:59
|
On Fri, May 3, 2024 at 2:35 AM Foad Sojoodi Farimani
<f.s...@gm...> wrote:
> Could anyone provide guidance on how to properly format Greek letters in the .mac/.mc files for correct LaTeX rendering, or point me towards a command in Maxima that outputs LaTeX code directly?
Foad, I use Maxima a lot to generate TeX documents. ?? tex at the
Maxima console input prompt will find several relevant functions.
As you have found, sigma_x is not output as expected (with x being a
subscript) by the tex function. One solution is to write sigma[x],
however, that implies replacing every existing use of sigma_x in your
program. That might or might not be what you want; an alternative is
to say texput(sigma_x, "\\sigma_x") so that just 'sigma_x' is output.
I often write stuff like this. Let's say this is foo.mac. You can see
a couple of things there: double backslash to make one backslash in a
string, end of line in a string is OK, with_stdout captures print and
tex output (also printf which is not shown in this example).
with_stdout ("mydocument.tex",
print ("\\documentclass{article}
\\begin{document}
Here's my first equation.
"),
tex (F = m*a^2),
print ("Another hoary old chestnut.
"),
tex (F = G*m[1]*m[2]/norm(r[2] - r[1])^2),
print ("Well, that's all for today.
\\end{document}
"));
After maxima -b foo.mac, I see that Maxima rearranges the order of
terms from what I wrote, and tex doesn't seem to know about norm. I'll
say simp: false to inhibit term reordering (and all other identities),
and texput to assign a suitable output for norm.
texput (norm, ["\\|", "\\|"], matchfix);
simp: false $
with_stdout ("mydocument.tex",
print ("\\documentclass{article}
\\begin{document}
Here's my first equation.
"),
tex (F = m*a^2),
print ("Another hoary old chestnut.
"),
tex (F = G*m[1]*m[2]/norm(r[2] - r[1])^2),
print ("Well, that's all for today.
\\end{document}
"));
Term reordering is a vexing problem for TeX output -- simp: false is a
heavy-handed solution.
Hope this helps in some way,
Robert
|