I use double line spacing through \doublespacing
from setspace and I want to highlight some parts of my text with a simple tcolorbox. I want the text to be spaced equally across the box's boundaries and title. However, as the MWE below shows, the space before and after the title is too small and the space after the box is too large.
My questions:
- Why is this happening?
- What is the most natural solution?
I have played with before
, top
, size
, etc. and I can probably make it "look about right". But I'm interested in a solution that is "right by design", i.e., one that accounts for the (variable) line spacing and inserts spaces accordingly.
EDIT: The space between the box title and content can be fixed with attach title to upper, after title=\par\nobreak\noindent
; this removes the title box altogether.
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{setspace}
\tcbuselibrary{skins}
\doublespacing
\begin{document}
I'm the first paragraph to demonstrate normal spacing between paragraphs.
I'm the paragraph before the box. I'm long enough to demonstrate the double line spacing.
\begin{tcolorbox}[
blanker, left=1em, borderline west={1pt}{0pt}{gray},
fonttitle=\color{black}\bf, adjusted title=I'm the title line,
]
I'm the paragraph in the box. I'm also long enough to demonstrate the double line spacing.
\end{tcolorbox}
I'm the paragraph after the box.
\end{document}
Best Answer
There are many vertical lengths in a
tcolorbox
to make their own space Thus, instead of fight with optionsbefore
,after
,after skip
, etc., to look like there is not anytcolorbox
, I would make my own macro with a simple vertical box:Or a minipage:
In both cases the result is:
THe MWE with the second macro: