3

First of all, apologies if there is an answer for this already.

I'm outputting symbolic results from Maxima using tex(<output>,"filename")$, which leaves me with an expression with $$ on each end (not to mention some \it{} and some \over{}, and maybe more new things to come).

I wanted to put it in an equation environment like,

\begin{equation*}
\input{filename.tex}
\end{equation*}

but that didn't work due to the clash of $$ I guess. Also I tried Maxima's stringy one, tex1() but I'd have to deal with the quotation marks surrounding it, as well as the ending semicolon.

So I gave up, for now, on breaking these very long equations up - though I'd like to! - and just set the page/paper width very, very large. Yuck.

This lead me to my current dislike, that some equations are short and some are long causes me to have to scroll around horizontally a lot - because they are all center justified.

On other pages on tex.SE I saw fleqn options in amsmath and amsart, as well as a \setlength{mathindent}{0in}, but nothing successfully worked.

Maybe I should go back to breaking them up, but that still doesn't let me easily deal with putting them in a math/equation environment... right?

Thank you!

P.S. I typically use lualatex and amsart, but this is pretty generic report, which explains my simple code:

\documentclass[fleqn]{amsart} %{standalone}
\usepackage[paperheight=10.75in,paperwidth=72.25in,margin=1in,heightrounded,showframe]{geometry}
\usepackage{amsmath}
\title{Maxima Results}
\begin{document}
\setlength{mathindent}{0pt}
\input{w02z0z111.tex}
\end{document}

Here is a very short result;

$$-{{310779087585246720\,i\,{\it z_0}^{14}+658160092626831360\,i\,
 {\it z_0}^{12}+21158324305920\,i\,{\it z_0}^{10}-380849837506560\,i
 \,{\it z_0}^8-174482709120\,i\,{\it z_0}^6-7971615\,i\,{\it z_0}^2-
 344373768\,i}\over{128\,3^{{{31}\over{2}}}\,{\it z_0}^4}}-{{
 41070158964605941940\,3^{{{9}\over{2}}}\,i\,{\it z_0}^{10}+
 10503610891673584872960\,{\it z_0}^9+96708129989156081584\,3^{{{9
 }\over{2}}}\,i\,{\it z_0}^8+17258799729306975187968\,{\it z_0}^7+
 162584742938225143616\,3^{{{9}\over{2}}}\,i\,{\it z_0}^6+
 19235016466581686759424\,{\it z_0}^5+61703548287898161920\,3^{{{11
 }\over{2}}}\,i\,{\it z_0}^4+13036868175072393805824\,{\it z_0}^3+
 384226900921449405185\,3^{{{7}\over{2}}}\,i\,{\it z_0}^2+
 4059210481688530072224\,{\it z_0}}\over{8748}}$$
Heiko Oberdiek
  • 271,626
nate
  • 835
  • 1
    The Maxima output is very bad TeX code. – egreg Aug 28 '15 at 21:01
  • Are you saying that in general wrt Maxima, or this particular output? – nate Aug 28 '15 at 21:08
  • The formula consists of two fractions with extremely long numerators. It's also very awkwardly coded, which makes it impossible to try massaging it and find some way for getting it to fit a normal page. The {\it z_0} bits are the least of your problems. – egreg Aug 28 '15 at 21:15
  • Aaahhh, yeah I figured it was nearly pointless... also ridiculous to document but the boss wants what the boss wants ;) Maybe I should reword my question, for something useful, to say "How to incorporate tex from an input{} into a math environment?" This at least would be useful to others and I can try massaging these results myself in Maxima... – nate Aug 28 '15 at 21:20

3 Answers3

2

You can get breaking at binary operations at the top level with some tricks.

  1. In the equation environment open a minipage
  2. Neutralize $ so it's not interpreted any more
  3. The minipage contains an inline formula in \displaystyle, with a \raggedright setting
\documentclass{amsart} %{standalone}
\usepackage{amsmath}

\newcommand{\maximainput}[1]{%
  \begin{equation}
  \begin{minipage}{.9\columnwidth}
  \raggedright\catcode`$=9 % ignore $
  $\displaystyle\input{#1}$
  \end{minipage}
  \end{equation}
}

\title{Maxima Results}
\begin{document}

\maximainput{w02z0z111.tex}

\end{document}

In the example case you get nothing really useful, because the formula consists of two fractions with very long numerator. If the fractions were coded as

\frac{1}{<denominator>}\bigl(<numerator>\bigr)

the numerators could be split across lines.

As you note, {\it z_0} is appallingly wrong, you can add \let\it\relax after \raggedright to nullify it.

egreg
  • 1,121,712
  • I used your example and the justification now works great! Thinking of incorporating breqn somehow... Should I clean up the question and re-title it to be relevant? – nate Aug 28 '15 at 23:28
2

Minor point: By default, Maxima writes "$$" before and after its TeX output, but you can change that. For example:

set_tex_environment_default ("\\begin{equation}", "\\end{equation}");

or to delete them entirely:

set_tex_environment_default ("","");
1

The code of the Maxima output is dead ugly. The $$ can be stripped by reading the file in a macro first (package catchfile) and removing the $$ via package regexpatch. Also the equation can be squeezed into the line via package resizegather. But because of the lengthy equation, the equation is decreased much too much:

\documentclass[fleqn]{amsart} %{standalone}
\usepackage[
%  paperheight=10.75in,
%  paperwidth=72.25in,
  margin=1in,
  heightrounded,
%  showframe
]{geometry}
\usepackage{amsmath}
\usepackage{catchfile}
\usepackage{regexpatch}
\usepackage{resizegather}
\title{Maxima Results}
\begin{document}
\setlength{\mathindent}{0pt}
\CatchFileDef\MaximaText{w02z0z111.tex}{\endlinechar=-1 }
\xpatchcmd*\MaximaText{$$}{}{}{}
\begin{gather*}\relax
\MaximaText
\end{gather*}
\end{document}

Result

You get a better result, when you manually rewrite the equation.

BTW, the non-working \mathindent setting comes from the missing backslash \.

\setlength{\mathindent}{0pt}
Heiko Oberdiek
  • 271,626
  • Oh, thanks for that mathindent comment - missed it. I see your point about the text becoming too small... I wonder if using breqn package should be incorporated... – nate Aug 28 '15 at 23:27