# How to add either dashed or colored vertical line in array, but without using arydshln?

I need to make what is called augmented matrix, using array. This requires a vertical line added before the last column.

\documentclass[12pt]{report}
\usepackage{array}
\begin{document}
$\left[\begin{array}{@{}ccc|c@{}} 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \end{array}\right]$
\end{document}


Which works well. I just like to have the vertical line, either dashed or colored say red, to make it more clear.

I can not use arydshln as this package breaks many things. It does not work when loading longtable for example, and it does not work with tex4ht.

But array on its own, works. I just do not know how to add macro either inplace or in the preamble to tell it to make that one vertical line be dashed, or different color. I prefer answer that does not use tikz also, just to keep it simple. I would like the answer to work both in lualatex and tex4ht if possible, as I compile same source code to PDF and HTML.

But if it works only in PDF (i.e using lualatex), that will be fine also.

TL 2020

• Easiest is probably using tikzmark. I'm sure we have plenty of duplicates around the side. – Alan Munn Sep 30 at 22:19

Here is a solution for a coloured vertical rule:

\documentclass[12pt]{report}

\usepackage{xcolor, array, bigstrut}

\begin{document}
$\left[\begin{array}{@{}ccc!{\color{red}\vline width 0.6pt}c@{}} 1 & 2 & 3 & 4 \bigstrut[t]\\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \end{array}\right]$
\end{document}


The package nicematrix provides a specifier : for vertical dotted lines. The package loads PGF.

\documentclass[12pt]{report}
\usepackage{nicematrix, bigstrut}
\begin{document}
$\begin{bNiceArray}{ccc:c} 1 & 2 & 3 & 4 \bigstrut[t]\\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \end{bNiceArray}$
\end{document}