【问题标题】:Latex code for adjusting attributes of hline (color, dashed), and/or attributes of vertical lines in table用于调整 hline 属性(颜色,虚线)和/或表格中垂直线属性的乳胶代码
【发布时间】:2010-10-09 16:48:55
【问题描述】:

我想给hline上色,例如:

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

什么的。

以下是失败的微弱尝试。我将 textcolor gray 放在 {|} 周围,以尝试使其变为灰色。理想情况下,我希望它是灰色和虚线。还要注意 {\hline} 标签周围的 textcolor gray。使用乳胶语法将不胜感激任何帮助。

\hline 有属性吗?如果是这样,文档在哪里?我喜欢 php.net 是有原因的,以满足我的其他编程需求。

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

【问题讨论】:

    标签: colors latex line pdflatex


    【解决方案1】:

    首先,导入颜色包,如下:

    \usepackage{color} 
    

    然后使用arydshln package,并执行此操作(在表格上下文中):

    \textcolor{gray}{\hdashline}
    

    【讨论】:

      【解决方案2】:

      只需使用官方包;)

      在序言中写下:

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

      使用 \grayline 与您的表中的 \hline 完全相同。

      【讨论】:

      • 不错!如何设置线条的粗细?
      • @WizardofKneup,我只在巫师不使用我的帮助执行任何咒语的情况下帮助他们。在this TeX SX question 的示例中,您有更改长度的代码。你是个聪明人,我相信你会结合这两个代码;)。
      • 所以它是\arrayrulewidth。谢谢!