7

I use the easytable package to make isometric tables. This package provide the TAB (with caps) environment to make tables.

In the same time I use the xcolor package with table option to colorize cells.

The \cellcolor command provided by the table option of xcolor work correctly inside a tabular environment or other table environments except with the TAB environment.

As you can see in the following MWE, \cellcolor colorize the cell in the cell in tabular environment but not the one in TAB environment:

\documentclass{article}
\usepackage[thinlines]{easytable}
\usepackage[table]{xcolor}


\begin{document}

\begin{TAB}(e,0.4cm,0.4cm){|c|}{|c:c:c:c|}
  T \cellcolor{blue!25} \\
  ~ \\
  ~ \\
  ~ \\
\end{TAB}


\begin{tabular}{l|c|r}
  \hline
  Some & \cellcolor{blue!25}coloured & contents \\
  \hline
\end{tabular}
\end{document}

And this is his rendering: enter image description here

So, how can I force coloration of a cell in TAB environment (with xcolor or other solution, it doesn’t matter)?

1 Answer 1

2

Here is a solution using the new tabularray package (see CTAN).

\documentclass{article}

\usepackage{xcolor}
\usepackage{tabularray}

\begin{document}

\begin{tblr}{
        hlines={0.7pt, solid}, vlines={0.7pt, solid},
        hline{2-Y} = {0.5pt, dashed},
        colspec={c}, rows={4mm}, columns={4mm},
        rowsep=0mm, colsep=0mm, stretch=0,
    }
    \SetCell{blue!25}T \\
    ~ \\
    ~ \\
    ~ \\
\end{tblr}

\begin{tblr}{
        colspec={l|c|r},
        rowsep=0mm,
    }
    \hline
    Some & \SetCell{blue!25}coloured & contents \\
    \hline
\end{tblr}

\end{document}

which produces the output Colored table

Inside the tblr environment, you can use the command \SetCell to modify the apperance of the current cell. The tabularray package has different default specifications for spacing, so I modified some parameters to resemble the output of your example. Please have a look at the tabularray documentation for further information.

If you use these tables frequently, you could consider defining a new environment using these specifications as defaults.

\NewTblrEnviron{mytblr}
\SetTblrInner[mytblr]{
    hlines={0.7pt, solid}, vlines={0.7pt, solid},
    hline{2-Y} = {0.5pt, dashed},
    rows={4mm}, columns={4mm},
    rowsep=0mm, colsep=0mm, stretch=0,
}

\begin{mytblr}{c}
    \SetCell{blue!25}T \\
    ~ \\
    ~ \\
    ~ \\
\end{mytblr}

You can decide, which specifications to use as defaults. For example, if you want to specify the cell size for each table individually, just delete the line rows={4mm}, columns={4mm} and specify this in the argument of mytblr .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .