# Adding an Image inside tcolorbox

I have a quick question regarding LaTeX's ability to add a small image inside a tcolorbox. What I am trying to accomplish is an entire line with a red color fill and left aligned white text and an image at the end of the line (The image is a rectangular with identical height as the line. Here is the code which I would like to add an image to.

\begin{tcolorbox}[
breakable,
left=0pt,
right=0pt,
top=8pt,
bottom=8pt,
colback=red,
colframe=red,
width=\textwidth,
enlarge left by=0mm,
boxsep=5pt,
arc=0pt,
outer arc=0pt,
]
\Large
\textbf{\textcolor{white}{Left Aligned Text} }
\end{tcolorbox}


Currently when I add an \includegraphics command it ruins the dimensions of the colorbox above.

Thank you for the help.

-
Using \smash{\includegraphics[width=1cm,height=1cm]{demo}} will add it without distorting the box. You may need a \raisebox to vertically get it where you want. –  Steven B. Segletes Apr 3 '14 at 18:24
Thank you very much. It works! –  Stas Apr 3 '14 at 18:46

Based on my comment, I \smashed the \includegraphics and used a \raisebox to center it.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tcolorbox}
\begin{document}
\begin{tcolorbox}[
%      breakable,
left=0pt,
right=0pt,
top=8pt,
bottom=8pt,
colback=red,
colframe=red,
width=\textwidth,
enlarge left by=0mm,
boxsep=5pt,
arc=0pt,
outer arc=0pt,
]
\Large
\textbf{\textcolor{white}{Left Aligned Text}
\hfill\smash{\raisebox{-11pt}{\includegraphics[width=1cm,height=1cm]{demo}}}
}
\end{tcolorbox}
\end{document}


-
Thank you! that was helpful, I appreciate it. –  Stas Apr 6 '14 at 23:12

Here's what worked for me, assuming that you wanted the image to be as high as the text in the line, not as high as the colored line itself.

\textbf{\textcolor{white}{Left Aligned Text}
\newlength{\somelength}
\settoheight{\somelength}{\hbox{A}}\hfill
\includegraphics[height=\somelength]{/home/nickie/lib/images/picsig.jpg}}


The A inside the \hbox serves the purpose of finding the height of the text and setting \somelength to its value. Then, this length is used as the height of the picture.

Notice that I had to remove breakable and outer arc from my source code, as I think I have an older tcolorbox. So, if what you get is slightly different, this may be reasonable.

If I'm wrong and you wanted the image to be bigger than the text's height, then you need something like \smash that Steven suggested (in his comment and answer) but you'll have to place it yourself where you want it.

-
Thank you! that works. –  Stas Apr 6 '14 at 23:12