Long formula as a matrix coefficient

I would like to write a 2*2 matrix with one of the coefficients given by a very long formula that I would like to write on two lines.

I tried this

 \begin{displaymath}
\begin{pmatrix}
X & X \\
\parbox[c]{3cm}{a+b+c+d\\ +e+f+g+h+j+t\\E+G+T+F+E} & X
\end{pmatrix}
\end{displaymath}


But I am not very satisfied with it. I was hoping some function or package exist to do something cleaner.

How can I do it?

• Please, be so kind and show us what you try so far. Perhaps some of the amsmath or mathtools math environments can solve your problem. Oct 22 at 18:24
• Please, edit your question and add to it an MWE (Minimal Working Example), a small but complete document with your matrix only, which reproduce problem. MWE preamble let be restricted to packages relevant to your problem. Help us to help you. Oct 22 at 18:45
• Is it really the case that there is no plus sign at the beginning of the third line, before the "E"? This has resulted in at least one questionable result in the answers already given. Oct 23 at 0:37

One of amsmath can be a solution for your problem. However, you can introduce a new variable in your matrix as shown in the MWE below:

\documentclass{article}
\usepackage{mathtools}

\begin{document}
$\begin{pmatrix} X & X \\ \begin{gathered} a+b+c+d\\ {}+e+f+g+h+j+t\\ E+G+T+F+E \end{gathered} & X \end{pmatrix}$

or
$\begin{pmatrix} X & X \\ Y & X \end{pmatrix}$
where $Y=a+b+c+d +e+f+g+h+j+t E+G+T+F+E$

\end{document}


For the first example, someone may have liked that the long equation is written in a more condensed way. This can be achieved for example by use of matrix instead of gathered written with a \small font size:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$\begin{pmatrix} X & X \\[1ex] \small\begin{matrix} a+b+c+d+e\\ {}+f+g+h+j+t\\ E+G+T+F+E \end{matrix} & X \end{pmatrix}$
\end{document}


• 2nd option is better by far.
– Joce
Oct 22 at 20:17
• @Joce, I am of the same opinion. That is reason why I add this possibilities. Thank you for comment! Oct 22 at 20:47

I guess you've provided an actual use case for drawing horizontal and vertical lines to bring out the structure of the 2x2 matrix.

The following solution uses no extra packages, just a pair of basic array environments.

\documentclass{article}
\begin{document}
$\left( \begin{array}{@{}c|c@{\,}} X & X \\ \hline \begin{array}{@{}c@{}} a+b+c+d\\ +e+f+g+h+j+t\\ +E+G+T+F+E \end{array} & X \end{array} \right)$
\end{document}


Using the same style of the image of Mico, here I add another option using the matrix environment. I think that with the nicematrix package it is possible to realize similar output.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\begin{document}
$\left(\begin{array}{c|c} X & X\\ \hline \begin{matrix} a+b+c+d\\ +e+f+g+h+j+t\\ +E+G+T+F+E \end{matrix} & X \end{array}\right)$
\end{document}