# Reduce witdth of matrix column with package nicematrix

I'm trying to write a relatively wide matrix with the package nicematrix, using the environment pNiceMatrix. I can fix the global width using the option [columns-width=xx], and if I fix it to 0mm, it will try to compact the matrix columns to the maximum. But even then, the spacing around the horizontal dots (\cdots), could be reduced. I am not able to use the options using {Wc{2mm}} - nicematrix reads the option as a string.

Here is an example that compiles:

\documentclass{article}
\usepackage{nicematrix}
\begin{document}
$\begin{pNiceMatrix}[columns-width=0mm] %nicematrix \xi^{(\gamma,1)}_{1,1} & \cdots & \xi^{(\gamma,1)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,1)}_{n_{Y},1} & \cdots & \xi^{(\gamma,1)}_{n_{Y},M_{n_{Y}}} \\ \Vdots & & & & & & \vdots \\ \xi^{(\gamma,N)}_{1,1} & \cdots & \xi^{(\gamma,N)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,N)}_{n_{Y},1} & \cdots & \xi^{(\gamma,N)}_{n_{Y},M_{n_{Y}}} \end{pNiceMatrix}$
\end{document}


And produces this output:

I have tried this, based on the first example in section 8 "The width of the columns" of the documentation :

$\begin{pNiceMatrix}{cWc{2mm}cWc{2mm}cWc{2mm}c} %nicematrix \xi^{(\gamma,1)}_{1,1} & \cdots & \xi^{(\gamma,1)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,1)}_{n_{Y},1} & \cdots & \xi^{(\gamma,1)}_{n_{Y},M_{n_{Y}}} \\ \Vdots & & & & & & \vdots \\ \xi^{(\gamma,N)}_{1,1} & \cdots & \xi^{(\gamma,N)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,N)}_{n_{Y},1} & \cdots & \xi^{(\gamma,N)}_{n_{Y},M_{n_{Y}}} \end{pNiceMatrix}$


But only to get :

How can I reduce the width of the columns 2,4,6 ?

I followed the quick install tutorial for texlive so I should have the latest version of nicematrix (5.19).

• If you look at the examples in section 8 none have NiceMatrix supporting the c{2mm} Aug 3 at 11:42
• Welcome to TeX.SE. The pNiceMatrix environment is like the pmatrix environment provided by amsmath, which means it doesn't accept column specifications. The [columns-width=0mm] tells latex that each column should have minimum width of 0mm. Try something like [columns-width=1cm] and see if that helps your solution. Aug 3 at 11:44
• Alright, I remove the edit then and create a new answer! And yes, there was no hint that it would work, but also no example how showing how to reduce the size of the matrix on the environment pNiceMatrix Aug 3 at 11:44
• @rbrignall Thank you, I have tried different values of for [columns-width=xx], and somehow, once the indicated width is smaller than the minimal possible width considering the size of the different elements, the width does not change anymore. In the actual implementation of the pMatrixEnvironment, setting columns-width to 0 ensures that it will always have the minimal size possible. But it may not be the cleanest way, and did not solve my issue. Aug 3 at 12:05

Since {pNiceMatrix} is similar to {pmatrix} of amsmath, it does not take in argument for the format of the array.

However, nicematrix provides {pNiceArray} with a mandatory argument which is the format. The environment {pNiceArray} is merely an environment {NiceArray} (similar to array) with @{} at both sides of the format and surrounded by parenthesis (with \left( and \right)).

Nevertheless, for what you want to acheive, the best solution is probably changing the value of \arraycolsep (as said in another answer).

\documentclass{article}
\usepackage{nicematrix}
\begin{document}
$\begin{pNiceMatrix} \xi^{(\gamma,1)}_{1,1} & \cdots & \xi^{(\gamma,1)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,1)}_{n_{Y},1} & \cdots & \xi^{(\gamma,1)}_{n_{Y},M_{n_{Y}}} \\ \Vdots & & & & & & \vdots \\ \xi^{(\gamma,N)}_{1,1} & \cdots & \xi^{(\gamma,N)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,N)}_{n_{Y},1} & \cdots & \xi^{(\gamma,N)}_{n_{Y},M_{n_{Y}}} \end{pNiceMatrix}$

$\begin{pNiceArray}{cWc{2mm}cWc{2mm}cWc{2mm}c} \xi^{(\gamma,1)}_{1,1} & \cdots & \xi^{(\gamma,1)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,1)}_{n_{Y},1} & \cdots & \xi^{(\gamma,1)}_{n_{Y},M_{n_{Y}}} \\ \Vdots & & & & & & \vdots \\ \xi^{(\gamma,N)}_{1,1} & \cdots & \xi^{(\gamma,N)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,N)}_{n_{Y},1} & \cdots & \xi^{(\gamma,N)}_{n_{Y},M_{n_{Y}}} \end{pNiceArray}$

\setlength{\arraycolsep}{1pt}
$\begin{pNiceMatrix} %nicematrix \xi^{(\gamma,1)}_{1,1} & \cdots & \xi^{(\gamma,1)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,1)}_{n_{Y},1} & \cdots & \xi^{(\gamma,1)}_{n_{Y},M_{n_{Y}}} \\ \Vdots & & & & & & \vdots \\ \xi^{(\gamma,N)}_{1,1} & \cdots & \xi^{(\gamma,N)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,N)}_{n_{Y},1} & \cdots & \xi^{(\gamma,N)}_{n_{Y},M_{n_{Y}}} \end{pNiceMatrix}$
\end{document}


I found a first solution in this answer, but it reduces the width of each column not only the columns 2,4,6. This behavior is enough for my usage, and it maybe the only solution, as the environment pNiceMatrix is based on the amsmath environments {matrix} and {pmatrix}.

\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\setlength{\arraycolsep}{1pt}
$\begin{pNiceMatrix} %nicematrix \xi^{(\gamma,1)}_{1,1} & \cdots & \xi^{(\gamma,1)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,1)}_{n_{Y},1} & \cdots & \xi^{(\gamma,1)}_{n_{Y},M_{n_{Y}}} \\ \Vdots & & & & & & \vdots \\ \xi^{(\gamma,N)}_{1,1} & \cdots & \xi^{(\gamma,N)}_{1,M_{1}}, & \Cdots &, \xi^{(\gamma,N)}_{n_{Y},1} & \cdots & \xi^{(\gamma,N)}_{n_{Y},M_{n_{Y}}} \end{pNiceMatrix}$
\end{document}
`

Output :