# Linebreak inside 'align'

I tried to linebreak inside math mode which did not work. So searching for that led me to try using 'align' instead. So I'm trying to break a line inside align with the following code:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
R = \left\{(S_1,S_1), (S_1,S_4), (S_4,S_4), (S_4,S_1), (S_2,S_2), (S_2,S_3),    (S_3,S_3), (S_3,S_2), (S_0,S_0), \\
(S_0, S_5), (S_5,S_5) , (S_5,S_0)\right\}
\end{align}

\end{document}


I get the error message : Extra }, or forgotten \right. \end{align} which I don't understand since I do have an opening and closing curly bracket?

Anyhow, the above does break the line in some way but it looks really ugly, and aligned to the right for some reason. Could someone show me how I could align the set I'm trying to write out, nicely on two lines?

• The problem is the \left\{ which does not see any closure on the same line. Use a \right. at the line end. As this formula wont need any auto-expansion of the brackets, you could use \{ as well. – LaRiFaRi Nov 24 '14 at 13:59
• @LaRiFaRi But it should not be closed before the last element has been included, it should only break the line and continue. – DSF Nov 24 '14 at 14:00
• The \right. just closes the \left, \right pair. But it prints nothing. There are several post around here, which explain that behaviour. – LaRiFaRi Nov 24 '14 at 14:01
• @LaRiFaRi I still get the same error. Could you write it out in the context of my example please? – DSF Nov 24 '14 at 14:04

In order to fix that, you will have to give the \left\{ its counterpart which would be \right. on the same line. The second line would need a \left. ... \right\} .

As you do not need auto-sized brackets here, I would leave it all away.

Here is your example and my version:

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{align}
R = \left\{(S_1,S_1), (S_1,S_4), (S_4,S_4), (S_4,S_1), (S_2,S_2), (S_2,S_3), (S_3,S_3), (S_3,S_2), (S_0,S_0),\right. \\
\left.(S_0, S_5), (S_5,S_5) , (S_5,S_0)\right\}
\end{align}
$$\begin{split} R = \{(S_1,S_1), (S_1,S_4), (S_4,S_4), (S_4,S_1), (S_2,S_2), (S_2,S_3), (S_3,S_3),\\ (S_3,S_2), (S_0,S_0), (S_0, S_5), (S_5,S_5) , (S_5,S_0)\} \end{split}$$
\end{document}


And here is a screen-shot of the second version (as the first version exceeds all possible limits...)

• Oh. I didn't start the \left again. Thank you. I find the equation way of doing it much more intuitive though. – DSF Nov 24 '14 at 14:10

Here is a solution similar to LaRiFaRi's but with a different alignment:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

$$\begin{split} R = \{&(S_{1},S_{1}), (S_{1},S_{4}), (S_{4},S_{4}), (S_{4},S_{1}), (S_{2},S_{2}), (S_{2},S_{3}),\\ &(S_{3},S_{3}), (S_{3},S_{2}), (S_{0},S_{0}), (S_{0},S_{5}), (S_{5},S_{5}), (S_{5},S_{0})\} \end{split}$$

\end{document}


Notice the horizontal alignment of the elements.

You also can use the following code, heavily inspired by Sebastien Gouezel's code for \DeclarePairedDelimiter (pp. 28-29 of mathtools documentation), that allows for line breaks in paired delimiters:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}

\newcommand\MTkillspecial[1]{% helper macro
\bgroup
\catcode\&=9
\let\\\relax%
\scantokens{#1}%
\egroup
}
\DeclarePairedDelimiter\set\{\}
\reDeclarePairedDelimiterInnerWrapper\set{star}{
\mathopen{#1\vphantom{\MTkillspecial{#2}}\kern-\nulldelimiterspace\right.}
#2
\mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#2}}#3}}

\begin{document}

\begin{align*} R = &\! \begin{aligned}[t]\set[\Big]{&(S_1,S_1), (S_1,S_4), (S_4,S_4), (S_4,S_1), (S_2,S_2), (S_2,S_3), (S_3,S_3), (S_3,S_2), \\
& (S_0,S_0), (S_0, S_5), (S_5,S_5) , (S_5,S_0)}
\end{aligned}\\
R = &\! \begin{aligned}[t]\set{ & (S_1,S_1), (S_1,S_4), (S_4,S_4), (S_4,S_1), (S_2,S_2), (S_2,S_3), (S_3,S_3), (S_3,S_2),\\
& (S_0,S_0) (S_0, S_5), (S_5,S_5) , (S_5,S_0)}
\end{aligned}
\end{align*}

\end{document}


Unfortunately, this code works only with the optional arguments (or no optional argument at all), but not with the star version.

• But the star version appears to work here. Indeed, the declared point of \reDeclarePairedDelimiterInnerWrapper is to support the star version. What fails is using \DeclarePairedDelimiterX or \DeclarePairedDelimiterXPP, hence for instance \delimsize is not available. – Blaisorblade Sep 1 '17 at 13:41
• @Blaisorblade: As this is a rather old post, I don't remember the details, but I suppose it didn't work when I tested it. Maybe there was a problem with the 2014 version of \DeclarePairedDelimiter`? As it worked with the optional argument (which is preferable in my opinion), I didn't investigate further. – Bernard Sep 1 '17 at 14:21