6

I want to color hline, e.g.:

\hline[color=red,width=2mm,dashed]

or something.

Below is a feeble attempt which fails. I put textcolor gray around {|} to try and make it gray. Ideally, I want it gray and dashed. Also note textcolor gray around the {\hline} tag. Any help would be appreciated using latex syntax.

Are there attributes for \hline? If so, where is the documentation?. There is a reason I love php.net for my other programing needs.

    \begin{array}{c\textcolor{gray}{|}cccccccccc}
 & \textcolor{gray}{P_1} & \textcolor{gray}{P_2} & \textcolor{gray}{P_3} & \textcolor{gray}{P_4}  & \textcolor{gray}{P_5} & \textcolor{gray}{P_6} & \textcolor{gray}{P_7} & \textcolor{gray}{P_8} & \textcolor{gray}{P_9} & \textcolor{gray}{P_{10}}\\
 \textcolor{gray}{\hline}
\textcolor{gray}{P_1}   &0&0&0&0&0&0&0&0&0&0\\
\textcolor{gray}{P_2}   & 0&0&0&0&0&0&0&0&0&0\\
\textcolor{gray}{P_3}   &0&0&0&0&0&0&0&0&0&0\\
\textcolor{gray}{P_4}   &0&1&1&0&0&0&0&0&0&0\\
\textcolor{gray}{P_5}   &1&1&0&0&0&0&0&0&0&0\\
\textcolor{gray}{P_6}   &0&0&0&0&0&0&0&0&0&0\\
\textcolor{gray}{P_7}   &1&1&0&0&1&1&0&0&0&0\\
\textcolor{gray}{P_8}   &1&0&0&1&0&1&0&0&0&0\\
\textcolor{gray}{P_9}   &0&0&1&0&0&0&0&0&0&0\\
\textcolor{gray}{P_{10}}  &0&0&0&0&0&1&0&1&0&0
\end{array}
Nicolás Ozimica
  • 9,481
  • 5
  • 38
  • 51
mshaffer
  • 959
  • 1
  • 9
  • 19

2 Answers2

7

First, import the color package, like so:

\usepackage{color} 

And then use the arydshln package, and do this (in a tabular context):

\textcolor{gray}{\hdashline}
Mia Clarke
  • 8,134
  • 3
  • 49
  • 62
1

Just use the official packages ;)

Write following in the preamble:

\usepackage{xcolor}
\usepackage{colortbl}
%It sets your colour line and then sets back to default (black)
\newcommand{\grayline}{\arrayrulecolor{gray}\hline\arrayrulecolor{black}}

Use \grayline exactly like \hline in your table.

loved.by.Jesus
  • 2,266
  • 28
  • 34
  • nice! how to set the thickness of the line? – Wizard of Kneup Nov 16 '21 at 19:14
  • @WizardofKneup, I help Wizards only under the condition that they do not use my help to perform any spells. In the example of [this TeX SX question](https://tex.stackexchange.com/questions/124155/variable-width-horizontal-rules-with-cline-intrude-cell-text) you have the code to change the length. You are a clever guy, I am sure you'll get to combine both codes ;). – loved.by.Jesus Nov 17 '21 at 21:15
  • So it's `\arrayrulewidth`. Thanks! – Wizard of Kneup Nov 19 '21 at 05:02