logo

How to Automatically Break Long Equations and Align by Equals in LaTeX 📂Academic Writing

How to Automatically Break Long Equations and Align by Equals in LaTeX

Code

To automatically break and align long equations, use the breqn package.

dmath

You can place an equation between the opening and closing dmath delimiters; if the equation becomes long it will be automatically line-broken and aligned at the equals sign.

\documentclass{article}
\usepackage{breqn}

\begin{document}

\begin{dmath}
dx = -0.018 x^{2} + 0.023 x y - 0.008 y^{2} + 0.033 x^{3} - 0.083 x^{2} y + 0.065 x y^{2} - 0.012 y^{3} + 0.02 x^{4} - 0.093 x^{3} y + 0.169 x^{2} y^{2} - 0.137 x y^{3} + 0.038 y^{4} - 0.037 x^{5} + 0.192 x^{4} y - 0.412 x^{3} y^{2} + 0.447 x^{2} y^{3} - 0.244 x y^{4} + 0.054 y^{5} + 0.011 x^{6} - 0.066 x^{5} y + 0.173 x^{4} y^{2} - 0.241 x^{3} y^{3} + 0.188 x^{2} y^{4} - 0.077 x y^{5} + 0.013 y^{6}
\end{dmath}

\begin{dmath}
dy = 0.009 + 0.006 x - 0.003 y + 0.005 x^{2} - 0.005 y^{2} - 0.025 x^{3} + 0.073 x^{2} y - 0.086 x y^{2} + 0.034 y^{3} - 0.025 x^{4} + 0.109 x^{3} y - 0.157 x^{2} y^{2} + 0.094 x y^{3} - 0.018 y^{4} + 0.068 x^{5} - 0.362 x^{4} y + 0.771 x^{3} y^{2} - 0.82 x^{2} y^{3} + 0.439 x y^{4} - 0.095 y^{5} - 0.027 x^{6} + 0.175 x^{5} y - 0.472 x^{4} y^{2} + 0.677 x^{3} y^{3} - 0.547 x^{2} y^{4} + 0.236 x y^{5} - 0.042 y^{6}
\end{dmath}

\end{document}

alt text