# Infinite size nicematrix

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

$$\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}$$


So I naively wrote

$$\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}$$


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{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{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.

• Could you put your code into complete examples with the necessary packages (and the class that you've used)? Commented Dec 15, 2023 at 17:54
• 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 Commented 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 Commented Dec 15, 2023 at 23:22

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.

\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}

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

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}


• What's the meaning of that \phantom command ? Commented Dec 17, 2023 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 tex.stackexchange.com/questions/212710/… Commented Dec 19, 2023 at 8:52