3

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

Using answer in adding-vertical-line-equal-sign-to-augmented-bmatrix-without-using-array show hows to add vertical line. Here is the answer:

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

enter image description here

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
7

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}

enter image description here

| improve this answer | |
7

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}

Output of the above code

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.