3

Dear community members,

I want to draw a 3D fancy box by coupling the first box (wich has a simple rectangle) and the second one. Have you any ideas?

enter image description here These are the Latex codes for the first and the second boxes, respectively.

First code (written outside the \begin{document} environment):

\usepackage{tikz}
\usetikzlibrary{calc}
\xdefinecolor{mycolor}{HTML}{1475bb} % Neutral Blue
\colorlet{bancolor}{mycolor}

\def\bancolor{mycolor}
\newenvironment{mybox}[3][]{%
\begin{tikzpicture}[#1]%
    \def\myboxname{#3}%
    \node [draw, line width=0.5mm, inner sep=1.5ex,text width=#2]% good 
options: minimum height, minimum width  , fill={mycolor!30}
    (BOXCONTENT) \bgroup\rule{0pt}{3ex}\ignorespaces
}{%
\egroup;
\node [right,inner xsep=1em,fill=bancolor!50,outer sep=0pt,text 
height=2ex,text depth=.5ex, text =black, font=\bf] (BOXNAME) 
at ([shift={(-1em,0pt)}]BOXCONTENT.north west) {\myboxname};
\fill[bancolor] (BOXNAME.north east) -- +(-1em,1em) -- +(-1em,0) -- cycle;
\fill[bancolor] (BOXNAME.south west) -- +(1em,-1em) -- +(1em,0) -- cycle;
\end{tikzpicture}
}

I call it inside the \begin{document} environment as follows:

\begin{mybox}{\textwidth}{Title}
    \justifying
    Hello World!
\end{mybox}

Second code (written within the \begin{document} environment):

\smartdiagramset{
    uniform color list=gray!60!black for 2 items,
    back arrow disabled=true,
}
\smartdiagram[flow diagram:horizontal]{PGF}

Regards. Widad

7

Here is an implementation with tcolorbox and TikZ.

\documentclass{article}

\usepackage{blindtext}

\usepackage[most]{tcolorbox}

\usetikzlibrary{calc}

\definecolor{bluebg}{rgb}{0.5,0.7,0.84}
\definecolor{trianglebg}{rgb}{0.09,0.41,0.69}


\makeatletter
\tcbset{%
  decorationwidth/.store in=\kv@decoration@width,
  decorationwidth=10pt,
  boxedtitlecolor/.colorlet=tcbcol@boxedtitle,
  decorationcolor/.colorlet =tcbcol@decorationcolor,
  decorationcolor=trianglebg,
  boxedtitlecolor=bluebg,
}
\newtcolorbox[auto counter]{myboxother}[2][]{%
  enhanced, sharp corners,
  drop shadow,
  attach boxed title to top left={xshift=-\kv@decoration@width,yshift=-\tcboxedtitleheight/2,yshifttext=-\tcboxedtitleheight/2},
  coltitle=black,
  boxed title style={toprule=0pt,bottomrule=0pt,leftrule=0pt,frame hidden,enhanced,colback=tcbcol@boxedtitle,sharp corners},
  underlay boxed title={ 
    \coordinate (refpointsouth) at ($(title.south west)+(0pt,0mm)$);
    \filldraw[line width=0pt,tcbcol@decorationcolor] 
    (refpointsouth)  -- ($(refpointsouth) + (\kv@decoration@width,0)$) -- +(0pt, -\kv@decoration@width) -- cycle;
    \coordinate (refpointnorth) at ($(title.north east)-(\kvtcb@left@rule-0.25pt,0pt)$);
    \filldraw[line width=0pt,tcbcol@decorationcolor]
    (refpointnorth)  -- ($(refpointnorth) + (-\kv@decoration@width,0pt)$) -- ($(refpointnorth) +(0pt, \kv@decoration@width)$) -- cycle;
    }
  ,
  title={#2},#1,  
}
\makeatother

\begin{document}

\begin{myboxother}[decorationwidth=15pt]{My title}
  Hello World

  \blindtext
\end{myboxother}


\begin{tcolorbox}[enhanced,interior style={top color=white,bottom color=white!60!black}, drop shadow]
  Hello World
  \blindtext
\end{tcolorbox}

or a small box

\tcbox[enhanced,interior style={top color=white,bottom color=white!60!black}, drop shadow south]{Hello World}

\end{document}

enter image description here

| improve this answer | |

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.