# Formatting maple for latex

I am doing some linear programming in maple, and sometimes the matrices are quite large. I know that maple have a /latex(expression) function, but when I have a vector, that has fractions in it, it outputs:

\left[ \begin {array}{ccccccc} -23&0&0&-1&-8/3&0&-1/3
\\ \noalign{\medskip}9/2&1&0&1&2/3&0&-1/6\\ \noalign{\medskip}7/2&0&1&
1&1/3&0&1/6\\ \noalign{\medskip}3&0&0&3&-1/3&1&1/3\end {array}
\right]


There are many things wrong with this, first of all when you copy+paste this into latex, it does not work since there is no space after the & also it displays fractions as -1/6 instead of -frac{1}{6}. Is there other packages to export maple to latex, or a way to edit the format of the current one? Hope you guys have the answer :-)

• Related: MaplePrimes: Any alternatives to Maple's LaTeX? -- this has been a long-standing issue with them (since at least 2007). Going to fire up Maple 18 momentarily and see what third-party alternatives look workable. – Mike Renfro Jan 3 '15 at 16:55
• Yeah, this is going to take a while. No idea if there's anything workable in that pile of posts above. – Mike Renfro Jan 3 '15 at 17:07
• Thanks a lot for looking at it, if only maple would be strict about its formatting, sometimes it does use frac and sometime it doesn't.. – Steffen Hvid Jan 4 '15 at 13:21
• I'm not enough of a Maple user to come up with a good answer, but here's what I got somewhat working: this answer from Joe Riehl applies regular expression substitutions to Maple's built-in LaTeX output. John Fredsted's sample is a good stress test. The _LatexSmallFractionConstant variable controls when \frac is used. Set it to 0 to force it all the time, and 50 is the default. – Mike Renfro Jan 4 '15 at 13:42

I think I can help you to solve the problem. You need to delete all strings "\noalign{\medskip}" in your code

It works perfectly:

\left[
\begin {array}{ccccccc}
-23  & 0 & 0 & -1 & -8/3 & 0 & -1/3\\
9/2 & 1 & 0 &  1 &  2/3 & 0 & -1/6\\
7/2 & 0 & 1 &  1 &  1/3 & 0 &  1/6\\
3   & 0 & 0 &  3 & -1/3 & 1 &  1/3
\end{array}\right]


You can test at here: http://www.wiris.com/editor/demo/en/mathml-latex