0

I have this table, based on this:

\documentclass{book}
\usepackage{colortbl}
\usepackage{hhline}

\begin{document}

\setlength{\arrayrulewidth}{2pt}

\begin{tabular}{|c|c|c|} \hline & & \ \hline & & \ \hhline{ >{\arrayrulecolor{yellow}} | >{\arrayrulecolor{black}} - >{\arrayrulecolor{yellow}} | >{\arrayrulecolor{black}} - >{\arrayrulecolor{yellow}} | >{\arrayrulecolor{black}} - >{\arrayrulecolor{yellow}} | >{\arrayrulecolor{black}} } & & \ \hhline{ >{\arrayrulecolor{yellow}} | >{\arrayrulecolor{black}} - >{\arrayrulecolor{yellow}} | >{\arrayrulecolor{black}} - >{\arrayrulecolor{yellow}} | >{\arrayrulecolor{black}} - >{\arrayrulecolor{yellow}} | >{\arrayrulecolor{black}} } & & \ \hline \end{tabular}

\end{document}

enter image description here

I want the vertical lines in the third row to be yellow.

I have read this, but the colour affects to all the rows.

  • 1
    See tabularray, some interesting examples are on pages 10, 12 in package documentation. – Zarko Jul 21 '22 at 15:54

3 Answers3

2

Example solution based on @Zarko comment:

\documentclass{book}

\usepackage{colortbl} \usepackage{tabularray}

\begin{document}

\begin{tblr}{ vlines = {1,3,5}{red}, vlines = {2,4}{blue}, } Alpha & Beta & Gamma & Delta \ Epsilon & Zeta & Eta & Theta \ Iota & Kappa & Lambda & Mu \ Nu & Xi & Omicron & Pi \ Rho & Sigma & Tau & Upsilon \ \end{tblr}

\end{document}

enter image description here

1

Like this?

enter image description here

As I mentioned in the my comment, this can be relative simple done by use of tabularray package (I use version 2022C):

\documentclass[margin=3mm]{standalone}
\usepackage{xcolor}
\usepackage{tabularray}

\begin{document} \begin{tblr}{colspec = {*{3}{Q[c]}}, hline{2-Y} = {even}{black}, hline{2-Y} = {odd}{yellow,leftpos = 0, rightpos = 0}, hline{1,Z} = {black}, vlines, } & & \ & & \ & & \ \end{tblr} \end{document}

or this:

enter image description here

\documentclass[margin=3mm]{standalone}
\usepackage{xcolor}
\usepackage{tabularray}

\begin{document} \begin{tblr}{colspec = {*{3}{Q[c]}}, hline{2-Y} = {even}{black}, hline{2-Y} = {odd}{yellow,leftpos = 0, rightpos = 0}, hline{1,Z} = {black}, vline{1,2,4} = {black}, vline{3} = {yellow}, } & & \ & & \ & & \ \end{tblr} \end{document}

Zarko
  • 296,517
0

{NiceTabular} of the package nicematrix behaves as the classical environment {tabular} (of array) but creates also PGF/Tikz nodes under the cells, columns and rows. You can use Tikz do draw whatever rule you want with any Tikz style of line.

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

\begin{document}

\begin{NiceTabular}{cccc}[hvlines] & & & \ & & & \ \CodeAfter \begin{tikzpicture} [line width = 1pt] \draw [red] (1-|1) -- (1-|2) (1-|3) -- (1-|4) ; \draw [white] (2-|2) -- (2-|5) ; \draw [densely dash dot] (2-|2) -- (2-|5) ; \draw [blue,double] (1-|2) -- (3-|2) ; \end{tikzpicture} \end{NiceTabular}

\end{document}

Output of the above code

F. Pantigny
  • 40,250