For a LaTeX/beamer presentation i want to add those nice lifted drop shadows which tcolorbox provides to all of my images. This worked fine so far for images included via includegraphics but not so fine for images drawn with tikzs (included via tikzpicture). The problem is, there is a spacing inside the tcolorbox between the tikzpicture and the right frame of the tcolorbox.
Here is my example:
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\begin{document}
\begin{tcolorbox}[enhanced,drop large lifted shadow,boxsep=0mm,left=0mm%
right=0mm,top=0mm,bottom=0mm,arc=0mm,boxrule=0.5pt]%
\begin{tikzpicture}
\draw (0.0, 0.0) grid (5.0, 5.0);
\draw [brown] (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}
\end{tcolorbox}
\end{document}
This space can get drastically reduced by adding the hbox option as I recently found out:
\begin{tcolorbox}[enhanced,drop large lifted shadow,boxsep=0mm,left=0mm,hbox,% <---- added the hox option here!
right=0mm,top=0mm,bottom=0mm,arc=0mm,boxrule=0.5pt]%
but there is still some spacing! How get I get rid of the rest?
edit: i have just noticed that tcolorbox is not the problem! The unwanted space to the right is created by Tikz. I tested this by putting the tikzpicture part only into a standalone environment and created a pdf from that (with pdflatex). The resulting pdf already had the unwanted space.
Maybe there are other reasons but tcolorbox can be ruled out though. A workaround for me at the moment is to create standalone pdfs from all of my tikzpictures (which are a lot) and then apply pdfcrop to all of them. The cropped images can be used fine within a tcolorbox then.


tcolorboxis actually atikzpicture, you're nestingticzpictureenvironments, which is not recommended, also there is a,missing in yourtcolorboxoptions list – Mar 29 '17 at 14:24hboxworks for me – Mar 29 '17 at 14:40tcolorboxpackage installed on your system? The newest is4.02, released about one month ago – Mar 29 '17 at 14:49TikZpictures where control points are needed. In this case, the boundinx box is wrong, because it includes all thesephantompoints andtcolorboxorstandalonecannot crop them because they are based in tikz boundingbox. See: http://tex.stackexchange.com/questions/43621/bounding-box-is-larger-than-expected-when-drawing-a-curved-path?noredirect=1&lq=1 – Ignasi Mar 30 '17 at 14:39