Math & ScienceFor some reason, cannot wrap this equation.

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
zimbodel
Posts: 20
Joined: Tue Jul 31, 2018 4:05 am

For some reason, cannot wrap this equation.

Post by zimbodel »

For some reason, I cannot wrap this equation.
I tried align, eqnarray, gather which I used for decades and many more.
What do I do wrong ?

The Latex code is a direct export from Maple and works in the \begin{equation} struct as below.

Code: Select all

\begin{equation}
{\it Q1}={\frac {1}{17920}}\, \left( \sin \left( {\it ts} \right) 
 \right) ^{2}{a}^{6} \left( 54969\,{a}^{2} \left( \cos \left( {\it ts}
 \right)  \right) ^{6}-65627\,{a}^{2} \left( \cos \left( {\it ts}
 \right)  \right) ^{4}-13160\, \left( \cos \left( {\it ts} \right) 
 \right) ^{4}{m}^{2} +21547\, \left( \cos \left( {\it ts} \right) 
 \right) ^{2}{a}^{2} +11200\,{m}^{2} \left( \cos \left( {\it ts}
 \right)  \right) ^{2}-1929\,{a}^{2}+1960\,{m}^{2} \right)
    \end{equation}


However, when I try to wrap the equation using align or eqnarray I get the error that \right is missing and the error refers to the last \right in the equation. I tried to break with eqnarray around &+& 21547 as an example.

Anyone can make this equation wrap by any means without error messages ?
I usually have no problem with this, and this should wrap as the equation has no errors in the example above.

Obviously I must miss something simple.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

For some reason, cannot wrap this equation.

Post by Stefan Kottwitz »

Hi zimbodel,

you can show each try (that gave errors), and we can help fix it, with align, gather, etc. Without seeing it, we cannot tell you what was wrong.

Here's a quick wrapping example with the breqn package and without any change to the equation code.

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{breqn}
\begin{document}
\begin{dmath}
  {\it Q1}={\frac {1}{17920}}\, \left( \sin \left( {\it ts} \right) 
  \right) ^{2}{a}^{6} \left( 54969\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{6}-65627\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{4}-13160\, \left( \cos \left( {\it ts} \right) 
  \right) ^{4}{m}^{2} +21547\, \left( \cos \left( {\it ts} \right) 
  \right) ^{2}{a}^{2} +11200\,{m}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{2}-1929\,{a}^{2}+1960\,{m}^{2} \right)
\end{dmath}
\end{document}
Stefan
LaTeX.org admin
zimbodel
Posts: 20
Joined: Tue Jul 31, 2018 4:05 am

For some reason, cannot wrap this equation.

Post by zimbodel »

Thank you for the kind response.

I sure will post an example of my failed attempts, but want to ask a question about the solution you posted.

Is it possible to add an "align" environment to breqn in order that I can do multiple equations in breqn aligned e.g. for the "=" operator ?
In other words how do I allign these two equations in breqn as I posted as code here.
I want to continue with breqn, but could never get it to work in the past in a multi equation environment. the breqn manual uses dmath to get to work with several equations, but it seems convoluted and feels like a completely different package from breqn. Maybe you have a better way ?
Once I see that breqn cannot do what I want, I will post my align and eqnarray failed attempts as you requested.

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{breqn}
\begin{document}
\begin{dmath}
  {\it Q1}={\frac {1}{17920}}\, \left( \sin \left( {\it ts} \right) 
  \right) ^{2}{a}^{6} \left( 54969\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{6}-65627\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{4}-13160\, \left( \cos \left( {\it ts} \right) 
  \right) ^{4}{m}^{2} +21547\, \left( \cos \left( {\it ts} \right) 
  \right) ^{2}{a}^{2} +11200\,{m}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{2}-1929\,{a}^{2}+1960\,{m}^{2} \right) \\
  {\it Q1}={\frac {1}{17920}}\, \left( \sin \left( {\it ts} \right) 
  \right) ^{2}{a}^{6} \left( 54969\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{6}-65627\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{4}-13160\, \left( \cos \left( {\it ts} \right) 
  \right) ^{4}{m}^{2} +21547\, \left( \cos \left( {\it ts} \right) 
  \right) ^{2}{a}^{2} +11200\,{m}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{2}-1929\,{a}^{2}+1960\,{m}^{2} \right)
\end{dmath}
\end{document}
zimbodel
Posts: 20
Joined: Tue Jul 31, 2018 4:05 am

For some reason, cannot wrap this equation.

Post by zimbodel »

Stefan.
In the end breqn could not do what I need.
It has no way of breaking a long fraction running of the page.
Everything I read online was not helpful either.

So I will return to my align and eqnarry problems.

As an example,
eqnarray (and align} has trouble with last \Left ) that is somehow not recognized.
I can get it to display by placing it in an mbox, but the latex code is valid as it produces no errors in an equation environment, but as soo as it gets aligned in eqnarray there are hordes of errors.

Code: Select all

\begin{eqnarray*}
  {\it Q}&=&{\frac {1}{30001}}\, \left( \sin \left( {\it ts} \right)
  \right) ^{2}{a}^{6} \left( 54969\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{6}-2078\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{4}-13160\,{m}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{4}\\
  &+&11200\,{m}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{2}+21547\, \left( \cos \left( {\it ts} \right)
  \right) ^{2}{a}^{2}+1960\,{m}^{2}-1929\,{a}^{2} \right) 
  \end{eqnarray*}
Last edited by zimbodel on Tue Jan 03, 2023 7:08 am, edited 1 time in total.
zimbodel
Posts: 20
Joined: Tue Jul 31, 2018 4:05 am

For some reason, cannot wrap this equation.

Post by zimbodel »

And, the same equation in an equation environment which throws no errors.

Code: Select all

\begin{equation}
  {\it Q}={\frac {1}{30001}}\, \left( \sin \left( {\it ts} \right)
  \right) ^{2}{a}^{6} \left( 54969\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{6}-2078\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{4}-13160\,{m}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{4}+11200\,{m}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{2}+21547\, \left( \cos \left( {\it ts} \right)
  \right) ^{2}{a}^{2}+1960\,{m}^{2}-1929\,{a}^{2} \right)   
  \end{equation}
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

For some reason, cannot wrap this equation.

Post by rais »

Happy New Year,

a \left/\right pair cannot be broken across lines. Here, you even have to stay within a, hmm, cell of the eqnarray/align environment, i.e., from line's beginning to first &, between two consecutive & characters, or from last & to line's end.
In order to balance the left/right pairings, use \right. before you start a new line and \left. at the beginning of the cell where your term continues. Both (notice the dot) won't produce any output, but they will adapt the level of nesting.

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{eqnarray*}
  {\it Q}&=&{\frac {1}{30001}}\, \left( \sin \left( {\it ts} \right)
  \right) ^{2}{a}^{6} \left( 54969\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{6}-2078\,{a}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{4}-13160\,{m}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{4} \right.\\
  &+&\left. 11200\,{m}^{2} \left( \cos \left( {\it ts}
  \right)  \right) ^{2}+21547\, \left( \cos \left( {\it ts} \right)
  \right) ^{2}{a}^{2}+1960\,{m}^{2}-1929\,{a}^{2} \right) 
  \end{eqnarray*}
\end{document}
In a more complicated scenario, you may additionally need \vphantom to get matching heights of the left/right pair that got broken across lines...

KR
Rainer
zimbodel
Posts: 20
Joined: Tue Jul 31, 2018 4:05 am

For some reason, cannot wrap this equation.

Post by zimbodel »

Thank you very much.
That is very helpful
Post Reply