0

I'm using tcolorbox which recommends not using float environments like figure and table inside a box, and instead suggests directly using includegrapghics and tabular combined with \captionof.

I guess one of the things a figure environment does is adding vertical spacing at the end. How can I achieve a similar thing for all my includegraphics? I can of course add vspace but is there a property I can set globally?

1

Do you want to add the space inside of the tcolorbox? If so, you can use the trim option for the \includegraphics command and set it globally via \setkeys{Gin}{trim=}.

\documentclass[12pt, a4paper]{scrartcl}
\usepackage{graphicx, tcolorbox}

\begin{document}

Here is a figure 
\begin{tcolorbox}[width=8cm]
    \centering
    \includegraphics[scale=0.5]{example-image-a}
\end{tcolorbox}
without vertical spacing of 2cm \\ 

\setkeys{Gin}{trim=0pt -2cm 0pt -0cm}

And a figure 
\begin{tcolorbox}[width=8cm]
    \centering
    \includegraphics[scale=0.5]{example-image-b}
\end{tcolorbox}
with vertical spacing of 2cm below \\

\end{document}

This can add (or subtract, depending on the sign) a vertical space (here 2cm) above or below the image. However this only adds space inside of the tcolorbox:

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.