7

I am trying to write a nicematrix version of this tridiagonal (infinite size) matrix, as the pmatrix environment renders a very ugly version

\begin{equation}
\begin{pmatrix}
    -\lambda & \lambda             & 0                    & 0       & \dots  \\
    \mu      & -(\lambda+\mu)      & \lambda              & 0       &        \\
    0        & 2\mu                & -(\lambda+2\mu)      & \lambda &        \\
    \vdots   &                     & \ddots               & \ddots  & \ddots
\end{pmatrix}
\end{equation}

So I naively wrote

\begin{equation}
\begin{pNiceMatrix}
    -\lambda & \lambda             & 0                    & 0       & \Cdots  \\
    \mu      & -(\lambda+\mu)      & \lambda              & 0       &        \\
    0        & 2\mu                & -(\lambda+2\mu)      & \lambda &        \\
    \Vdots   &                     & \Ddots               & \Ddots  & \Ddots
\end{pNiceMatrix}
\end{equation}

But the result does not work at all

I am guessing the problem comes from a lack of indication for an end to my \Ddots. But then how am I supposed to manage infinite size matrices ?

Edit

I am providing a complete minimal example, with the document class I am working in.

\documentclass{article}

\usepackage{nicematrix}

\begin{document}
\begin{equation}
\begin{pNiceMatrix}
    -\lambda & \lambda             & 0                    & 0       & \Cdots  \\
    \mu      & -(\lambda+\mu)      & \lambda              & 0       &        \\
    0        & 2\mu                & -(\lambda+2\mu)      & \lambda &        \\
    \Vdots   &                     & \Ddots               & \Ddots  & \Ddots
\end{pNiceMatrix}
\end{equation}
\end{document}

The results of compilation look a little bit different to the pictures I provided because I had a font package. But the problem is still there.

3
  • 3
    Could you put your code into complete examples with the necessary packages (and the class that you've used)?
    – Teepeemm
    Dec 15, 2023 at 17:54
  • 1
    Done. I gave the complete minimal example but the differences are annecdotal. This was to be expected as it clearly looks like an internal problem of nicematrix Dec 15, 2023 at 18:06
  • Command \Ddots are intended to be drawn between two not empty matrix nodes. So you should stich with first code fragment which gives to my opinion nice looking result. What you after seems to be features request. Hopefully author of package will see your question and provide some fix to your problem
    – Zarko
    Dec 15, 2023 at 23:22

2 Answers 2

7

The commands \Ldots, \Cdots, \Vdots, \Ddots, and \Iddots are intended to be used between cells that are not empty. So you can make the cells \NotEmpty.

enter image description here

\documentclass{article}

\usepackage{nicematrix}

\begin{document}

\[
\begin{pNiceMatrix}
    -\lambda  & \lambda        & 0               & 0         & \Cdots  \\
    \mu       & -(\lambda+\mu) & \lambda         & 0         &         \\
    0         & 2\mu           & -(\lambda+2\mu) & \lambda   &         \\
    \Vdots    &                & \Ddots          & \Ddots    & \Ddots  \\
    \NotEmpty &                &                 & \NotEmpty & \NotEmpty
\end{pNiceMatrix}
\]

\end{document}
3
  • +1! I use nice matrix occasionally and wasn't aware for NotEmpty command. Good to know!
    – Zarko
    Dec 16, 2023 at 15:28
  • Was not aware either of this command. Thx ! Dec 17, 2023 at 21:10
  • ... And here I was searching the whole documentation for that. Thanks a lot <3 Apr 19 at 23:41
2

With \phantom is perhaps enough for you?

\documentclass[border=5mm]{standalone}
\usepackage{nicematrix}
\begin{document}
$\begin{pNiceMatrix}
    -\lambda & \lambda             & 0                    & 0       & \Cdots  \\
    \mu      & -(\lambda+\mu)      & \lambda              & 0       &        \\
    0        & 2\mu                & -(\lambda+2\mu)      & \lambda &        \\
    \Vdots   &                     & \Ddots               & \Ddots  & \Ddots\\
\phantom{}&\phantom{}&\phantom{}&\phantom{.}&\phantom{.}
\end{pNiceMatrix}$
\end{document}

enter image description here

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .