thick line in array environment

thick line in array environment

I am using an array environment, not tabular, which makes it impossible to use such commands as

\specialrule{.1em}{.05em}{.05em}

\Xhline{2\arrayrulewidth}

\noalign {\ifnum 0=`}\fi \hrule height 1pt
    \futurelet \reserved@a \@xhline

for making line thicker. I have solved the problem with the vertical lines by using the command

\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}

and with the horizontal lines by using

\Xhline{1pt}

Is this correct or is there a better way? I thank you very much

Carlo Alberto

답변1

They all work within the array environment. Here is a demo with makecell, boldline and booktabs. \cmidrule can even be used in the xmatrix environments:

    \documentclass{article}
    \usepackage{array, boldline, makecell, booktabs, amsmath}
    \newcommand\btrule[1]{\specialrule{#1}{0pt}{0pt}}
    \usepackage[svgnames, table]{xcolor}

    \begin{document}

  \[ \begin{array}{l!{\vline width 1pt}c | r }
      \arrayrulecolor{IndianRed} \Xhline{1pt}
      1 & 2 & 3 \\
      \hline
      4 & 5 & 6 \\
      \hline
      7 & 8 & 9 \\
      \Xhline{1pt}
    \end{array}
    \qquad
    \begin{array}{ lV{2.5}c | r }
      \hlineB{2.5}
      1 & 2 & 3 \\
      \hline
      4 & 5 & 6 \\
      \hline
      7 & 8 & 9 \\
      \hlineB{2.5}
    \end{array}
    \qquad
    \begin{array}{ l!{\color{IndianRed}\vline width 1pt}c | r }
      \arrayrulecolor{IndianRed}
      \btrule{1pt}
      1 & 2 & 3 \\
      \arrayrulecolor{black} \hline
      4 & 5 & 6 \\
      \hline
      7 & 8 & 9 \\
      \arrayrulecolor{IndianRed}\btrule{1pt}
    \end{array}
    \qquad
    \begin{bmatrix}
      1 & 2 & 3 \\
       \cmidrule(lr){1-3}
      4 & 5 & 6 \\
       \cmidrule(lr){1-2}
      7 & 8 & 9 \\
    \noalign{\setlength{\aboverulesep{-2ex}}
    \arrayrulecolor{IndianRed}\cmidrule(lr){1-3}
    \end{bmatrix}
\]
\end{document} 

enter image description here

답변2

For information, you can also draw thick rules (or whatever rule you want) in an array with the environment {NiceArray} of nicematrix. This environment is similar to the environment {array} (of array) but creates PGF/Tikz nodes under the cells, rows and columns. You can use Tikz to draw whatever rule you want with Tikz after the construction of the array.

\documentclass{article}
\usepackage{nicematrix,tikz}

\begin{document}

$\begin{NiceArray}{ccccc}
1 & 2 & 10 & 14 & 15 \\
0 & 2 & 10 & 14 & 15 \\
0 & 0 & 10 & 14 & 15 \\
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
\CodeAfter 
  \tikz \draw [thick] (2-|1) -- (2-|2) |- (3-|3) |- (4-|6) ;
\end{NiceArray}$

\end{document}

Output of the above code

관련 정보