8

Is there a way to force breqn to break at a certain character in favor of another. For instance, in the following example, one might prefer that the line be broken at a + sign rather than at a \cdot. Can one instruct breqn the exact point at which an equation should be broken?

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{breqn}
\begin{document}
\begin{dmath*}
x = \left( y + \frac{1}{2}y^2z^3 \int_{-\infty}^{+\infty} xy^2\exp(z+xy)\,\mathrm{d}y  + \frac{9\pi}{7} \int_{-\infty}^{+\infty} xy^3\cdot\ln z \,  \mathrm{d}z \cdot \int_{-\infty}^{+\infty} \frac{x}{(1-y)^2} \cdot \mathrm{e}^{-3z} \,\mathrm{d}y \right)
\end{dmath*}
\end{document}

2 Answers 2

7

You can force a line break with \\

I think breqn by default gives the same breaking penalty to all binary relations, with no user-level customisation of that.

On the other hand I think that it is safe to do this

 \let\oldcdot\cdot
 \usepackage{breqn}
 \let\cdot\oldcdot

which restores \cdot to its normal non-breqn definition so breaking won't occur at the dot. On your example, this causes the break to happen before the + \frac{9\pi}

1
  • The temporary redefinition of \cdot produced the desired behavior. Please post an update if you think of any reason why it might be unsafe. Thanks.
    – user001
    Commented Mar 13, 2012 at 13:17
7

There is no way to force breqn to break at a certain character in favor of another. However, you can influence its default behavior by enclosing sections in {} or use an explicit break with \\. If you use the latter you will not get proper alignment.

enter image description here

Eq(1a) was printed using \exp({z+xy}), whereas eq(1c) was printed with the default behavior. Obviously breqn's algorithm needs some improvements here as breaking at the plus sign of the exponential is a poor choice.

Eq(1d) was obtained with a forced break using \\.

Here is the MWE for anyone wanting to experiment further.

\documentclass{article}
\usepackage{amsmath}
\let\oldcdot\cdot
\usepackage{breqn}
\let\cdot\oldcdot
\begin{document}
\begin{dgroup}[compact]
\begin{dmath}
x  = \left( y + \frac{1}{2}y^2z^3 \int_{-\infty}^{+\infty} xy^2\exp({z+xy})\,\mathrm{d}y  + \frac{9\pi}{7} \int_{-\infty}^{+\infty} xy^3\cdot\ln z \,  \mathrm{d}z \cdot \int_{-\infty}^{+\infty} \frac{x}{(1-y)^2} \cdot \mathrm{e}^{-3z} \,\mathrm{d}y \right)
\end{dmath}
\begin{dmath}
f=0
\end{dmath}
\begin{dmath}
x = \left( y + \frac{1}{2}y^2z^3 \int_{-\infty}^{+\infty} xy^2\exp(z+xy)\,\mathrm{d}y + \frac{9\pi}{7} \int_{-\infty}^{+\infty} xy^3\cdot\ln z \,  \mathrm{d}z \cdot \int_{-\infty}^{+\infty} \frac{x}{(1-y)^2} \cdot \mathrm{e}^{-3z} \,\mathrm{d}y \right)
\end{dmath}
\begin{dmath}
x = \left( y + \frac{1}{2}y^2z^3 \int_{-\infty}^{+\infty} xy^2\exp(z+xy)\,\mathrm{d}y + \frac{9\pi}{7}\\ \int_{-\infty}^{+\infty} xy^3\cdot\ln z \,  \mathrm{d}z \cdot \int_{-\infty}^{+\infty} \frac{x}{(1-y)^2} \cdot \mathrm{e}^{-3z} \,\mathrm{d}y \right)
\end{dmath}
\begin{dmath}
f=0
\end{dmath}
\end{dgroup}
\end{document}
2
  • Thanks Yiannis. When I run your code, the top and bottom lines of the broken equations are not in vertical alignment as in the image you posted. Rather, the bottom line of each broken equation is right shifted so that its rightmost characters lie directly below the equation number. I suspect that the [compact] option that you loaded with breqn is important for this, but I'm not sure why I cannot reproduce your results.
    – user001
    Commented Mar 13, 2012 at 13:20
  • @user001 Maybe is a version issue.
    – yannisl
    Commented Mar 13, 2012 at 14:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .