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

Try

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

To obtain

enter image description here


I will add another simple solution if you like.

enter image description here

\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).

Result of the second code

Tags:

Matrices