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 am writing an Article in LaTeX.

Please suggest me how to create a highlight boxes like the ones shown below in LaTeX:

enter image description here

enter image description here

share|improve this question
    
Welcome to tex.sx! It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. –  Leo Liu Aug 12 '12 at 2:23
    
Thanks, I will keep this in mind while posting next time. –  Sandeep Singh Aug 12 '12 at 2:28
add comment

3 Answers

up vote 33 down vote accepted

You can use the bclogo and/or mdframed packages; a little example:

\documentclass{book}
\usepackage{xcolor}
\usepackage[tikz]{bclogo}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}

\definecolor{bgblue}{RGB}{245,243,253}
\definecolor{ttblue}{RGB}{91,194,224}

\mdfdefinestyle{mystyle}{%
rightline=true,innerleftmargin=10,innerrightmargin=10,
outerlinewidth=3pt,topline=false,rightline=true,bottomline=false,
skipabove=\topsep,skipbelow=\topsep
}

\begin{document}

\renewcommand\bcStyleTitre[1]{\large\textcolor{ttblue}{#1}}
\begin{bclogo}[couleur=bgblue, arrondi =0 , logo=\bcbombe, barre=none,noborder=true]{Commom Programming Error}
\itshape\lipsum[4]
\end{bclogo}

\begin{mdframed}[style=mystyle,frametitle={Web addresses in text}]
\lipsum[4]
\end{mdframed}

\end{document}

enter image description here

Both packages offer you many customization possibilities and the documentations contain numerous examples.

For the second framed box, here's another option using TikZ:

\documentclass{book}
\usepackage{environ}
\usepackage{xcolor}
\usepackage[tikz]{bclogo}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}

\NewEnviron{myremark}[1]
  {\par\medskip\noindent
  \begin{tikzpicture}
    \node[inner sep=0pt] (box) {\parbox[t]{.99\textwidth}{%
      \begin{minipage}{.3\textwidth}
      \centering\tikz[scale=5]\node[scale=3,rotate=30]{\bclampe};
      \end{minipage}%
      \begin{minipage}{.65\textwidth}
      \textbf{#1}\par\smallskip
      \BODY
      \end{minipage}\hfill}%
    };
    \draw[red!75!black,line width=3pt] 
      ( $ (box.north east) + (-5pt,3pt) $ ) -- ( $ (box.north east) + (0,3pt) $ ) -- ( $ (box.south east) + (0,-3pt) $ ) -- + (-5pt,0);
    \draw[red!75!black,line width=3pt] 
      ( $ (box.north west) + (5pt,3pt) $ ) -- ( $ (box.north west) + (0,3pt) $ ) -- ( $ (box.south west) + (0,-3pt) $ ) -- + (5pt,0);
  \end{tikzpicture}\par\medskip%
}

\begin{document}

\lipsum[4]
\begin{myremark}{Web addresses in texts}
\lipsum[4]
\end{myremark}
\lipsum[4]

\end{document}

enter image description here

share|improve this answer
    
Thanks a lot for your guidance. –  Sandeep Singh Aug 12 '12 at 2:41
add comment

Here an example using mdframed whereby the symbols are taken from the package dingbat Instead of the symbols you can use every picture.

\documentclass{report} 
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{calc}
\usepackage{kantlipsum}

\usepackage{dingbat}%\eye and \leftpointright

\newcounter{error}[chapter]
\renewcommand*\theerror{\thechapter.\arabic{error}}
\tikzset{
errorsymbol/.style={%
    rectangle,draw=blue,
   ,scale=2,overlay}}

\tikzset{
 lampsymbol/.style={%
   ,scale=2,overlay}}

\newmdenv[hidealllines=true,backgroundcolor=blue!5,%
 frametitle={\stepcounter{error}Comman~Programming~Error~\theerror},
 frametitlefont=\color{blue!80!black}\bfseries,
 skipabove=\topsep,skipbelow=\topsep,nobreak,
 leftmargin=.3cm,rightmargin=.3cm, innerleftmargin=2cm,
 singleextra={\path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(2,\y1)$) node[errorsymbol] {\eye};},%
]{error}


\newmdenv[nobreak,middlelinewidth=.8pt,
 frametitlefont=\bfseries,
 leftmargin=.3cm,rightmargin=.3cm, innerleftmargin=2cm,
 skipabove=\topsep,skipbelow=\topsep,
 singleextra={\path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(2,\y1)$) node[ lampsymbol] {\leftpointright};
                          \draw[line width=.8pt,white,] ($(O|-P)+(.2cm,0)$) -- ($(P)-(.2cm,0)$); 
                          \draw[line width=.8pt,white,] ($(O)+(.2cm,0)$) -- ($(P|-O)-(.2cm,0)$);
    },%
]{lamp}

\begin{document}
\begin{error}
Use only uppercase letters in the names of enumeration constants to make these
constants stand out in a program and to indicate that enumeration constants
are variables.
\end{error}

\begin{lamp}[frametitle={Web addresses in texts}]
Use only uppercase letters in the names of enumeration constants to make these
constants stand out in a program and to indicate that enumeration constants
are variables.
\end{lamp}
\end{document}

enter image description here

share|improve this answer
add comment

It will most likely have to remain as a box that does not break across page boundaries. As such, a traditional "equation" with an image and a text box, all contained in a tabular should do:

enter image description here

\documentclass{article}
\usepackage{array}% http://ctan.org/pkg/array
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\begin{document}
\[
  \left[
      \begin{tabular}{@{\quad}m{.3\textwidth}@{\qquad}m{.6\textwidth}@{\quad}}
        \includegraphics[width=\linewidth]{example-image-a} &
          \raggedright%
          \textbf{Web addresses in texts} \par
            There's a package called \texttt{url} designed for typesetting web addresses.
            Write \mbox{\texttt{\string\usepackage\string{url\string}}} in your preamble; this will provide the
            command \mbox{\texttt{\string\url}}. This command takes an address for the argument and
            will print it out with typewriter font. Furthermore, it is able to handle
            special characters in addresses like underscores and percent signs. It even
            enables hyphenation in addresses, which is useful for websites with a very
            long name.%
      \end{tabular}
    \right]
\]
\end{document}
share|improve this answer
add comment

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.