1

I'm trying to align a set of equations at the equal signs, with one of them breaking. This is the MWE.

\documentclass{article}
\usepackage{amsmath,mathtools,breqn}
\usepackage{amssymb}

\begin{document}

\begin{dgroup*}
    \begin{dmath*}
        (A \times B) \cup (B \times A)= \{(1,3),(1,4),(2,3),(2,4),(3,1),(3,2),(3,3),(3,4),(4,1),(4,2),(4,3)\},
    \end{dmath*}
    \begin{dmath*}
        (A \times B) \cap (B \times A)= \{(3,3)\},
    \end{dmath*}
    \begin{dmath*}
        (A \times B) \smallsetminus (B \times A)= \{(1,3),(1,4),(2,3),(2,4),(3,4)\}.
    \end{dmath*}
\end{dgroup*}
\end{document}

The first equation should break somewhere in the middle of the set. However, dgroup* breaks it at the equal sign, completely ruining its alignment. I suspect it's because breqn doesn't like breaking lines at commas; I tried following this solution to a related question but it didn't work.

0

breqn has some heuristics for breaking at some places. It will never break at commas, because it cannot distinguish between the two commas in (1,3),: the first comma must not be used for a break, while in your case the second one might be used.

Since breqn, as well as LaTeX, doesn't really know mathematics, breaking such a display has to be done by somebody who knows.

You can set a break point manually, though. Compare the following two displays and decide which style to adopt.

\documentclass{article}
\usepackage{amsmath,mathtools}
\usepackage{breqn}
\usepackage{amssymb}

\begin{document}

\begin{dgroup*}
    \begin{dmath*}
        (A \times B) \cup (B \times A)=
        \{(1,3),(1,4),(2,3),(2,4),\penalty0
        (3,1),(3,2),(3,3),(3,4),(4,1),(4,2),(4,3)\},
    \end{dmath*}
    \begin{dmath*}
        (A \times B) \cap (B \times A)= \{(3,3)\},
    \end{dmath*}
    \begin{dmath*}
        (A \times B) \smallsetminus (B \times A)= \{(1,3),(1,4),(2,3),(2,4),(3,4)\}.
    \end{dmath*}
\end{dgroup*}


\begin{align*}
(A \times B) \cup (B \times A) &= \{
  \begin{aligned}[t]
  &(1,3),(1,4),(2,3),(2,4),\\
  &(3,1),(3,2),(3,3),(3,4),(4,1),(4,2),(4,3)\},
  \end{aligned}
\\
(A \times B) \cap (B \times A) &= \{(3,3)\},
\\
(A \times B) \smallsetminus (B \times A) &= \{(1,3),(1,4),(2,3),(2,4),(3,4)\}.
\end{align*}

\end{document}

enter image description here

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.