# 1 horizontal and 1 vertical line needs to be a different color in my table

I could not figure out how to do dotted vertical and horizontal lines. My boss said that I could use a different colored line if needed.

Is there a way to do that with the boxes below? I would like to make them a thicker blue line instead of the dotted lines.

Here's my code for the first box. The picture of what it needs to look like is below:

\begin{center}
\begin{tabular}{|ccc|cc|c|c|}
\hline
2 & 1 & 4 & 1 & 0 & 0 & 10 \\
0& 5 & -1 & 0& 1 & 0 & 6 \\
\hline
3 & 7 & -8 & 0 & 0 & 1 & 9 \\
\hline
0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\hline
\end{tabular}
\end{center}


A small variation of nice @Bernard answer:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{bm}
\usepackage{arydshln, collcell}
\newcolumntype{C}{>{\collectcell\bm\mathsf}c<{\endcollectcell}}

\begin{document}
$\renewcommand\arraystretch{1.5} \begin{array}{|CCC|CC|C:C|} \hline 2 & 1 & 4 & 1 & 0 & 0 & 10 \\ 0 & 5 & -1 & 0 & 1 & 0 & 6 \\ \hdashline 3 & 7 & -8 & 0 & 0 & 1 & 9 \\ \hline 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline \end{array}$
$\renewcommand\arraystretch{1.5} \begin{array}{|CCC|CC|C!{\color{blue}\vline}C|} \hline 2 & 1 & 4 & 1 & 0 & 0 & 10 \\ 0 & 5 & -1 & 0 & 1 & 0 & 6 \\ \arrayrulecolor{red}\hline\arrayrulecolor{black} 3 & 7 & -8 & 0 & 0 & 1 & 9 \\ \hline 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline \end{array}$
\end{document}

• thank you so much! – Erika Olsen Dec 10 '19 at 20:06
• @ErikaOlsen, you are welcome! – Zarko Dec 10 '19 at 20:12

Here is a solution for both possibilities:

\documentclass[11pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{array}
\usepackage{amssymb, mathtools}
\usepackage[table, svgnames]{xcolor}
\usepackage{arydshln}
\setlength\dashlinedash{3pt}
\setlength\dashlinegap{2pt}

\begin{document}

\begin{center}
\sffamily\bfseries\setlength{\extrarowheight}{2pt}
\begin{tabular}{|ccc|cc:c|c|}
\hline
2 & 1 & 4 & 1 & 0 & 0 & 10 \\
0& 5 & --1 & 0& 1 & 0 & 6 \\
\hdashline
3 & 7 & --8 & 0 & 0 & 1 & 9 \\
\hline
0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\hline
\end{tabular}
\vskip 1cm
\begin{tabular}{|ccc|cc|c!{\color{Gold}\vrule}c|}
\hline
2 & 1 & 4 & 1 & 0 & 0 & 10 \\
0& 5 & --1 & 0& 1 & 0 & 6 \\
\arrayrulecolor{IndianRed}\hline
3 & 7 & --8 & 0 & 0 & 1 & 9 \\
\arrayrulecolor{black}\hline
0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\hline
\end{tabular}
\end{center}

\end{document}


Edit: You even can have both: coloured and dashed rules:

{%
\arrayrulecolor{IndianRed}
\begin{tabular}{!{\color{black}\vrule}ccc!{\color{black}\vrule}cc:c!{\color{black}\vrule}c!{\color{black}\vrule}}
\arrayrulecolor{black} \hline
2 & 1 & 4 & 1 & 0 & 0 & 10 \\
0& 5 & --1 & 0& 1 & 0 & 6 \\
\arrayrulecolor{Gold} \hdashline
3 & 7 & --8 & 0 & 0 & 1 & 9 \\
\arrayrulecolor{black} \hline
0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\hline
\end{tabular}
}%


• uf, you beat me for 4 seconds :-( – Zarko Dec 9 '19 at 19:26
• Sorry for that, @Zarko. I can withdraw my answer if you wish. – Bernard Dec 9 '19 at 19:29
• No, no, now I looking for different version of answer – Zarko Dec 9 '19 at 19:36
• If you know a way to colour dashed lines, it would be very nice! – Bernard Dec 9 '19 at 19:38
• No, i dont know how to color vertical dashed rules. However, you show us, how to do this! +1!!! – Zarko Dec 9 '19 at 20:13