1

There is the package breqn for automatically breaking long math equations. I have used it, but there is a little problem that I am facing with it. When we have two different long equations that we need to separate using \\ as we do in the align environment and have aligned them using &, an error shows up. What possibly could be done so that we can take advantage of the breqn package, similar to what is provided in the align environment.

Here is the code:

\documentclass[fleqn,preprint,10pt]{elsarticle}
\usepackage{amsmath}
\usepackage{breqn}
%\setkeys{breqn}{breakdepth={1}}
\begin{document}

\begin{dmath*}
\tilde{a}_{1}=a_{{10}}\epsilon_{{6}}\epsilon_{{8}}\epsilon_{{2}}-a_{{3}}\epsilon_{{
11}}\epsilon_{{9}}\epsilon_{{2}}-2\,a_{{3}}\epsilon_{{6}}\epsilon_{{8}
}\epsilon_{{2}}+2\,a_{{10}}\epsilon_{{6}}\epsilon_{{8}}\epsilon_{{9}}-
4\,a_{{3}}\epsilon_{{6}}\epsilon_{{8}}\epsilon_{{9}}+{{\rm e}^{
\epsilon_{{3}}}}a_{{11}}\epsilon_{{9}}\epsilon_{{2}}-{{\rm e}^{2\,
\epsilon_{{10}}-2\,\epsilon_{{3}}}}a_{{8}}\epsilon_{{6}}\epsilon_{{2}}
-{{\rm e}^{\epsilon_{{10}}-\epsilon_{{3}}}}a_{{9}}\epsilon_{{11}}
\epsilon_{{2}}-{{\rm e}^{\epsilon_{{10}}-\epsilon_{{3}}}}a_{{2}}
\epsilon_{{6}}\epsilon_{{5}}+{{\rm e}^{2\,\epsilon_{{3}}-\epsilon_{{10
}}}}a_{{6}}\epsilon_{{8}}\epsilon_{{2}}-{{\rm e}^{\epsilon_{{10}}-
\epsilon_{{3}}}}a_{{2}}\epsilon_{{6}}{\epsilon_{{9}}}^{2}-2\,{{\rm e}^
{\epsilon_{{10}}-\epsilon_{{3}}}}a_{{9}}\epsilon_{{7}}-{{\rm e}^{3\,
\epsilon_{{10}}-3\,\epsilon_{{3}}}}a_{{4}}\epsilon_{{6}}+{{\rm e}^{2\,
\epsilon_{{3}}-\epsilon_{{10}}}}a_{{6}}\epsilon_{{4}}-{{\rm e}^{2\,
\epsilon_{{10}}-2\,\epsilon_{{3}}}}a_{{5}}\epsilon_{{11}}-{{\rm e}^{
\epsilon_{{10}}-\epsilon_{{3}}}}a_{{2}}\epsilon_{{7}}-2\,{{\rm e}^{
\epsilon_{{10}}-\epsilon_{{3}}}}a_{{9}}\epsilon_{{11}}\epsilon_{{9}}-2
\,{{\rm e}^{2\,\epsilon_{{10}}-2\,\epsilon_{{3}}}}a_{{8}}\epsilon_{{6}
}\epsilon_{{9}}+{{\rm e}^{2\,\epsilon_{{10}}-\epsilon_{{3}}}}a_{{1}}+2
\,{{\rm e}^{2\,\epsilon_{{3}}-\epsilon_{{10}}}}a_{{6}}\epsilon_{{8}}
\epsilon_{{9}}-{{\rm e}^{\epsilon_{{10}}-\epsilon_{{3}}}}a_{{2}}
\epsilon_{{6}}\epsilon_{{9}}\epsilon_{{2}}-2\,a_{{10}}\epsilon_{{1}}+a
_{{3}}\epsilon_{{1}}+{{\rm e}^{\epsilon_{{3}}}}a_{{11}}\epsilon_{{5}}+
2\,{{\rm e}^{\epsilon_{{10}}}}a_{{7}}\epsilon_{{9}}+{{\rm e}^{\epsilon
_{{3}}}}a_{{11}}{\epsilon_{{9}}}^{2}+a_{{10}}\epsilon_{{6}}\epsilon_{{
4}}-2\,a_{{10}}\epsilon_{{7}}\epsilon_{{9}}-a_{{3}}\epsilon_{{11}}
\epsilon_{{5}}-a_{{3}}{\epsilon_{{9}}}^{2}\epsilon_{{11}}+{{\rm e}^{
\epsilon_{{10}}}}a_{{7}}\epsilon_{{2}}-2\,a_{{3}}\epsilon_{{6}}
\epsilon_{{4}}-a_{{10}}\epsilon_{{7}}\epsilon_{{2}},\\
\tilde{a}_{2}=\,-a_{{10}}\epsilon_{{2}}+a_{{3}}\epsilon_{{2}}+{{\rm e}^{\epsilon_{{10}
}-\epsilon_{{3}}}}a_{{2}}\\
\tilde{a_{3}}=\,-{{\rm e}^{\epsilon_{{10}}-\epsilon_{{3}}}}{\epsilon}^{2}a_{{9}}-{
{\rm e}^{2\,\epsilon_{{10}}-2\,\epsilon_{{3}}}}a_{{5}}\epsilon_{{2}}+2
\,{{\rm e}^{\epsilon_{{10}}-\epsilon_{{3}}}}a_{{2}}\epsilon_{{9}}
\epsilon_{{2}}+2\,a_{{3}}\epsilon_{{8}}\epsilon_{{2}}-2\,a_{{10}}
\epsilon_{{8}}\epsilon_{{2}}+2\,a_{{10}}\epsilon_{{5}}\epsilon_{{2}}-2
\,a_{{3}}\epsilon_{{5}}\epsilon_{{2}}+{{\rm e}^{\epsilon_{{10}}-
\epsilon_{{3}}}}a_{{2}}{\epsilon_{{9}}}^{2}+{{\rm e}^{\epsilon_{{10}}-
\epsilon_{{3}}}}a_{{2}}\epsilon_{{5}}+{{\rm e}^{2\,\epsilon_{{10}}-2\,
\epsilon_{{3}}}}a_{{8}}\epsilon_{{2}}+2\,{{\rm e}^{2\,\epsilon_{{10}}-
2\,\epsilon_{{3}}}}a_{{8}}\epsilon_{{9}}-2\,{{\rm e}^{\epsilon_{{10}}-
\epsilon_{{3}}}}a_{{9}}\epsilon_{{8}}-{{\rm e}^{\epsilon_{{10}}-
\epsilon_{{3}}}}a_{{2}}\epsilon_{{8}}+4\,a_{{3}}\epsilon_{{8}}\epsilon
_{{9}}-4\,a_{{10}}\epsilon_{{8}}\epsilon_{{9}}-{\epsilon}^{2}a_{{3}}
\epsilon_{{9}}+{\epsilon}^{2}a_{{10}}\epsilon_{{9}}+{{\rm e}^{3\,
\epsilon_{{10}}-3\,\epsilon_{{3}}}}a_{{4}}+3\,a_{{3}}\epsilon_{{4}}-3
\,a_{{10}}\epsilon_{{4}}
\end{dmath*}
Now see following using environment using align
\begin{align*}
\tilde{a}_{1}=&\,a_{{10}}\epsilon_{{6}}\epsilon_{{8}}\epsilon_{{2}}-a_{{3}}\epsilon_{{
11}}\epsilon_{{9}}\epsilon_{{2}}-2\,a_{{3}}\epsilon_{{6}}\epsilon_{{8}
}\epsilon_{{2}}+2\,a_{{10}}\epsilon_{{6}}\epsilon_{{8}}\epsilon_{{9}}-
4\,a_{{3}}\epsilon_{{6}}\epsilon_{{8}}\epsilon_{{9}}+{{\rm e}^{
\epsilon_{{3}}}}a_{{11}}\epsilon_{{9}}\epsilon_{{2}}\\
&-{{\rm e}^{2\,
\epsilon_{{10}}-2\,\epsilon_{{3}}}}a_{{8}}\epsilon_{{6}}\epsilon_{{2}}
-{{\rm e}^{\epsilon_{{10}}-\epsilon_{{3}}}}a_{{9}}\epsilon_{{11}}
\epsilon_{{2}}-{{\rm e}^{\epsilon_{{10}}-\epsilon_{{3}}}}a_{{2}}
\epsilon_{{6}}\epsilon_{{5}}+{{\rm e}^{2\,\epsilon_{{3}}-\epsilon_{{10
}}}}a_{{6}}\epsilon_{{8}}\epsilon_{{2}}\\
&-{{\rm e}^{\epsilon_{{10}}-
\epsilon_{{3}}}}a_{{2}}\epsilon_{{6}}{\epsilon_{{9}}}^{2}-2\,{{\rm e}^
{\epsilon_{{10}}-\epsilon_{{3}}}}a_{{9}}\epsilon_{{7}}-{{\rm e}^{3\,
\epsilon_{{10}}-3\,\epsilon_{{3}}}}a_{{4}}\epsilon_{{6}}+{{\rm e}^{2\,
\epsilon_{{3}}-\epsilon_{{10}}}}a_{{6}}\epsilon_{{4}}-{{\rm e}^{2\,
\epsilon_{{10}}-2\,\epsilon_{{3}}}}a_{{5}}\epsilon_{{11}}\\
&-{{\rm e}^{
\epsilon_{{10}}-\epsilon_{{3}}}}a_{{2}}\epsilon_{{7}}-2\,{{\rm e}^{
\epsilon_{{10}}-\epsilon_{{3}}}}a_{{9}}\epsilon_{{11}}\epsilon_{{9}}-2
\,{{\rm e}^{2\,\epsilon_{{10}}-2\,\epsilon_{{3}}}}a_{{8}}\epsilon_{{6}
}\epsilon_{{9}}+{{\rm e}^{2\,\epsilon_{{10}}-\epsilon_{{3}}}}a_{{1}}\\&+2
\,{{\rm e}^{2\,\epsilon_{{3}}-\epsilon_{{10}}}}a_{{6}}\epsilon_{{8}}
\epsilon_{{9}}-{{\rm e}^{\epsilon_{{10}}-\epsilon_{{3}}}}a_{{2}}
\epsilon_{{6}}\epsilon_{{9}}\epsilon_{{2}}-2\,a_{{10}}\epsilon_{{1}}+a
_{{3}}\epsilon_{{1}}+{{\rm e}^{\epsilon_{{3}}}}a_{{11}}\epsilon_{{5}}\\&+
2\,{{\rm e}^{\epsilon_{{10}}}}a_{{7}}\epsilon_{{9}}+{{\rm e}^{\epsilon
_{{3}}}}a_{{11}}{\epsilon_{{9}}}^{2}+a_{{10}}\epsilon_{{6}}\epsilon_{{
4}}-2\,a_{{10}}\epsilon_{{7}}\epsilon_{{9}}\\&-a_{{3}}\epsilon_{{11}}
\epsilon_{{5}}-a_{{3}}{\epsilon_{{9}}}^{2}\epsilon_{{11}}+{{\rm e}^{
\epsilon_{{10}}}}a_{{7}}\epsilon_{{2}}-2\,a_{{3}}\epsilon_{{6}}
\epsilon_{{4}}-a_{{10}}\epsilon_{{7}}\epsilon_{{2}},\\
\tilde{a}_{2}=&\,-a_{{10}}\epsilon_{{2}}+a_{{3}}\epsilon_{{2}}+{{\rm e}^{\epsilon_{{10}
}-\epsilon_{{3}}}}a_{{2}}\\
\tilde{a_{3}}=&\,-{{\rm e}^{\epsilon_{{10}}-\epsilon_{{3}}}}{\epsilon}^{2}a_{{9}}-{
{\rm e}^{2\,\epsilon_{{10}}-2\,\epsilon_{{3}}}}a_{{5}}\epsilon_{{2}}+2
\,{{\rm e}^{\epsilon_{{10}}-\epsilon_{{3}}}}a_{{2}}\epsilon_{{9}}
\epsilon_{{2}}+2\,a_{{3}}\epsilon_{{8}}\epsilon_{{2}}-2\,a_{{10}}
\epsilon_{{8}}\epsilon_{{2}}\\
&+2\,a_{{10}}\epsilon_{{5}}\epsilon_{{2}}-2
\,a_{{3}}\epsilon_{{5}}\epsilon_{{2}}+{{\rm e}^{\epsilon_{{10}}-
\epsilon_{{3}}}}a_{{2}}{\epsilon_{{9}}}^{2}+{{\rm e}^{\epsilon_{{10}}-
\epsilon_{{3}}}}a_{{2}}\epsilon_{{5}}+{{\rm e}^{2\,\epsilon_{{10}}-2\,
\epsilon_{{3}}}}a_{{8}}\epsilon_{{2}}+2\,{{\rm e}^{2\,\epsilon_{{10}}-
2\,\epsilon_{{3}}}}a_{{8}}\epsilon_{{9}}\\
&-2\,{{\rm e}^{\epsilon_{{10}}-
\epsilon_{{3}}}}a_{{9}}\epsilon_{{8}}-{{\rm e}^{\epsilon_{{10}}-
\epsilon_{{3}}}}a_{{2}}\epsilon_{{8}}+4\,a_{{3}}\epsilon_{{8}}\epsilon
_{{9}}-4\,a_{{10}}\epsilon_{{8}}\epsilon_{{9}}-{\epsilon}^{2}a_{{3}}
\epsilon_{{9}}+{\epsilon}^{2}a_{{10}}\epsilon_{{9}}\\
&+{{\rm e}^{3\,
\epsilon_{{10}}-3\,\epsilon_{{3}}}}a_{{4}}+3\,a_{{3}}\epsilon_{{4}}-3
\,a_{{10}}\epsilon_{{4}}
\end{align*}
Basically what I want to do is to use dmath environment just like above.
\end{document}
  • "An error shows up" -- please tell us what the error message says. (For what it's worth, I get no error message when compiling your code.) – Mico Apr 22 '16 at 5:43
  • Actually In my code there are 3 equations that I want to align like one does in "\begin{align}......\end{align}" environment using ampersand sign "&". You can see $\tilde{a_{1}}$, $\tilde{a_{2}}$ and $\tilde{a_{3}}$ are not aligned. – IgotiT Apr 22 '16 at 5:51
  • Welcome to the site! This is a considerable wall of code, you might get a better response if you simplified things down a little for us! – Au101 Apr 22 '16 at 5:57
  • The question is modified. Please see comparison of "dmath" and "align". – IgotiT Apr 22 '16 at 6:19
1

You could insert \nobreak instructions after \tilde{a}_{2} and \tilde{a_{3}}, respectively. (The latter expression should probably be \tilde{a}_{3}, right?)

5

What you are looking for is dgroup. If you want to align several equations, you put each of them in a dmath environment and all the dmath environments are put inside a dgroup environment. Nobody will have understood this last sentence, but the following example will make it clear.

\documentclass{article}
\usepackage{breqn}
% Macro for Euler's number
\newcommand*\ee{\mathrm{e}}
\begin{document}

\begin{dgroup*}
  \begin{dmath*}
    \tilde{a}_{1}
    = a_{10} \epsilon_6 \epsilon_8 \epsilon_2
    - a_3 \epsilon_{11} \epsilon_9 \epsilon_2
    - 2 a_3 \epsilon_6 \epsilon_8 \epsilon_2
    + 2 a_{10} \epsilon_6 \epsilon_8 \epsilon_9
    - 4 a_3 \epsilon_6 \epsilon_8 \epsilon_9
    + \ee^{\epsilon_3} a_{11} \epsilon_9 \epsilon_2
    - \ee^{2 \epsilon_{10} - 2 \epsilon_3} a_8 \epsilon_6 \epsilon_2
    - \ee^{\epsilon_{10}-\epsilon_3} a_9\epsilon_{11} \epsilon_2
    - \ee^{\epsilon_{10}-\epsilon_3} a_2 \epsilon_6 \epsilon_5
    + \ee^{2 \epsilon_3 - \epsilon_{10}} a_6 \epsilon_8 \epsilon_2
    - \ee^{\epsilon_{10} - \epsilon_3} a_2 \epsilon_6 \epsilon_9^2
    - 2 \ee^{\epsilon_{10}-\epsilon_3} a_9 \epsilon_7
    - \ee^{3 \epsilon_{10} - 3 \epsilon_3} a_4 \epsilon_6
    + \ee^{2 \epsilon_3 - \epsilon_{10}} a_6 \epsilon_4
    - \ee^{2 \epsilon_{10} - 2 \epsilon_3} a_5 \epsilon_{11}
    - \ee^{\epsilon_{10} - \epsilon_3} a_2 \epsilon_7
    - 2 \ee^{\epsilon_{10} - \epsilon_3} a_9 \epsilon_{11} \epsilon_9
    - 2 \ee^{2 \epsilon_{10} - 2 \epsilon_3} a_8 \epsilon_6 \epsilon_9
    + \ee^{2 \epsilon_{10} - \epsilon_3} a_1
    + 2 \ee^{2 \epsilon_3 - \epsilon_{10}} a_6 \epsilon_8 \epsilon_9
    - \ee^{\epsilon_{10} - \epsilon_3} a_2 \epsilon_6 \epsilon_9 \epsilon_2
    - 2 a_{10} \epsilon_1
    + a_3 \epsilon_1
    + \ee^{\epsilon_3} a_{11} \epsilon_5
    + 2 \ee^{\epsilon_{10}} a_7 \epsilon_9
    + \ee^{\epsilon_3} a_{11} \epsilon_9^2
    + a_{10} \epsilon_6 \epsilon_4
    - 2 a_{10} \epsilon_7 \epsilon_9
    - a_3 \epsilon_{11} \epsilon_5
    - a_3 \epsilon_9^2 \epsilon_{11}
    + \ee^{\epsilon_{10}} a_7 \epsilon_2
    - 2 a_3 \epsilon_6 \epsilon_4
    - a_{10} \epsilon_7 \epsilon_2 ,
  \end{dmath*}
  \begin{dmath*}
    \tilde{a}_2
    = - a_{10} \epsilon_2
    + a_3 \epsilon_2
    + \ee^{\epsilon_{10} - \epsilon_3} a_2
  \end{dmath*}
  \begin{dmath*}
    \tilde{a}_3
    = - \ee^{\epsilon_{10} - \epsilon_3} \epsilon^2 a_9
    - \ee^{2 \epsilon_{10} - 2 \epsilon_3} a_5 \epsilon_2
    + 2 \ee^{\epsilon_{10} - \epsilon_3} a_2 \epsilon_9 \epsilon_2
    + 2 a_3 \epsilon_8 \epsilon_2
    - 2 a_{10} \epsilon_8 \epsilon_2
    + 2 a_{10} \epsilon_5 \epsilon_2
    - 2 a_3 \epsilon_5 \epsilon_2
    + \ee^{\epsilon_{10} - \epsilon_3} a_2 \epsilon_9^2
    + \ee^{\epsilon_{10} - \epsilon_3} a_2 \epsilon_5
    + \ee^{2 \epsilon_{10} - 2 \epsilon_3} a_8 \epsilon_2
    + 2 \ee^{2 \epsilon_{10} - 2 \epsilon_3} a_8 \epsilon_9
    - 2 \ee^{\epsilon_{10} - \epsilon_3} a_9 \epsilon_8
    - \ee^{\epsilon_{10} - \epsilon_3} a_2 \epsilon_8
    + 4 a_3 \epsilon_8 \epsilon_9
    - 4 a_{10} \epsilon_8 \epsilon_9
    - \epsilon^2 a_3 \epsilon_9
    + \epsilon^2 a_{10} \epsilon_9
    + \ee^{3 \epsilon_{10} - 3 \epsilon_3} a_4
    + 3 a_3 \epsilon_4
    - 3 a_{10} \epsilon_4
  \end{dmath*}
\end{dgroup*}

\end{document}

enter image description here

  • +1 for removing all unnecessary curly braces and thinspaces and for the \ee macro. :-) – Mico Apr 22 '16 at 7:29
  • 2
    @Mico RegEx wins ;-) – Henri Menke Apr 22 '16 at 7:30
  • 3
    Ah man, the legibility of that code you have there is amazing. What a difference! :) – Au101 Apr 22 '16 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.