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
    Could you put your code into complete examples with the necessary packages (and the class that you've used)? – Teepeemm Dec 15 '23 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 – 20-sided-dice Dec 15 '23 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 '23 at 23:22

2 Answers2

6

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}

Sandy G
  • 42,558
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

pascal974
  • 4,652
  • What's the meaning of that \phantom command ? – 20-sided-dice Dec 17 '23 at 21:12
  • @20-sided-dice you have a description of this command section 3.7.1 in the lshort documentation or in this post https://tex.stackexchange.com/questions/212710/fill-space-created-by-phantom-with-other-text – pascal974 Dec 19 '23 at 08:52