Graphics, Figures & Tables ⇒ Create a box with image and text
-
- Posts: 5
- Joined: Fri Jan 08, 2010 7:46 pm
Create a box with image and text
I am trying to create a new environment that is a warning box. I am writing a technial manual and I want to be able to have a colored box with a little warning logo to the left of it. I have figured out how to make a colored box, but I can't figure out how to make a new environment that has the graphic always on the left sort of overlapping the left edge. Is this even possible?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Re: Create a box with image and text
it surely is possible. Just to be absolutely sure about your request and to provide effective help, can you please post an image (or a link to one) showing exactly the aspect and placement (with respect to the normal text) that your warning box must have?
-
- Posts: 5
- Joined: Fri Jan 08, 2010 7:46 pm
Re: Create a box with image and text
\begin{myenv}
It is important to have a backup "off-site" and "on-site"
\end{myenv}
And have the attached show up.
I am really not sure where to start, thank you everyone.
- Attachments
-
- Screenshot.png (13.81 KiB) Viewed 4141 times
Create a box with image and text
Code: Select all
\documentclass{article}
\usepackage{calc}
\usepackage{framed}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\usepackage{lipsum}
\renewenvironment{shaded}{%
\def\FrameCommand{\colorbox{blue!20}}%
\MakeFramed {\FrameRestore}}%
{\endMakeFramed}
\newlength\mylena
\newlength\mylenb
\setlength\mylena{1.5cm}
\setlength\mylenb{.9\textwidth - \mylena}
\newenvironment{myenv}
{\begin{shaded}%
\begin{minipage}[c][1cm][c]{\mylena}
\begin{tikzpicture}[remember picture,overlay]
\shade[ball color=blue!80] (0.4,0) circle (.4cm)
node {\fontsize{8mm}{11mm}\usefont{T1}{put}{b}{b}\color{white}i};
\end{tikzpicture}
\end{minipage}%
\begin{minipage}[t]{\mylenb}}
{\end{minipage}\end{shaded}}
\begin{document}
\lipsum[1]
\begin{myenv}
Some short text.
\end{myenv}
\lipsum[1]
\begin{myenv}
\lipsum[1]
\end{myenv}
\lipsum[1]
\end{document}
Of course, feel free to adapt my example according to your needs.