3

I am using tikz and minipage to create a note box inside a description list. The problem I am facing is that I practically do not have any control over the positioning of the minipage and the corresponding note text. I would want to position the note text in such a manner in which the surrounding text is not wrapped around it (by which I mean no inline embedding), and I could position the note box in accordance with the layout of the page (say take it left, or right, or position it around the center, et al.). Can anyone suggest a method to achieve both of the above? The MWE follows.

TIA

\documentclass[11pt]{report}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes}
\begin{document}
 \begin{description}
\item[\emph{Point:}] texttexttexttexttexttexttexttexttext... 
 % copied from http://www.texample.net/tikz/examples/boxes-with-text-and-math/
\vspace{3mm}
\begin{tikzpicture}
\node [mybox] (box){%
    \begin{minipage}{0.9\textwidth}
Note text.
    \end{minipage}
};
\node[fancytitle, right=10pt] at (box.north west) {NOTE};
\node[fancytitle, rounded corners] at (box.east) {$\clubsuit$};
\end{tikzpicture}
texttexttexttexttexttexttexttexttext...
\end{description}
\end{document}
  • 1
    Forget about that. It is very old and now new weapons are available. Try tcolorbox for such note boxes. – user11232 Mar 9 '15 at 5:06
  • @HarishKumar Can you modify my code to provide me with an example? I would really appreciate it. – Vinod Mar 9 '15 at 5:07
  • @HarishKumar I could find an example from the documentation, so reusing that :)....I will accept your answer anyway..thanks for the same – Vinod Mar 9 '15 at 5:25
4

First your example:

\documentclass[11pt]{report}
\usepackage{tikz,showframe}
\usetikzlibrary{shapes,positioning}
\tikzset{mybox/.style = {draw=red, fill=blue!20, line width=1pt,
                          rectangle, rounded corners, inner sep=10pt, inner ysep=20pt},
         fancytitle/.style ={fill=red, text=white}
         }
\begin{document}
 \begin{description}
    \item[\emph{Point:}] texttexttexttexttexttexttexttexttext...

    % copied from http://www.texample.net/tikz/examples/boxes-with-text-and-math/
      \vspace{3mm}
       \begin{tikzpicture}
        \node [mybox] (box){%
           \begin{minipage}{\dimexpr\textwidth-\leftmargin-22pt\relax}
             Note text.
           \end{minipage}
          };
        \node[fancytitle, right=10pt] at (box.north west) {NOTE};
        \node[fancytitle, rounded corners,overlay] at (box.east) {$\clubsuit$};
       \end{tikzpicture}

      texttexttexttexttexttexttexttextt
  \end{description}
\end{document}

enter image description here

Now with tcolorbox

\documentclass[11pt]{report}
\usepackage[many]{tcolorbox}
\tikzset{fancytitle/.style ={fill=red, text=white}}
\newtcolorbox{mybox}[2][]{
  enhanced jigsaw,
  width=0.5\textwidth,  %% change
  colback=blue!20,
  colframe=red,
  title=#2,
  boxrule=1pt,
  left=10pt,right=10pt,top=20pt,bottom=20pt,
  attach boxed title to top left= {xshift=10pt,yshift*=-\tcboxedtitleheight/2},
  boxed title style={size=small,colback=red,colframe=green!75!black,arc=0ex},
  before=\par\vspace{3mm},
  after=\par,
  overlay unbroken and first ={
    \node[fancytitle, rounded corners] at (frame.east) {$\clubsuit$};
    },
  #1
}


\begin{document}
 \begin{description}
    \item[\emph{Point:}] texttexttexttexttexttexttexttexttext...
       \begin{mybox}{NOTE}
          Note text.
       \end{mybox}
      texttexttexttexttexttexttexttextt
  \end{description}
\end{document}

enter image description here

And an example from manual:

\documentclass[11pt]{report}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\usepackage{varwidth}
\newtcolorbox{mybox}[2][]{enhanced,
attach boxed title to top left={xshift=1cm,yshift=-2mm},
fonttitle=\bfseries,varwidth boxed title=0.7\linewidth,
colbacktitle=green!45!white,coltitle=green!10!black,colframe=green!50!black,
interior style={top color=yellow!10!white,bottom color=green!10!white},
boxed title style={enhanced,boxrule=0.75mm,colframe=white,
borderline={0.1mm}{0mm}{green!50!black},
borderline={0.1mm}{0.75mm}{green!50!black},
interior style={top color=green!10!white,bottom color=green!10!white,
middle color=green!50!white},
drop fuzzy shadow},
overlay unbroken and first ={
    \node[fill=red, text=white, rounded corners] at (frame.east) {$\clubsuit$};
    },
title={#2},#1}

\begin{document}
 \begin{description}
    \item[\emph{Point:}] texttexttexttexttexttexttexttexttext...
       \begin{mybox}{My title}
         \lipsum[2]
       \end{mybox}
      texttexttexttexttexttexttexttextt
  \end{description}
\end{document}

enter image description here

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .