# How to place a vertical dashed line between columns of a matrix?

Can you help me how to do that dashed line on this matrix

I will add another simple solution if you like.

\documentclass{article}
\usepackage{arydshln}
\usepackage{mathtools}
\begin{document}
$\left[ \begin{array}{c:c} 1 & 2 \\ 3 & 4 \\ 5 & 6 \\ \end{array} \right]$
\end{document}


ADDENDUM: 2020-7-24. Using {bNiceArray} of nicematrix package you will have the square brackets at the same position as in {bmatrix} of amsmath.

\documentclass[a4paper,12pt]{article}

\usepackage{nicematrix}
\usepackage{arydshln}

\NiceMatrixOptions{letter-for-dotted-lines=V}

\begin{document}
$\begin{bNiceArray}{c:c} 1 & 2 \\ 3 & 4 \\ 5 & 6 \end{bNiceArray}$
\end{document}


Remark: If you don't put \NiceMatrixOptions{letter-for-dotted-lines=V}, you will have a dotted line (drawn by nicematrix).

• The dashes are of different lengths which is more or less inevitable if you have long dashes. Is it possible to make them shorter and more tightly packed? – Anush Jul 24 at 8:22
• Instead of \left[\begin{NiceArray}...\end{NiceArray}\right], it's possible to use \begin{bNiceArray}...\end{bNiceArray} with the same result (which is a result similar to {bmatrix} of amsmath). – F. Pantigny Jul 24 at 8:48
• @F.Pantigny Very kind F. Pantigny you are right totally. The reason of my addendum is the same: I'm using papeeria.com that can compile with your previous version of nicematrix (I use the most recent TeXlive2019). Please, can you edit my addenudum adding your screenshot? Thank you very much. – Sebastiano Jul 24 at 11:55
• @Sebastiano: I have edited your addendum :-) – F. Pantigny Jul 24 at 12:38
• @F.Pantigny Excellent. Always thank you. – Sebastiano Jul 24 at 12:42

Try

\documentclass{article}
\usepackage{amsmath}
\usepackage{arydshln}
\begin{document}
$$\left[ \begin{array}{c;{2pt/2pt}c} -2 & -4 \\ 2 & -1 \\ -8 & 16 \end{array} \right]$$
\end{document}


To obtain

• Unfortunately, it does not work for me; it (TeXStudio) says: Package array Error: Illegal pream-token (;): c' used. \begin{array}{c;{2pt/2pt}c} Package array Error: Illegal pream-token (2pt/2pt):c' used. \begin{array}{c;{2pt/2pt}c} – Alex Konnen Dec 13 '19 at 19:04
• @AlexKonnen works fine here. add a MWE and I'll try to see what happens. – Denis Dec 18 '19 at 7:34
• I have found the reason why it did not work: my document included \usepackage{tabularx}; I assume that \usepackage{arydshln} is somehow incompatible with the latter; if I remove tabularx, the code works, with tabularx it does not. – Alex Konnen Dec 19 '19 at 19:38
• The vertical dashes seem to end with a short bold dash. Can this be avoided? – Anush Jul 24 at 8:24
• You can try to modify the option of the dashed line. Here I set 2pt / 2pt. – Denis Jul 24 at 10:06