2

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. enter image description here

  • \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{matrix} should work – user31729 May 22 '15 at 17:57
  • Basic guidelines are at the LaTeX wiki. – DJP May 22 '15 at 18:02
  • I have already seen those but I am getting a lot of missing $ etc – user1930901 May 22 '15 at 18:03
  • @user1930901: You have to wrap a math environment around \begin{matrix}...\end{matrix}, say $...$ or \(...\) of course – user31729 May 22 '15 at 18:07
  • You can also use the pmatrix environment. – G. Aguilera May 22 '15 at 18:10
5

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}

enter image description here

  • Thanks! can you label such equation? since I did \label{2} before \end{equation} but nothing is showing – user1930901 May 22 '15 at 18:11
  • @user1930901 use the unstarred version: \begin{equation}, not \begin{equation*}. – Null May 22 '15 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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