# tcolorbox: vertical spacing in a tcolorbox

How can I obtain the same vertical spacing above and below the line of text in a tcolorbox?

\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcolorbox{questions}{
colframe = red
}
\begin{document}
\begin{questions}
\centering
What is the spatial period?
\end{questions}
\end{document}


From the image, we can see that the spacing below the sentence is more than above the spacing. I tried using \vfill but nothing changed.

Also, as an additional question, can I stop indentations after a tcolorbox when a new sentence is started?

Looks can be deceiving. Because of the "p" descending letters, the vertical gap from the bottom of the "p" to the box is the same as the top of the "W" to the box (see second image). Try it with the p's removed (or \smashed as I show in the third image of this MWE). The gap is identical relative, not to the text baselines, but with respect to the actual bottom and top of the text box (second and fourth images).

\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcolorbox{questions}{
colframe = red
}
\begin{document}
\begin{questions}
\centering
What is the spatial period?
\end{questions}
\begin{questions}
\centering
\fboxsep=0pt\fbox{What is the spatial period?}
\end{questions}
\begin{questions}
\centering
What is the s\smash{p}atial \smash{p}eriod?
\end{questions}
\begin{questions}
\centering
\fboxsep=0pt\fbox{What is the s\smash{p}atial \smash{p}eriod?}
\end{questions}
\end{document}


As far as the indent,

\newtcolorbox{questions}{
nobeforeafter,
colframe = red
}


will prevent the following text from being indented. However, it will also have the effect of allowing the tcolorboxes to be indented, which you may not want. Furthermore, it will change/eliminate the padding around the box.

As an alternative, a \noindent can manually override indentation on the subsequent text.

• Thanks. I prefer the smashed look though so I will be using that. – dustin Aug 28 '13 at 15:42
• @dustin I don't know the package well enough, but you may look to see if there is a setting that will allow border gap to be based on a calculation of baselines, rather than on a calculation of gap distance. Just a thought. – Steven B. Segletes Aug 28 '13 at 15:53
• I am using \noindent. I just wanted a lazy way out. – dustin Aug 28 '13 at 16:19
• @dustin The nobeforeafter parameter is useful if you need to do subsequent manipulation on the box prior to typesetting, for example, stacking several of them in a custom configuration. But, as mentioned, the parameter will also strip things like padding, indentation specifications, etc. – Steven B. Segletes Aug 28 '13 at 16:30