2
\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:

enter image description here

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

3 Answers 3

1

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  \\
\quad \textbf{?}
        &       &           &       \\
\end{NiceTabular}
\end{center}

\end{document}

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

Output of the above code

0

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.

code output is shown as

1
  • the ? needs to be centered
    – js bibra
    Sep 17, 2020 at 8:30
0

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}

enter image description here

You must log in to answer this question.

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