使用 tcolorbox 和 tikz 重现下图

使用 tcolorbox 和 tikz 重现下图

我想使用tcolorbox和重现下图。需要使用和 箭头连接进行tikz一些节点调整 。tcolorbox

在此处输入图片描述

我的代码是

\documentclass[border=10pt]{standalone}
%\documentclass[border=10pt]{article}

\usepackage{enumitem}
\setlist[itemize]{leftmargin=*, itemsep = 0em}
\usepackage[none]{hyphenat}

\usepackage{tikz}
\usetikzlibrary{matrix, shapes, arrows, positioning}

\usepackage[most]{tcolorbox}

\begin{document}


\newtcolorbox{GreenBox}[2][]{%
   enhanced,
   colback   = green!5!white,
   colframe  = green!75!black, 
   arc       = 4mm, 
   outer arc = 1mm, 
   fonttitle = \huge\slshape\textbf,
   center title, 
   title     = #2,
   #1}


\newtcolorbox{RedBox}[2][]{%
   enhanced,
   colback   = red!5!white,
   colframe  = red!95!black, 
   arc       = 4mm, 
   outer arc = 1mm, 
   fonttitle = \huge\slshape\textbf,
   center title, 
   title     = #2,
   #1}

\newtcolorbox{BrownBox}[2][]{%
   enhanced,
   colback   = brown!5!white,
   colframe  = brown!75!black, 
   arc       = 4mm, 
   outer arc = 1mm, 
   fonttitle = \huge\slshape\textbf,
   center title, 
   title     = #2,
   #1}

\newtcolorbox{BlueBox}[2][]{%
   enhanced,
   colback   = blue!5!white,
   colframe  = blue!75!black, 
   arc       = 4mm, 
   outer arc = 1mm, 
   fonttitle = \huge\slshape\textbf,
   center title, 
   title     = #2,
   #1}
   
\begin{GreenBox}{ASD}

  \begin{RedBox}[width=3cm, remember as=box1, nobeforeafter]{A}
  \begin{itemize}
  \item A
  \item B
  \end{itemize}
  \end{RedBox}
  \hfill
  \begin{RedBox}[width=3cm, remember as=box2, nobeforeafter]{B}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{RedBox}
  \hfill
  \begin{RedBox}[width=3cm, remember as=box3, nobeforeafter]{C}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{RedBox}
  \vspace{2cm}
  \begin{RedBox}[width=3cm, remember as=box4, nobeforeafter]{D}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{RedBox}
  \hfill
  \begin{BlueBox}[width=3cm, remember as=box5, nobeforeafter]{E}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{BlueBox}
  \hfill
  \begin{RedBox}[width=3cm, remember as=box6, nobeforeafter]{F}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{RedBox}
  \vfill
  \begin{BrownBox}[width=3cm, remember as=box7, nobeforeafter]{G}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{BrownBox}
  \hfill
  \begin{BrownBox}[width=3cm, remember as=box8, nobeforeafter]{H}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{BrownBox}
  \hfill
  \begin{BrownBox}[width=3cm, remember as=box9, nobeforeafter]{I}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{BrownBox}
\end{GreenBox}

\begin{tikzpicture}[overlay, remember picture, line width=1mm, draw=red]
\draw[->] (box1)--(box5);
\draw[->] (box2)--(box5);
\draw[->] (box3)--(box5);
\draw[->] (box4)--(box5);
\draw[->] (box6)--(box5);
\draw[->] (box7)--(box5);
\draw[->] (box8)--(box5);
\draw[->] (box9)--(box5);
\end{tikzpicture}

\end{document}

得到下图 在此处输入图片描述

答案1

有用的库

tikzlibraryarrows.metashadows.blur(用于矩形和箭头)和 一起shapes可以做您所缺少的事情。

这是我得到的

这看上去是不是有点接近我们所期望的呢?

结果

与原版的区别

我故意保持这些简单,而不是准确地模仿目标:

  • 箱子宽度统一(5厘米)
  • 使用 Utopia 字体(而不是 Cambria)
  • 避免箱子与底部条带重叠
  • 尽可能保持对称

有待改进

某些方面可以改进:

  • 整个海报周围的黄灰色边框仍然缺失。加上它,tcolorbox海报上出现了几条不必要的线条,我无法控制。
  • 原来的箭头是完美的三角形,而我的箭头略微凹陷。可以坚持使用直角三角形,但让它保留为微妙的 Walter 线索。
  • 椭圆形中心节点的模糊阴影边缘有奇怪的暗色。应该有出口,但我没找到。

当然,还有一些其他的错误,以供热情的打字狂人发现!

最后是代码

\documentclass[border=10pt]{standalone}

\usepackage{fourier}
\usepackage{amsmath}
\usepackage{paralist}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\usepackage{tikz}
\usetikzlibrary{shapes, shadows.blur, arrows.meta}
%
\tikzset{
    arw/.style={line width=18pt,     % line style
                -{Latex[length=20pt, % arrow style
                        width=36pt]}
               },
    shd/.style={preaction={%    % line & arrow shadow
                 transform canvas={
                     shift={(1.5pt,-1pt)}
                                  }, 
                 draw=gray,
                 opacity=0.25,
                 line width=12pt}
               },
         }
%
%   Main frame background color
\definecolor{cBkg}{HTML}{eeece0}
%   Color of top/bottom/center
\definecolor{cCen}{HTML}{1f487c}
%   Colors for the eight boxes
\definecolor{cAdm}{HTML}{bf674f}
\definecolor{cExe}{HTML}{bf7c51}
\definecolor{cAud}{HTML}{c48f49}
\definecolor{cPar}{HTML}{bea553}
\definecolor{cReg}{HTML}{bcb855}
\definecolor{cJud}{HTML}{adbc57}
\definecolor{cCiv}{HTML}{9bbb58}
\definecolor{cLeg}{HTML}{c0504e}

\newcommand{\cobox}[3]{%
    \begin{tcolorbox}[colback=#1,
                      colframe=white,
                      skin=beamer,
                      drop fuzzy shadow,
                      width=5cm,
                      left=1ex,right=0.5ex]
    \textbf{\large\mbox{}\hfill#2\hfill\mbox{}}
        \begin{compactitem}[o]\color{white}\raggedright
         #3
        \end{compactitem}
    \end{tcolorbox}
                      }

\begin{document}

\begin{tcolorbox}[width=20cm,
                  left=0.2cm,
                  boxrule=0pt,
                  colbacktitle=cCen,
                  sharp corners,
                  fonttitle=\center\bfseries\Huge,
                  toptitle=1.5ex,
                  bottomtitle=1.5ex,
                  title=SOEs Accountability,
                  colback=cBkg]
   \mbox{}\\
%   White strip below title and   |   Comment next 10 lines
%   dotted line  (aesthetic ?!)   |   if strip is not reqd.
\tcbsubtitle[boxrule=0pt, 
            colback=white,
            before skip=-2\baselineskip,
            after skip=-2\baselineskip]%
     {\centering\LARGE\strut%
      \tikz[overlay]
        \draw[cBkg!80!black, very thick, dashed, 
              xshift=0.5ex, yshift=-1ex]
          (-10cm, 0) -- (10cm, 0);
     }
   \mbox{}\\[-1ex]  
%
\begin{tikzpicture}
%   Central elliptical node
  \node[ellipse,
        thick, white,
        draw=white,
        fill=cCen,
        blur shadow={shadow blur steps=15}]
    (Cen) at (0,0)
      {\begin{minipage}{4cm}%
        \centering\bfseries\LARGE%
           \mbox{}\\                % space above
            SOEs\\ 
        Accountability\\[-1ex]
           \mbox{}                  % space below
       \end{minipage}%
      };
%   Define coordinates of boxes
  \coordinate (Adm) at (-6,  3);
  \coordinate (Exe) at ( 0,  4.5);
  \coordinate (Aud) at ( 6,  3);
  \coordinate (Par) at ( 7,  0);
  \coordinate (Reg) at ( 6, -3.2);
  \coordinate (Jud) at ( 0, -4.3);
  \coordinate (Civ) at (-6, -3);
  \coordinate (Leg) at (-7,  0);
%   Arrows placed below boxes
  \draw[arw,shd,cAdm] (Adm.center) -- (Cen);  
  \draw[arw,shd,cExe] (Exe.center) -- (Cen);
  \draw[arw,shd,cAud] (Aud.center) -- (Cen);
  \draw[arw,shd,cPar] (Par.center) -- (Cen);
  \draw[arw,shd,cReg] (Reg.center) -- (Cen);
  \draw[arw,shd,cJud] (Jud.center) -- (Cen);
  \draw[arw,shd,cCiv] (Civ.center) -- (Cen);
  \draw[arw,shd,cLeg] (Leg.center) -- (Cen);
%
%   Next the eight boxes, one by one...
%
  \node at (Adm)
  {\cobox{cAdm}
         {Administrative Control}
         {\item Minister
          \item Civil servants from Section 
                Officer to Secretary}
  };
%
  \node at (Exe)
   {\cobox{cExe}
          {Executive}
          {\item Prime Minister
           \item Cabinet
           \item Privatization Commission
           \item Finance Division
           \item Cabinet Committes
           \item ECC}
   }; 
%
  \node at (Aud)
   {\cobox{cAud}
          {Auditing}
          {\item Chartered Accountants
           \item Auditor General of Pakistan}
   }; 
%
  \node at (Par)
   {\cobox{cPar}
          {Parliamentary Oversight}
          {\item National Assembly Standing Committee
           \item Senate Standing Committee
           \item Public Accounts Committee}
   }; 
%
  \node at (Reg)
   {\cobox{cReg}
          {Regulatary Oversight}
          {\item SECP
           \item PPRA
           \item Sectoral Regulators}
   }; 
%
  \node at (Jud)
   {\cobox{cJud}
          {Judicial/ Accountability}
          {\item Supreme Court
           \item High Court
           \item Federal Ombudsman
           \item FIA
           \item NAB}
   }; 
%
  \node at (Civ)
   {\cobox{cCiv}
          {Civil Society}
          {\item Media
           \item Public at large
           \item Transparency International}
   }; 
%
  \node at (Leg)
   {\cobox{cLeg}
          {Legal \Large\strut  % medium space above line
                 \medskip      % medium space after line
          }
          {\item Board of Directors
                 \smallskip}   % small space at the end
   }; 
%
\end{tikzpicture}
%
%  Blue strip at bottom
\tcbsubtitle[boxrule=0pt, 
            colback=cCen,
            after skip=-2em]%
     {\mbox{}}
   \mbox{}\\[-1ex]  
%
\end{tcolorbox}

\end{document}

答案2

首先tcbraster

\documentclass[10pt]{standalone}

\usepackage{enumitem}
\setlist[itemize]{leftmargin=*, itemsep = 0em}
\usepackage[none]{hyphenat}

\usepackage{tikz}
\usetikzlibrary{matrix, shapes, arrows, positioning}

\usepackage[most]{tcolorbox}

\begin{document}

\tcbset{
    innerbox/.style={enhanced, 
        fonttitle=\bfseries, 
        coltitle=black,
        colupper=white,
        detach title,
        fontupper=\scriptsize,
        halign=flush left,
        before upper={\centerline\tcbtitle\par},
        colframe=white,
        drop shadow},
}
 
\begin{tcboxeditemize}[%
    raster columns=3, 
    raster column skip=5mm, raster row skip=5mm,
    raster left skip=1mm, raster right skip=1mm, 
    size=small, innerbox, remember as=box\thetcbrasternum,
    colback=violet!90,
    raster row 1/.style={raster valign=bottom},
    raster row 2/.style={raster valign=center},
    raster row 3/.style={raster valign=top}]
    {colframe=blue!75!black, colback=white!80!brown, sharp corners, title=ASD, boxsep=0pt, left=1mm, right=1mm}

\tcbitem[colback=brown!80!red, title=Administrative Control]
  \begin{itemize}
  \item Minister
  \item Civil servants from section Officer to Secretary
  \end{itemize}

\tcbitem[colback=brown, title=Executive]
  \begin{itemize}
  \item Prime Minister
  \item Cabinet
  \item Privatization Commision
  \item Finance Division
  \item Cabinet Commitees
  \item ECC
  \end{itemize}

\tcbitem[colback=brown!80!green, title=Auditing]
  \begin{itemize}
  \item Chartered accoutants
  \item Auditor General of Pakistan
  \end{itemize}

\tcbitem[title=D]
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}

\tcbitem[height=2cm, bean arc, colback=blue!30!black, valign=center, fontupper=\bfseries\large, halign=center]
  SOEs Accountability

\tcbitem[title=F]
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}

\tcbitem[title=G]
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}

\tcbitem[title=H]
  \begin{itemize}
  \item AS
  \item BC
  \item CD
  \item DE
  \end{itemize}

\tcbitem[title=I]
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}

\end{tcboxeditemize}

\begin{tikzpicture}[overlay, remember picture, line width=1mm, draw=red]
\draw[->] (box1)--(box5);
\draw[->] (box2)--(box5);
\draw[->] (box3)--(box5);
\draw[->] (box4)--(box5);
\draw[->] (box6)--(box5);
\draw[->] (box7)--(box5);
\draw[->] (box8)--(box5);
\draw[->] (box9)--(box5);
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案3

看看这个。希望它能帮到你。我加了一些注释来指导说明。很抱歉没有tcolorbox按照你的要求使用。我发现下面的方法更简单。恕我直言,它可能会简化你的工作。

编辑:我重写了代码,使其更简洁。希望现在看起来更好!

\documentclass[10pt, border=20pt]{standalone}

\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{matrix, shapes, arrows, positioning, shadows.blur}

\newif\iffirstbullet

\def\bitem{%
    \\\color{white}\textbullet~%
    }

\newcommand{\clbox}[7]{%
    %-> #1=Title; #2=Size; #3=position; #4=color; #5=(start)--(end); #6=xshift; #7bullets
    \firstbullettrue %... prevents breaking the first line
    \node (#1) [#3, #6]{};
    
    %--> THEN, USE IT AS REFERENCE TO DRAW THE ARROW UP TO THE CENTRAL SHAPE
    \draw[-triangle 90, line width=1mm, postaction={draw, line width=4mm, shorten >=3mm, -}, #4] #5;
    
    %--> THEN DRAW THE SHAPE AT THE VERY SAME POSITION COVERING PART OF THE ARROW
    \node [rectangle, rounded corners, line width=1pt, text centered, draw=white, blur shadow={shadow blur steps=5}, fill=#4, #3, #6]{%
        \begin{tabular}{c}
            \bfseries #1\\
            \begin{tabular}{p{#2}}
                #7
            \end{tabular}
        \end{tabular}
        };
    }

\begin{document}
 
\begin{tikzpicture}[node distance = 2.5cm]
    \tiny %... adjusts text font size
    
    %--> BEGIN WITH CENTRAL SHAPE
    \node (soes) [ellipse, line width=1pt, text centered, draw = white, fill = white!20!blue, blur shadow={shadow blur steps=5}]
        {\begin{tabular}{c}
            \\
            \color{white}\bfseries SOEs\\
            \color{white}\bfseries Accountability\\
            \\
        \end{tabular}
        };
    
    %-> #1=Title; #2=Size; #3=position; #4=color; #5=(start)--(end); #6=xshift; #7=bullets
    \clbox{Executive}{2.5cm}{above of=soes}{brown!80!black}{(Executive)--(soes)}{}{%
        \bitem Prime Minister
        \bitem Cabinet
        \bitem ...
        }
    
    %-> #1=Title; #2=Size; #3=position; #4=color; #5=(start)--(end); #6=xshift; #7=bullets
    \clbox{Administrative Control}{2.5cm}{left of=Executive}{BrickRed}{(Administrative Control)--(soes)}{xshift=-1.5cm}{%
        \bitem Minister
        \bitem Civil servants from Section Officer to Secretary
        }
    
    %-> #1=Title; #2=Size; #3=position; #4=color; #5=(start)--(end); #6=xshift; #7=bullets
    \clbox{Auditing}{2.5cm}{right of=Executive}{brown}{(Auditing)--(soes)}{xshift=1.5cm}{%
        \bitem Chartered accountants
        \bitem Auditor General of Pakistan
        }
    
    %-> #1=Title; #2=Size; #3=position; #4=color; #5=(start)--(end); #6=xshift; #7=bullets
    \clbox{Legal}{2.5cm}{left of=soes}{black!30!red}{(Legal)--(soes)}{xshift=-1.5cm}{%
        \bitem Board of Directors
        }
    
    %-> #1=Title; #2=Size; #3=position; #4=color; #5=(start)--(end); #6=xshift; #7=bullets
    \clbox{Parliamentary Oversight}{2.5cm}{right of=soes}{YellowOrange!80!black}{(Parliamentary Oversight)--(soes)}{xshift=1.5cm}{%
        \bitem National Assembly Standing Commite
        \bitem Senate Standing Commitee
        \bitem Public Accounts Commitee
        }
    
    %-> #1=Title; #2=Size; #3=position; #4=color; #5=(start)--(end); #6=xshift; #7=bullets
    \clbox{Judicial Accountability}{2.5cm}{below of=soes}{PineGreen!50!black}{(Judicial Accountability)--(soes)}{}{%
        \bitem Supreme Court
        \bitem High Court Federal Ombudsman
        \bitem FIA
        \bitem NAB
        }
    
    %-> #1=Title; #2=Size; #3=position; #4=color; #5=(start)--(end); #6=xshift; #7=bullets
    \clbox{Civil Society}{2.5cm}{left of=Judicial Accountability}{green!50!black}{(Civil Society)--(soes)}{xshift=-1.5cm}{%
        \bitem Media
        \bitem Public at large
        \bitem Transparency International
        }
    
    %-> #1=Title; #2=Size; #3=position; #4=color; #5=(start)--(end); #6=xshift; #7=bullets
    \clbox{Regulatory Oversight}{2.5cm}{right of=Judicial Accountability}{GreenYellow!60!black}{(Regulatory Oversight)--(soes)}{xshift=1.5cm}{%
        \bitem SECP
        \bitem PPRA
        \bitem Sectoral Regulators
        }
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案4

根据您的 MWE:

在此处输入图片描述

\documentclass[border=3mm]{standalone}
\usepackage{enumitem}
\setlist[itemize]{nosep,
                  leftmargin=*}
\usepackage[most]{tcolorbox}
\usetikzlibrary{arrows.meta, 
                matrix, 
                positioning}
\usepackage[none]{hyphenat}

\begin{document}
\newtcolorbox{GreenBox}[2][]{%
   enhanced,
   colback   = green!5!white,
   colframe  = green!75!black,
   arc       = 2mm,
   %outer arc = 1mm,
   fonttitle = \Large\slshape\bfseries,
   center title,
   title     = #2,
   #1}

\newtcolorbox{CB}[3][]{% ColorBox
   width=3cm,
   enhanced,
   left=1mm, right=1mm,
   colback   = #3!5!white,
   colframe  = #3!95!black,
   arc       = 2mm,
  % outer arc = 1mm,
   shadow={1.5pt}{-1.5pt}{0pt}{gray!50},
   fonttitle = \Large\slshape\bfseries,
   center title,
   title     = #2,
   #1}


\begin{GreenBox}{ASD}

  \begin{CB}[remember as=box1, nobeforeafter]{A}{red}
  \begin{itemize}
  \item A
  \item B
  \end{itemize}
  \end{CB}
  \hfill
  \begin{CB}[remember as=box2, nobeforeafter]{B}{red}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{CB}
  \hfill
  \begin{CB}[remember as=box3, nobeforeafter]{C}{red}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{CB}

  \vspace*{1cm}
  \begin{CB}[remember as=box4, nobeforeafter]{D}{red}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{CB}
  \hfill
  \begin{CB}[width=3cm, remember as=box5, nobeforeafter]{E}{blue}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{CB}
  \hfill
  \begin{CB}[width=3cm, remember as=box6, nobeforeafter]{F}{red}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{CB}
  
  \vspace*{1cm}
  \begin{CB}[width=3cm, remember as=box7, nobeforeafter]{G}{brown}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{CB}
  \hfill
  \begin{CB}[width=3cm, remember as=box8, nobeforeafter]{H}{brown}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{CB}
  \hfill
  \begin{CB}[width=3cm, remember as=box9, nobeforeafter]{I}{brown}
  \begin{itemize}
  \item AS
  \item BC
  \end{itemize}
  \end{CB}
\end{GreenBox}

\begin{tikzpicture}[overlay, remember picture,
every edge/.style = {draw=red, line width=3mm,
                     -{Triangle[length=4mm, width=6mm]},
                        shorten >=1pt, shorten <=2pt}
                    ]
\draw   (box1.south east) edge (box5.north west)
        (box2) edge (box5)
        (box3.south west) edge (box5.north east)
        (box4) edge (box5)
        (box6) edge (box5)
        (box7.north east) edge (box5.south west)
        (box8) edge (box5)
        (box9.north west) edge (box5.south east);
\end{tikzpicture}

\end{document}

相关内容