# Automatic linebreaking inside displaymath

Yes, I know of the existence of breqn, and I am very excited about this package.

I am trying to write a mathematics paper, that will be typeset in two different styles (different page sizes, and different textblocks, &c).

At some point I have to typeset a long exact sequence, which looks approximately like

$1 \to A \to B \to C \to D \to E \to F \to \ldots$


In my paper, all these letters are actually longer mathematical expressions (cohomology groups). In one paper, this sequence fits nicely on the page, but in the other, I get an hbox overflow error.

I immediately thought of breqn, but the result of using

\begin{dmath*}
1 \to A \to B \to C \to D \to E \to F \to \ldots
\end{dmath*}


is that I get a linebreak at every \to. This is not what I want. There should be just 1 linebreak (if needed), and it should automatically be chosen at the \to between C and D.

How do I accomplish this?

-
I do not see how that will help. If I use split, the formula will not be on 1 line in the document where line-breaking is not necessary. – jmc Sep 21 '12 at 2:13

\documentclass{article}
\usepackage[textwidth=5cm]{geometry}% just for the example
\usepackage{breqn}

\begin{document}

\begin{dmath*}
{1 \to A \to B \to C} \to {D \to E \to F \to \ldots}
\end{dmath*}

\end{document}


-
Wow, thanks! That looks good. One question: Can it be done even more automatic? Suppose I want 5 different textwidths... /I realize this is more difficult question, focussing on a general solution. But I think general solutions are important./ – jmc Sep 21 '12 at 2:24
@jmc perhaps it can be done, but I think it requires too much work, specially since the requirement for the breaking point in this special case might not be the optimal one in other situations. The problem is the determination of the breaking point more than the textwidth. – Gonzalo Medina Sep 21 '12 at 2:27

If you use inline rather than display math it would break automatically without needing any packages.

\documentclass{article}

\begin{document}

\def\tst{ 1 \to A \to B \to C \to D \to E \to F \to \ldots }

\fbox{\parbox{2cm}{$\displaystyle \tst$}}

\fbox{\parbox{3cm}{$\displaystyle \tst$}}

\fbox{\parbox{4cm}{$\displaystyle \tst$}}

\fbox{\parbox{5cm}{$\displaystyle \tst$}}

\fbox{\parbox{6cm}{$\displaystyle \tst$}}

\fbox{\parbox{7cm}{$\displaystyle \tst$}}

\end{document}

-
Hi David. Thanks for this answer. I have been disconnected from the internet for half a year. I will consider this. I think the \displaystyle is very useful, and I did not know of it yet. Thanks again! – jmc Feb 15 '13 at 13:25