# how to avoid breaking a line in dmath mode?

I tried all 3 options above that I have seen recommended in other threads/answers, but none seem to work

\begin{dmath}
P (A>B \cap A>B+C)=P(A>B+C)=P(A=\nolinebreak 3 \cap B=\nolinebreak 1 \cap C=\nolinebreak 1)=\frac{1}{3}\frac{1}{3}\frac{1}{3}=\frac{1}{27}
\end{dmath}

\begin{dmath}
P (A>B \cap A>B+C)=P(A>B+C)=P(A=\nolinebreak3 \cap B=\nolinebreak 1 \cap C=\nolinebreak1)=\frac{1}{3}\frac{1}{3}\frac{1}{3}=\frac{1}{27}
\end{dmath}

\begin{dmath}
P (A>B \cap A>B+C)=P(A>B+C)=P(A\hiderel{=}3 \cap B\hiderel{=}\cap C\hiderel{=}1)=\frac{1}{3}\frac{1}{3}\frac{1}{3}=\frac{1}{27}
\end{dmath}


Add a pair of braces ({}) around the part that shouldn't break:

\documentclass{article}

\usepackage{breqn}

\begin{document}
\begin{dmath}
P({A>B \cap A>B+C})
= P({A>B+C})
= P({A= 3 \cap B=1 \cap C=1})
=\frac{1}{3}\frac{1}{3}\frac{1}{3}
=\frac{1}{27}
\end{dmath}

\end{document}

• Which shows the shortcomings of breqn. I want to decide where to break my equations. Sep 22, 2014 at 15:46

Althought it is not said in your question, neither exposed in the MWE, I suppose you are using the breqn package since it provides the dmath environment. This environment specifically breaks the equations, since it is meant to do so:

'breqn - Automatic line breaking of displayed equations (...) The sin­gle most am­bi­tious goal of the pack­age, how­ever, is to sup­port au­to­matic line­break­ing of dis­played equa­tions'.

Using another equation environment will solve it:

$P (A>B \cap A>B+C)=P(A>B+C)=P(A=\nolinebreak 3 \cap B=\nolinebreak 1 \cap C=\nolinebreak 1)=\frac{1}{3}\frac{1}{3}\frac{1}{3}=\frac{1}{27}$

$$P (A>B \cap A>B+C)=P(A>B+C)=P(A=\nolinebreak3 \cap B=\nolinebreak 1 \cap C=\nolinebreak1)=\frac{1}{3}\frac{1}{3}\frac{1}{3}=\frac{1}{27} %label{eq:myeq} %optional$$

\begin{dmath}
P (A>B \cap A>B+C)=P(A>B+C)=P(A\hiderel{=}3 \cap B\hiderel{=}\cap C\hiderel{=}1)=\frac{1}{3}\frac{1}{3}\frac{1}{3}=\frac{1}{27}
\end{dmath}


With $ and $ you get numberless equations, and with the equation you get them numbered.

Since you equation is quite wide, you may want to display it in two lines, to have the numbering correctly set at the right:

\begin{aligned} P (A>B \cap A>B+C) & = P(A>B+C)\\ & = P(A=\nolinebreak3 \cap B=\nolinebreak 1 \cap C=\nolinebreak1) = \frac{1}{3}\frac{1}{3}\frac{1}{3}=\frac{1}{27} \end{aligned}

• Thank you for you response. The reason why I like dmath is because it is breaking equations pretty nicely automatically, so I don't have to do a manual approach :( Sep 22, 2014 at 14:47
• array switches to \textstyle, and the spacing around the = is wrong, use aligned from amsmath. Sep 22, 2014 at 14:48