TransWikia.com

Tabbing: Colored background

TeX - LaTeX Asked on January 4, 2021

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

One Answer

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

Answered by Abuzar Ghafari on January 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP