Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted
\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

share|improve this answer
    
Excellent, thank you. –  user001 Mar 13 '12 at 16:33
    
Indeed, right alignment is neater method than using phantoms. –  Ian Thompson Mar 13 '12 at 16:35
add comment

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.

share|improve this answer
    
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 '12 at 16:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.