# wrapping an arbitrary lon equation

In sage with the latex function, the question of getting an equation wrapped into multiple lines has been largely covered for all the cases where you know exatly what your equation will look like. My issue is when the equation can be insanely long without any way to control it, as it's part of a different process. I'll appreciate hints or even solutions from those who have been thru or may be from who's got an idea. Many thx in advance. ps: anything that works with overleaf and/or texShop (whatever this may require) is more than welcome M

As an example :

a=set([3,9,11,23])
print(latex(Permutations(a).list()))
print(latex(Combinations(a,3).list()))


One can see that for this very basic example that the content do not wrap. What am I doing wrong ? any hints? thx in advance M ps: In practice I just send the print to a file. here the purpose is to show what I'm talking about. Hope it make sens. ps: ENV = Montery (MacOS) + sagemath 9.7 + overleaf + TexShop

edit retag close merge delete

Sort by ยป oldest newest most voted

There is probably no "general" xolution to your problem. breqn attempt this for "regular" mathematical expression, but I'm not convinced it would work with your case (yourv permutation elements are not regular LaTeX "math ob jects...

Possible workaround in your specific case :

sage: a=set([3, 9, 11, 23])
sage: print("\\begin{verbatim}\n%s\n\\end{verbatim}"%"\n".join([str(u) for u in Permutations(a)]))
\begin{verbatim}
[11, 9, 3, 23]
[11, 9, 23, 3]


[ Snip... ]

[23, 3, 11, 9]
[23, 3, 9, 11]
\end{verbatim}


Otherwise, SageTeX may be your friend...

more

Thx Emmanuel for this answer. In fact this is what I'm doing thru appropriate formatting however I do not benefit from the full line width. It look like I need to develop a specific function that splits the expressions based on the length .... this will not look correct but at least i'll be able to see the results:equations.

( 2023-01-04 23:44:48 +0100 )edit