Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm writing a programming book for novices and I'm making some text boxes to focus attention on them, like "Tips", "Warning", "Focus on" and so on. For now I'm using tcolorbox and I'm very happy with it, but I would like to add some small icons on the right (or left) side of the title bar. Another option could be to remove the title bar and add a side bar with the icon. In the manual of tcolorbox I have found several examples, but none of them show how to load images and add on the title bar. Any help would be wery appreciated.

[EDIT]

Here is a minimal example of my code:

\documentclass[10pt]{book}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage[breakable]{tcolorbox}

% ----------------------------------------------------------------
\begin{document}

\begin{tcolorbox}[breakable,arc=0mm,colback=gray!5,colframe=gray,title=Warning!]%
\lipsum[1]
\end{tcolorbox}

\end{document}
% ----------------------------------------------------------------

The code rendered: enter image description here I would like something like: enter image description here or even: enter image description here

Another option could be

\documentclass[10pt]{book}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage[breakable]{tcolorbox}

% ----------------------------------------------------------------
\begin{document}

\begin{tcolorbox}[breakable,arc=0mm,colback=gray!5,colframe=gray,leftrule=12mm]%
\lipsum[1]
\end{tcolorbox}

\end{document}
% ----------------------------------------------------------------

Rendering: enter image description here And the mokup: enter image description here

That's all :)

share|improve this question
    
An image can be loaded by \includegraphics. You can use this command as any other character. –  Marco Daniel Jul 2 '13 at 15:30
1  
Please remove the edit and ask a new question. It's very hard to change an answer after every editing. –  Marco Daniel Jul 5 '13 at 15:31

1 Answer 1

up vote 9 down vote accepted

The package tcolorbox provides the option overlay and some other friends. A simple solution for your left part can be:

\documentclass{article}
\usepackage{graphicx}
\usepackage[most]{tcolorbox}

\newtcolorbox{lattention}{breakable,enhanced,arc=0mm,colback=gray!5,colframe=gray,leftrule=12mm,%
overlay={\node[anchor=north west,outer sep=2pt] at (frame.north west) {\includegraphics[width=8mm]{attention}}; }}

\usepackage{lipsum}
\begin{document}
\begin{lattention}
\lipsum[2]
\end{lattention}

\begin{lattention}
\lipsum
\end{lattention}
\end{document}

Of course you need the picture attention. After this the result will be:

enter image description here

The adjustment is yours ;-)

share|improve this answer
    
Thank you, it's exactly what I need :) –  FloDD Jul 2 '13 at 17:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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