Graphics, Figures & TablesCreate a box with image and text

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
joemburgess
Posts: 5
Joined: Fri Jan 08, 2010 7:46 pm

Create a box with image and text

Post by joemburgess »

Hello,

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?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Create a box with image and text

Post by gmedina »

Hi,

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?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
joemburgess
Posts: 5
Joined: Fri Jan 08, 2010 7:46 pm

Re: Create a box with image and text

Post by joemburgess »

Im sorry I have attached a link of sort of what I wanted. I want to be able so do a sort of
\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
Screenshot.png (13.81 KiB) Viewed 4006 times
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Create a box with image and text

Post by gmedina »

In the following example I defined the new environment myenv that can give you some ideas:

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}
The basic idea was to use the shaded environment, provided by the framed package, and some of the features provided by the PGF/TiKZ package. Please refer to the documentation of the packages used.

Of course, feel free to adapt my example according to your needs.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply