Consider the following example, inspired from the previous post here:
\documentclass[a4paper, 10pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{array}
\usepackage[table]{xcolor}
\usepackage[skins,theorems,breakable,most]{tcolorbox}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{tabularx}
\usepackage{multicol}
\NewDocumentCommand{\tcbtab}{O{}m+m}{%
\begin{tcolorbox}[%
enhanced,
sharp corners,
titlerule = 0pt,
boxsep=0pt,
left=0pt,
right=0pt,
top=0pt,
bottom=0pt,
middle=0pt,
colframe = black,
box align=center,
halign=center,
valign=center,
boxed title style={
enhanced,
colback = black,
arc=0pt,
outer arc=0pt,
},
listing only,
title = {\centering\makebox[\linewidth][c]{#2}},%
#1%
]
#3%
\end{tcolorbox}%
}
\begin{document}
\lipsum[1]
\tcbtab[
attach boxed title to top={xshift=0mm,yshift=0mm},%
tabularx={X|p{2cm}}%
]{Title}{%
First column & Second column \\
\hline
Cell 1 & Cell 2
}
\lipsum[1]
\tcbtab[
attach boxed title to bottom={xshift=0mm,yshift=0mm},%
tabularx={X|p{2cm}}%
]{Title}{%
First column & Second column \\
\hline
Cell 1 & Cell 2
}
\end{document}
There is a one line spacing before or after the table depending on where the title is positioned. How to remove this spacing (while keeping the possibility to put the title at the top or at the bottom of the tcolorbox
?
{xshift=..., yshift= ...}
statement