Quantcast
Channel: Matching width of Caption background with Table width - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by user11232 for Matching width of Caption background with Table width

$
0
0

You have tagged tcolorbox but not using it!. Here is a version using your own code. I have commented the changes made in the code.

\documentclass{article}\usepackage[usenames,svgnames,dvipsnames]{xcolor}\usepackage{booktabs}\usepackage{array}\usepackage[font={bf}]{caption}\captionsetup[table]{box=colorbox,boxcolor=orange!20}\begin{document}%===========================================\section{ Gender Distribution}%===========================================\begin{center}\fboxsep0pt %% <<<--- add this.\fcolorbox{yellow!20}{yellow!20}{%\parbox{\textwidth}{%\fboxsep5pt% %%<<--- add this here for making caption's height large\centering%\setlength{\abovecaptionskip}{10pt}%\setlength{\belowcaptionskip}{-3pt}   %% <<<--- this messes up\captionof{table}{Duration of Use and Gender Distribution}\begin{tabular}{>{\hspace{1pc}}c>{\hspace{1pc}}c>{\hspace{1pc}}c>   {\hspace{1pc}}c<{\hspace{1pc}}}\toprule& Female & Male & All \\\midrule1 year- 2 years & 2 (50) & 2 (13.3) & 4 \\2 years - 3 years & 0 (0) & 4 (26.7) & 4 \\3 years +& 1 (25) & 3 (20) & 4 \\6 months- 1 year & 1 (25) & 3 (20) & 4 \\Less than 6 months & 0 (0) & 3 (20) & 3 \\\midruleTotal & 4 & 15 & 19 \\\bottomrule\footnotesize{Source:Airtel Survey}\end{tabular}}%   %<<<<--- % needed here%   <<<--- don't leave blank line here for better}\end{center}\end{document}

enter image description here


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>