Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

2 Answers 2

up vote 6 down vote accepted

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}

share|improve this answer
    
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 Mar 13 '12 at 13:17

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}
share|improve this answer
    
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 Mar 13 '12 at 13:20
    
@user001 Maybe is a version issue. –  Yiannis Lazarides Mar 13 '12 at 14:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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