6

I have a matrix whose entries are quite long and must be broken up across multiple lines. The desired break-points are the + operators separating terms in each matrix element. The following code is illustrative of the problem I face: the + operators in the second line of each matrix element appear as unary rather than binary operators. Can this be changed?

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[\begin{bmatrix}
 a + b &  e + f \\
+c + d & +g + h \\[6pt]
 i + j &  m + n \\
+k + l & +o + p \\
\end{bmatrix}\]
\end{document}

I would most prefer if each term was aligned vertically with the corresponding term below it (e.g., a+b in vertical alignment with c+d), with the additional + sign to the left, and properly spaced from the ensuing c (i.e., subjected to the spacing that is accorded to binary operators).

Also, as a means of clarifying that the top two lines and bottom two lines separately constitute single rows, I introduced whitespace between lines 2 and 3 by adding [6pt] after the closing \\ of the second matrix line). Is there a better way to selectively introduce whitespace?

Lastly, is there a more automated way to achieve line-breaking in a matrix environment, compared to my manual separation of long lines across \\ separators? Thanks.

2 Answers 2

7
\documentclass{article}
\usepackage{mathtools}

\begin{document}
\[\begin{bmatrix*}[r]
   a + b &    e + f \\
{}+c + d & {}+g + h \\[6pt]
   i + j &    m + n \\
{}+k + l & {}+o + p \\
\end{bmatrix*}\]
\end{document}

enter image description here

1
  • Indeed, right alignment is neater method than using phantoms. Mar 13, 2012 at 16:35
4

To change an operator from unary to binary, put an empty group before it, e.g. {}+c+d. You could use the \phantom command to get the vertical alignment right: \phantom{{}+{}}a+b see section 3.7.1 of the Not so short introduction to LaTeX.

1
  • Ah, I just came across the phantom operator before you posted this, and it solves the alignment issue. However, I was using \phantom{+} rather than \phantom{{}+} (I wasn't aware of how to change unary to binary operators). Many thanks for both solutions.
    – user001
    Mar 13, 2012 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .