# [Tex/LaTex] Matrix format in Latex

math-modematrices

How can a matrix be written in LaTeX? I have tried to use \begin{matrix} but I need to write the matrix below and I cannot understand how to fill it up exactly as this.

#### Best Answer

MWE:

\documentclass[11pt]{article}
\usepackage{amsmath}

\begin{document}
\begin{equation*}
Q =
\begin{pmatrix}
-(\lambda_1 + \mu_1) & \lambda_1 & 0 & \ldots & 0 & 0 \\
0 & -(\lambda_2 + \mu_2) & \lambda_2 & \ldots & 0 & 0 \\
\vdots & \vdots & \vdots & \ldots & 0 & 0 \\
0 & 0 & 0 & -(\lambda_{n-1} + \mu_{n-1}) & \lambda_{n-1} & \\
0 & 0 & 0 & \ldots & 0 & -\mu_n
\end{pmatrix}
\end{equation*}
\end{document}