TransWikia.com

beamer shading columns and highlight extra

TeX - LaTeX Asked on July 26, 2021

I would like to have two middle columns in a grey background (constant) and on the top to overlay a square to highlight something in particular (just to enter at some point). An example of of what I would like follows – numbers are different from my MVE.

    documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage{psfrag}
usepackage{tikz}
usetikzlibrary{intersections,patterns,pgfplots.fillbetween}
usetikzlibrary{decorations.pathreplacing}
usepackage{booktabs, dcolumn}
usepackage{fontawesome}
usetheme{CambridgeUS}
usecolortheme{seahorse}
usepackage{multirow}
usepackage{hyperref}
usepackage{pgfplots}
usepgfplotslibrary{dateplot}
usepackage{datetime}
usepackage[scale=2]{ccicons}
newdateformat{monthyeardate}{%
  monthname[THEMONTH], THEYEAR}
usepackage{animate}
%usepackage{colortbl}
usepackage[beamer,customcolors]{hf-tikz}
usetikzlibrary{calc}
title{beamer}
% To set the highlighting boxes red.
tikzset{%
    hl/.style={
align=center,
set fill color=white,
    set border color=red,
 right offset={0.35,-0.2},
  },
hl2/.style={
align=center,
set fill color=gray!10,
    set border color = white,
right offset={0.35,-0.2},
  },
}


begin{document}

maketitle

begin{frame}
begin{table}
    centering
begin{tabular}{l*{6}{c}}
toprule
                   & multicolumn{2}{c}{x} & tikzmarkin<1->[hl2]{c} multicolumn{2}{c}{y} & multicolumn{2}{c}{555} 
                  cmidrule(r){2-3} cmidrule(r){4-5} cmidrule(r){6-7} &multicolumn{1}{c}{Probit}&multicolumn{1}{c}{Heckman Prob}&multicolumn{1}{c}{Probit}&multicolumn{1}{c}{Heckman Prob}&multicolumn{1}{c}{Probit}&multicolumn{1}{c}{Heckman Prob}
                  & (1) & (2) & (3) & (4) & (5) &(6) 

midrule
wwwww &      75  &    85   &      850  &      980&    00   &       800
                    &    80   &    1400   &    250  &    70 &    199   &   60   

multicolumn{7}{l}{cccccccccccccccc}                     
1                   &  tikzmarkin<2>[hl]{bH5}   50 &      30 &    40 &     10 tikzmarkend{c}tikzmarkend{bH5} &      20       5
end{tabular}
end{table}
end{frame}
end{document}

enter image description here

One Answer

As starting point: use tikzmark library (recent version). After removing not used packages from preamble and comment others, which are load by beamer the mwe (minimal working example) is:

documentclass[xcolor=table]{beamer}
usetheme{CambridgeUS}
usecolortheme{seahorse}
%usepackage[utf8]{inputenc}    % default at recent version of document classes
%usepackage{psfrag}
usepackage{fontawesome}
usepackage{tikz}
usetikzlibrary{fit,            % new
                tikzmark}       % new
usepackage{booktabs,
            cellspace,          % new
            multirow}
setlengthcellspacetoplimit{4pt}
setlengthcellspacebottomlimit{4pt}
%addparagraphcolumntypes{X}  % in case of use tabularx

%usepackage{multirow} doesn't exist
%usepackage{hyperref} loaded by beamer
%usepackage{colortbl} loaded by beamer option "xcolor=table"

begin{document}
%maketitle

begin{frame}
begin{table}
    centering
    renewcommand{aboverulesep}{0pt}
    renewcommand{belowrulesep}{0pt}
begin{tabular}{l cc
    >{columncolor{gray!30}}Sc
    >{columncolor{gray!30}}Sc
                cc}
toprule
        & multicolumn{2}{c}{x}
                & multicolumn{2}{c}{cellcolor{gray!30}{y}}
                        & multicolumn{2}{c}{555}
                        
        cmidrule(r){2-3} cmidrule{4-5} cmidrule(l){6-7}
        & Probit    & HP    &  Probit   & HP    & Probit    & HP    
        & (1)       & (2)   & (3)       & (4)   & (5)       & (6)   
midrule
wwwww   & 75        & 85    & 850       & 980   & 00        & 800   
        & 80        & 1400  & 250       & 70    & 199       & 60    
multicolumn{3}{l}{cccccccccccccccc}
                            &           &       &           &       
1       &  tikzmarknode{a}{50}
                    &       &    40     & 10    & tikzmarknode{b}{20}
                                                            & 5      
    midrule[heavyrulewidth]
multicolumn{7}{l}{HP: Heckman Prob}
end{tabular}
end{table}
    begin{tikzpicture}[overlay,remember picture]
node[draw=red, thick, inner sep=2pt, rounded corners, fit=(a) (b)] {};
    end{tikzpicture}
end{frame}
end{document}

after two compilation it gives:

enter image description here

Correct answer by Zarko on July 26, 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