# Tabbing: Colored background

\documentclass{article}

\newenvironment{mytabbing}{%
\begin{minipage}[t]{3in}
\begin{tabbing}
\hspace*{2cm}\= \hspace*{2cm}\= \hspace*{2cm}\= \hspace*{2cm} \kill
TAB-1 \> TAB-2 \> TAB-3 \> TAB-4\\
}%
{\end{tabbing}\end{minipage}}%

\begin{document}
\begin{mytabbing}
Test1 \> Test2 \> Test3 \>Test4
\end{mytabbing}

\end{document}


If I want colored background for the column names (TAB-1 ...), do I have to work in some tabular (tabularx, etc.) environment, and I have no other option? Something like:

• Please try with better option with the combination of tabularx and colortbl packages, instead of tabbing Sep 16 '20 at 8:21
• if you could upload a sketch of the desired output it would be helpful Sep 17 '20 at 0:43
• @jsbibra Added. Sep 17 '20 at 7:40

Here is the solution with the tabular environment.

\documentclass{article}

\usepackage[margin=1in]{geometry}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{amssymb}
\usepackage{tikz}

\renewcommand{\arraystretch}{2}
\newcommand{\cred}[1]{\color{red}#1}
\newcommand{\wt}[1]{\color{white}\textbf{#1}}

\begin{document}

\begin{center}
\begin{tabular}{llll}
\rowcolor{gray!60} \wt{SOUTH} & \wt{WEST} & \wt{NORTH} & \wt{EAST} \\
\tikz \draw (0,0) -- (1,0); & 1 $\clubsuit$   & Double & Pass\\
1 $\cred{\blacklozenge}$ & Pass & 2 $\clubsuit$ & Pass \\
2 $\cred{\blacklozenge}$ & Pass & 2 $\cred{\spadesuit}$& Pass \\
\hspace{0.15cm}\textbf{?}  & & & \\
\end{tabular}
\end{center}

\end{document}


The ? is now centered.

• the ? needs to be centered Sep 17 '20 at 8:30

Solution with use of the tabularray table package:

\documentclass{article}
\usepackage[margin=1in]{geometry}

\usepackage{amssymb}
\usepackage{xcolor}
\newcommand{\cred}[1]{\color{red}#1}
\newcommand{\wt}[1]{\color{white}\textbf{#1}}
\usepackage{tabularray}

\begin{document}

\begin{center}
\begin{tblr}{row{1}={font=\bfseries, bg=gray, fg=white, abovesep+=2pt},
colspec=llll,
}
SOUTH   & WEST  & NORTH     & EAST  \\
------
& 1 $\clubsuit$
& Double    & Pass  \\
1 $\cred{\blacklozenge}$
& Pass  & 2 $\clubsuit$
& Pass  \\
2 $\cred{\blacklozenge}$
& Pass & 2 $\cred{\spadesuit}$
& Pass  \\
\SetCell[c=1]{l,font=\bfseries} \;?
&       &           &       \\
\end{tblr}
\end{center}

\end{document}


Here is a solution with {NiceTabular} of nicematrix. You won't see any thin white line in the gray panel of the first row, whatever PDF you use and whatever level of zoom you use.

\documentclass{article}
\usepackage[margin=1in]{geometry}

\usepackage{amssymb}
\usepackage{xcolor}
\newcommand{\cred}[1]{\color{red}#1}
\newcommand{\wt}[1]{\color{white}\textbf{#1}}
\usepackage{nicematrix}

\begin{document}

\begin{center}
\begin{NiceTabular}{llll}[cell-space-top-limit=3pt]
\RowStyle[bold,rowcolor=gray,color=white]{}
SOUTH   & WEST  & NORTH     & EAST  \\
------
& 1 $\clubsuit$
& Double    & Pass  \\
1 $\cred{\blacklozenge}$
& Pass  & 2 $\clubsuit$
& Pass  \\
2 $\cred{\blacklozenge}$
& Pass & 2 $\cred{\spadesuit}$
& Pass  \\

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).