# How to write matrix with math symbols in equation?

Here is my try

Let $\Gamma$ be an $2\times 2$ Hermitian matrix,\\
\begin{displaymath}
$$\Gamma = \begin{bmatrix} \gamma 1 & \gamma 2\\ \gamma 3 &\gamma 4 \end{bmatrix}$$
\end{displaymath}

• welcome to tex.se! your equation is writen on very wrong way. remove \begin{displaymath} and \end{displaymath}, and all $ inside equation. for further help you need to provide complete but small document. – Zarko Mar 4 '18 at 16:02 • Welcome to TeX.SX! Here are some information for you: small complete document – Bobyandbob Mar 4 '18 at 16:08 ## 4 Answers let me convert my comment to an answer: • your equation is written on very wrong way: • it is not allowed to nest $$...$$ inside \begin{displaymath} ... \end{displaymath}, • also use $ inside equation is not allowed (it is intend for use for math expression in text)
• your equation can be written on many ways, besides shown in other answers:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
Let $\Gamma$ be a $2\times 2$ Hermitian matrix,
$\Gamma = \begin{bmatrix} \gamma_{1 1} & \gamma_{1 0} \\ \gamma_{0 1} & \gamma_{0 0} \end{bmatrix},$
and write
\begin{align*}
\Gamma(z, w)
& = \begin{bmatrix} w & 1 \end{bmatrix}
\Gamma
\begin{bmatrix} z \\ 1 \end{bmatrix} \\
& = \gamma_{00} + \gamma_{0 1} z + \gamma_{10} w + \gamma_{11} z w.
\end{align*}
\end{document}


where is, as noted Mico in his comment below, $...$ entirely equivalent to \begin{displaymath} ... \end{displaymath}.

or an alternative to the leandriis answer, as suggested Bernard in his comment below:

\documentclass{article}
\usepackage{mathtools}% needed for \shortintertext
\begin{document}
Let $\Gamma$ be an $2\times 2$ Hermitian matrix,
\begin{align*}
\Gamma & = \begin{bmatrix}
\gamma_{1 1} & \gamma_{1 0} \\
\gamma_{0 1} & \gamma_{0 0}
\end{bmatrix},
\shortintertext{and write}
\Gamma(z, w)
& = \begin{bmatrix} w & 1 \end{bmatrix}
\Gamma
\begin{bmatrix} z \\ 1 \end{bmatrix} \\
& = \gamma_{00} + \gamma_{0 1} z + \gamma_{10} w + \gamma_{11} z w.
\end{align*}
\end{document}


which gives:

and one more (final) alternative :-), as suggested barbara beeton in her comment below:

\documentclass{article}
\usepackage{mathtools}% needed for \shortintertext
\begin{document}
Let $\Gamma$ be an $2\times 2$ Hermitian matrix,
\begin{gather*}
\Gamma = \begin{bmatrix}
\gamma_{1 1} & \gamma_{1 0} \\
\gamma_{0 1} & \gamma_{0 0}
\end{bmatrix},
\shortintertext{and write}
\begin{split}
\Gamma(z, w)
& = \begin{bmatrix} w & 1 \end{bmatrix}
\Gamma
\begin{bmatrix} z \\ 1 \end{bmatrix} \\
& = \gamma_{00} + \gamma_{0 1} z + \gamma_{10} w + \gamma_{11} z w.
\end{split}
\end{gather*}
\end{document}


which gives

• You may want to mention that $...$ is entirely equivalent to \begin{displaymath} ... \end{displaymath}. – Mico Mar 4 '18 at 16:38
• Why not only an align* environment, and a \(short)intertext{and write}? – Bernard Mar 4 '18 at 16:44
• @Bernard, this is already shown in leandriis answer. – Zarko Mar 4 '18 at 16:46
• @Zarko: Sorry, I didn't read till the bottom of my screen. – Bernard Mar 4 '18 at 16:56
• @Bernard, no, you have right. i add modified leandriis answer as you suggested. with \shortintertext{...} and main text outside of align* environment – Zarko Mar 4 '18 at 16:59

Some suggestions:

• The contents of an environment such as displaymath are in math mode automatically -- no need to encase math elements in $...$.

• Use an align* environment for multi-line unnumbered equations.

\documentclass{article}
\usepackage{amsmath} % for 'bmatrix' and 'align*' environments
\begin{document}
Let $\Gamma$ be a $2\times2$ Hermitian matrix,
\begin{displaymath}
\Gamma = \begin{bmatrix}
\gamma_{11} & \gamma_{10} \\
\gamma_{01} & \gamma_{00}
\end{bmatrix}\,,
\end{displaymath}
and write
\begin{align*}
\Gamma(z,w) &= \begin{bmatrix} w &  1 \end{bmatrix}
\Gamma
\begin{bmatrix} z \\ 1 \end{bmatrix} \\
&= \gamma_{00}+\gamma_{01}z+\gamma_{10}w+\gamma_{11}zw.
\end{align*}
\end{document}


A variant using a single align* environment and intertext:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\intertext{Let $\Gamma$ be an $2\times 2$ Hermitian matrix,}
\Gamma =& \begin{bmatrix} \gamma_{11} &  \gamma_{10}\\ \gamma_{01} &\gamma_{11}\end{bmatrix},
\intertext{and write}
\Gamma(z,w) =& \begin{bmatrix} w & 1 \end{bmatrix} \Gamma \begin{bmatrix} z \\ 1 \end{bmatrix}\\
=& \gamma_{00}+\gamma_{01}z+\gamma_{10}w+\gamma_{11}zw.
\end{align*}
\end{document}


• There seems to be little (logical) need to align the = symbol in the first equation with the subsequent = symbols. The first equation defines a 2x2 matrix, while the second equation sets up a quadratic form. – Mico Mar 4 '18 at 16:34
• There's no logical need, you're right, but the sentence is not finished at the first equation, so there's a logical need to use \intertext. I'll add that using \shortintertext might look nicer. – Bernard Mar 4 '18 at 16:59
• @Bernard - I suppose that, technically speaking, \Gamma(z,w) is a bilinear form and not a quadratic form... – Mico Mar 4 '18 at 17:19
• @Mico: It could be bilinear (certainly not quadratic), but it isn't, because of the constant term $\gamma_{0,0}$ in the definition. – Bernard Mar 4 '18 at 18:03

This should give the desired output.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
Let $\Gamma$ be a $2\times 2$ Hermitian matrix,
%
\begin{equation*}
\Gamma = \begin{bmatrix}
\gamma_{1 1} & \gamma_{1 0} \\
\gamma_{0 1} & \gamma_{0 0}
\end{bmatrix},
\end{equation*}
%
and write
%
\begin{align*}
\Gamma(z, w) &= \begin{bmatrix} w & 1 \end{bmatrix} \Gamma \begin{bmatrix} z \\ 1 \end{bmatrix} \\
&= \gamma_{0 0} + \gamma_{0 1} z + \gamma_{1 0} w + \gamma_{1 1} z w.
\end{align*}
\end{document}

• It's not right to leave blank lines between text and displayed equations. – Mico Mar 4 '18 at 16:13
• @Mico why is that? You mean only here in this forum or in general? Because IMO it is much more readable like this... – SampleTime Mar 4 '18 at 16:15
• general. because with blank line you start new paragraph. it can has indented first line. without it you continue with paragraph and text will start at left text border. – Zarko Mar 4 '18 at 16:20
• Blank lines in a tex file create paragraph breaks. Paragraphs are TeX's fundamental building blocks. Look at the input: Logically, there is but one "paragraph", which consists of two short lines of text and two displayed equations (one of which is split further across two lines). By introducing paragraph breaks (via the blank lines in the input file), one not only messes up TeX's spacing algorithms across and within paragraphs, one also messes up the spacing above and below displayed equations. – Mico Mar 4 '18 at 16:23
• Ok, good points. I have edited the code to avoid new paragraphs. I think I will use comments then, because I think the code is much harder to read otherwise... – SampleTime Mar 4 '18 at 16:59