Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Latex code for adjusting attributes of hline (color, dashed), and/or attributes of vertical lines in table

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}
like image 335
mshaffer Avatar asked Oct 09 '10 16:10

mshaffer


People also ask

How do I change the color of a line in LaTeX?

Two new commands are also used in the example: \textcolor{red}{easily} : Changes the colour of inline text. This command takes two parameters, the colour to use and the text whose colour is changed. In the example the word easily is printed in red.

How do I change the color of a table in LaTeX?

Colors in Tables We need xcolor package with the table option to introduce colors to our tables, we can add it with \usepackage[table]{xcolor} command. To add color only to a single cell, there is a \cellcolor{<color>} command, which needs to be placed in the cell.

How do I make a vertical line in LaTeX?

In LaTeX text mode, the vertical bar produces an em dash (—). The \textbar command can be used to produce a vertical bar.


1 Answers

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}
like image 160
Mia Clarke Avatar answered Nov 05 '22 23:11

Mia Clarke