2

I need to draw a rectangle with a shadow effect with color. Please help

Actual result

Actual result

Expected Result

Expected Result

The following is my code please help

    \documentclass{article}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{calc}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\newtcolorbox{mybox}{
  colback=white!5!white,
  width=0.70\textwidth,
  left=3pt,
  right=3pt,
  top=3pt,
  bottom=3pt,
  skin=freelance,
  frame code={%
    \begin{pgfonlayer}{foreground}  
    \draw[line width = 1pt,color = white!30] ($(frame.south west) +(-1pt,-1pt)$) rectangle ($(frame.north east)+(1pt,1pt)$); %% outer rectangle
    \clip (frame.south west) rectangle (frame.north east);
    \draw[line width = 1pt,color=black!10!black,fill = white] (frame.south west) circle (7pt);
    \draw[line width = 1pt,color=black!10!black,fill = white] (frame.north west) circle (7pt);
    \draw[line width = 1pt,color=black!10!black,fill = white] (frame.north east) circle (7pt);
    \draw[line width = 1pt,color=black!10!black,fill = white] (frame.south east) circle (7pt);
      \draw[line width = 5pt,color=black!5!black]
           ($(frame.south west) +(0pt,7pt)$) -- ($(frame.north west)+(0pt,-7pt)$)  ; %% west
      \draw[line width = 1.8pt,color=black!5!black]
           ($(frame.north west) +(7pt,0pt)$) -- ($(frame.north east)+(-7pt,0pt)$)  ; %% north
      \draw[line width = 1.8pt,color=black!5!black]
           ($(frame.north east) +(0pt,-7pt)$) -- ($(frame.south east)+(0pt,7pt)$)  ; %% east
      \draw[line width = 1.8pt,color=black!5!black]
           ($(frame.south west) +(7pt,0pt)$) -- ($(frame.south east)+(-7pt,0pt)$)  ; %% south      
    \end{pgfonlayer}
  },
}


\begin{document}

\begin{mybox}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida
mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus
et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra
metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus
eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium
quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean
faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Cur-
abitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue
eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim
rutrum.
\end{mybox}

\lipsum[1-10]

\end{document}
4

I suppose you want to have this?

\documentclass{article}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{calc,shadows.blur}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\newtcolorbox{mybox}{
  width=0.70\textwidth,
  left=3pt,
  right=3pt,
  top=3pt,
  bottom=3pt,
  skin=freelance,
  frame code={%
    \begin{pgfonlayer}{main}
      \path[fill=yellow!20,blur shadow={shadow xshift=4pt,shadow yshift=-4pt}] 
        ($(frame.north west)+(7pt,0)$) arc (0:-90:7pt) -- 
        ($(frame.south west)+(0,7pt)$) arc (90:0:7pt) -- 
        ($(frame.south east)+(-7pt,0)$) arc (180:90:7pt) -- 
        ($(frame.north east)+(0,-7pt)$) arc (270:180:7pt) -- cycle;
    \end{pgfonlayer}
  },
  interior code={%
    \path[draw,line width=1pt] 
      ($(frame.north west)+(7pt,0)$) arc (0:-90:7pt) -- 
      ($(frame.south west)+(0,7pt)$) arc (90:0:7pt) -- 
      ($(frame.south east)+(-7pt,0)$) arc (180:90:7pt) -- 
      ($(frame.north east)+(0,-7pt)$) arc (270:180:7pt) -- cycle;
  },
}


\begin{document}

\begin{mybox}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida
mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus
et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra
metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus
eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium
quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean
faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Cur-
abitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue
eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim
rutrum.
\end{mybox}

\lipsum[1-10]

\end{document}

enter image description here

  • Great is it possible to increase the arc size like the above image. – Shalu Apr 6 at 10:03
  • @Shalu In the \path commands, you may see many 7pts. If you want to increase the arc size, just change 7pt to 9pt for example. – user156344 Apr 6 at 10:10
  • how to change the shadow to the left side, please help – Shalu Apr 11 at 6:50
  • @Shalu Just edit the code inside pgfonlayer{main} to whatever you want. – user156344 Apr 11 at 6:51
  • @Shalu If you have a new question, please ask it with details so that I (and many other people) may have a look. – user156344 Apr 11 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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