我的表格中的 1 条水平线和 1 条垂直线需要使用不同的颜色

我的表格中的 1 条水平线和 1 条垂直线需要使用不同的颜色

我不知道如何画垂直和水平虚线。老板说如果需要的话我可以使用不同颜色的线。

有没有办法对下面的框进行同样的操作?我想让它们变成更粗的蓝线,而不是虚线。

这是我为第一个框编写的代码。它需要的外观如下图所示:

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

在此处输入图片描述

答案1

@Bernard 的回答有一点变化:

在此处输入图片描述

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

答案2

以下是针对这两种可能性的解决方案:

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

在此处输入图片描述

编辑:你甚至可以同时拥有彩色和虚线规则:

{%
\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}
}%

在此处输入图片描述

相关内容