# How to put a line above the lower part of tcolorbox

How can I cover the top side of the light gray part with the same line that encloses the box?

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
% --
\begin{document}
\begin{tcolorbox}[title={Title}, center title, toptitle=1mm, bottomtitle=1mm, halign lower=center, sharp corners,%
bicolor, collower=black, colback=white, colframe=black!75, colbacklower=black!50]
\lipsum[1]
\tcblower
Text
\end{tcolorbox}
\end{document}


A simple overlay over the segmentation node can solve the problem:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
% --
\begin{document}
\begin{tcolorbox}[
title={Title},
center title,
toptitle=1mm,
bottomtitle=1mm,
halign lower=center,
sharp corners,%
bicolor,
collower=black,
colback=white,
colframe=black!75,
colbacklower=black!50,
overlay={\draw[tcbcolframe, line width=.5mm] (segmentation.west)--(segmentation.east);}]
\lipsum[1]
\tcblower
Text
\end{tcolorbox}
\end{document}


• clever solution, +1 – Ñako Jun 18 '19 at 10:34
• Nice solution. One last thing, how can I make the two boxes (the dark gray and the light gray) look the same height? Right now the bottom box looks quite a bit taller than the top one, and it becomes really apparent if one reduces both toptitle and bottomtitle. – noibe Jun 18 '19 at 12:24
• @noibe You'll have to play with margins, bottom will change space between lower text and bottom border while middle fixes separation between upper and lower text. – Ignasi Jun 18 '19 at 13:47
• @Ignasi Ok thanks. One last thing (this time for real), is it possible to extend the line a tiny tiny bit to the left and to the right, so as not to have any blank space where that line (the horizontal) meets the vertical ones? It is barely noticeable, but if you zoom in to the max you can see it (at least in my pdf viewer). – noibe Jun 18 '19 at 15:33
• @noibe Yes, adding xshift to the segmentation nodes. For example ([xshift=-1pt]segmentation.west) or ([xshift=1pt]segmentation.east) – Ñako Jun 18 '19 at 22:15

IN case, that your tcolorbox hasonly one color, this line you can draw by use of

segmentation engine=path,
segmentation style={draw=black!75, line width=1.5pt, solid}


which gives:

However, when is used bicolor option, defined colors by

colbacklower=black!50,


is lost, actually it is overwritten by settings for colframe=black!75:

This I would consider as bug in package. The complete code, by which I generated bot pictures is:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
% --
\begin{document}
\begin{tcolorbox}[enhanced,
title={Title}, center title, toptitle=1mm, bottomtitle=1mm,
halign lower=center, sharp corners,%
bicolor,
colback=white, colframe=black!75,
collower=white, collower=black!50,
segmentation engine=path,
segmentation style={draw=red, line width=1.5pt, solid}% red is selected that line is visible
]
\lipsum[1]
\tcblower
Text
\end{tcolorbox}
\end{document}


with plain tikz you can draw your box as follows:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usepackage{lipsum}
% --
\begin{document}

\noindent%
\begin{tikzpicture}[
mpnv/.style = {rectangle split,
rectangle split parts=3,
rectangle split part fill={black!75, white, black!50},
draw=black!75, line width=1pt,
minimum width=\linewidth, inner sep=2mm,
text width=\linewidth-2*\pgfkeysvalueof{/pgf/inner xsep},
align=justify
}%
]
\node[mpnv] {\nodepart[align=center]{one}       \textcolor{white}{Text}
\nodepart{two}                     \lipsum[1]
\nodepart[align=center]{three}     Text
};
\end{tikzpicture}
\end{document}


• Is there some other way to achieve that same result? – noibe Jun 17 '19 at 19:28
• @noibe, you can go with plain tikz (tcolorbox is actually based on it). I will try to make latter a proposal with such solution. It might happen that meanwhile someone with more knowledge provide a solution with tcolorbox or fix why it not working as expected. – Zarko Jun 17 '19 at 20:18

Adapting the solution given by egreg to the question Issue with tabularx and hbox options in tcolorbox, it is possible to achieve the desired output.

## Update (18.06.2019)

The spaces between text and frame can be set up with:

• \def\arraystretch{} for the vertical margin
• \def\tabcolsep{} for the horizontal margin

The Title can be vertically centered with the options:

• toptitle
• bottomtitle

The extra space at the bottom comes from the paragraph breaks \par after \lipsum. There are two possibilities to remove it:

• package option nopar (global option)
• starred version \lipsum* (local option)

Updated output:

Updated code:

\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{colortbl}
\usepackage{array}
\usepackage{tikz}
\usepackage{tcolorbox}
\tcbuselibrary{skins, breakable}
%\usepackage[nopar]{lipsum}
\usepackage{lipsum}

\makeatletter
\tcbset{
tabular/.style={
boxsep=\z@,top=\z@,bottom=\z@,leftupper=\z@,rightupper=\z@,
toptitle=2mm,bottomtitle=2mm,boxrule=1.5pt,
before upper={\arrayrulecolor{tcbcol@frame}\def\arraystretch{2.0}\def\tabcolsep{1.5em}%
\tcb@hack@currenvir\tabular{#1}},
after upper=\endtabular\arrayrulecolor{black!75}},
}
\makeatother

%--- from https://tex.stackexchange.com/a/381720/89320
%--- to remove space after \midrule
\newcommand{\midsepremove}{\aboverulesep = 0mm \belowrulesep = 0mm}
%----

\begin{document}

\midsepremove
\begin{tcolorbox}[
skin = enhanced,
tabular = {p{11cm}},
capture = hbox,
%  breakable = false,
title = {Title},
center title,
halign lower=center,
sharp corners,
colback=white,
center,
]
\arrayrulecolor{black!75}
\lipsum*[1]\tabularnewline %
\midrule[1.5pt]
\cellcolor{black!50} \centering Text \tabularnewline
\end{tcolorbox}

\end{document}

• Nice solution, but I see a few problems. The spacing between the text and the sides, top and bottom (especially the bottom) differs quite a lot from the original code. Also, the title doesn't seem to be vertically centered. – noibe Jun 17 '19 at 21:53
• @noibe, the spacing between text and top and bottom can be set with arraystretch{1.5}. Though, there is still an extra space at the bottom. Now I am looking for a solution. Between text and sides you can use tabcolsep. The title is not centered because a typo: toptitle=2mm,bottomtitle=1mm, should be toptitle=2mm,bottomtitle=2mm, I will update later my approach – Ñako Jun 18 '19 at 7:35