我是 tikz 的新手,我正在寻找一个可以很好地增强/调整我的两个 tikz 图形的人(如果这一点很重要的话,它们是在 xetex 中创建的)。
我做了两个流程图(也是在 stackoverflow 的帮助下),请参见下面的独立代码(MWE)和图表。
在图 1 中,我想问一下是否有人知道如何为中间的三个框添加一些灰度并为顶部框添加更深的灰色背景?
在图 2 中,我希望有人
- a) 调整整个图形,使上部居中
- b)使两个花括号居中且更粗,
- c) 中间的单个框与图 1 中的顶部框一样呈深灰色。
这是有人愿意做的事吗?:)
图。1
图 1 - 代码
\documentclass[tikz]{standalone}
\usepackage{tikz, tikzscale}
\usetikzlibrary{
shapes.geometric,
arrows,
arrows.meta,
calc,
positioning,
decorations.pathreplacing,
calligraphy, % had to be after lib. decorations.pathreplacing
bending} % add geometric shapes and arrows for flowcharts, plus calc package, positioning for relative positions
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process2} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process3} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[transform shape, node distance=2cm]
\centering\node (start) [process3] {Start};
\node (pro1) [startstop, below of=start] {Center*};
\node (pro2) [process, left=1.2cm of pro1] {Bla 1};
\node (pro3) [process, right=1.2cm of pro1, align=center] {Bla 2};
\node (pro4) [process2, below left= 0.3cm and -0.5cm of pro2, align=center] {Bla 3};
\node (pro5) [process2, below right= 0.3cm and -0.5cm of pro2, align=center] {Bla 4};
\node (pro6) [process2, below left= 0.3cm and -0.5cm of pro3, align=center] {Bla 5};
\node (pro7) [process2, below right= 0.3cm and -0.5cm of pro3, align=center] {Bla 6};
\node (OR) [right=0.6cm of pro4] {OR};
\draw [arrow] (pro1) -- (start);
\draw [arrow] (pro2.north) |- (start.west);
\draw [arrow] (pro3.north) |- (start.east);
\draw [arrow] (pro4.north) |- (pro2.west);
\draw [arrow] (pro5.north) |- (pro2.east);
\draw [arrow] (pro6.north) |- (pro3.west);
\draw [arrow] (pro7.north) |- (pro3.east);
\end{tikzpicture}
\end{document}
图 2
图 2 - 代码
\documentclass[tikz]{standalone}
\usepackage{tikz, tikzscale}
\usepackage{paralist} % compactitem
\usetikzlibrary{
shapes.geometric,
arrows,
arrows.meta,
calc,
positioning,
decorations.pathreplacing,
calligraphy, % had to be after lib. decorations.pathreplacing
bending} % add geometric shapes and arrows for flowcharts, plus calc package, positioning for relative positions
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process2} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process3} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[
transform shape,
node distance = 22mm and 11mm,
box/.style = {shape=rectangle, draw, thin,
minimum height=10mm, text width=32mm, align=center,
top color=#1!20, bottom color=#1!80,
anchor=south west
},
BC/.style args = {#1/#2/#3}{ % Braces Calligraphic
decorate,
decoration={calligraphic brace, amplitude=6pt,
raise=#1,
#2, % for mirroring of brace
aspect=#3},
very thick,
pen colour={gray}
},
]
\node (start) [process, align=center] {Bla 1};
\node (pro1) [process, right of=start, align=center, xshift=2cm] {Bla 2};
\node (pro2) [process, right of=pro1, align=center, xshift=2cm] {Bla 3};
\node (pro3) [process2, below of=start, align=center, yshift=-.5cm] {Bla 4};
\node (pro4) [process2, below of=pro1, align=center, yshift=-.5cm] {Bla 5};
\node (pro5) [process2, below of=pro2, yshift=-.5cm] {Bla 6};
\node (main) [startstop, below of=pro4, yshift=-.5cm] {Center*};
\node (pro6) [process3, below left=1cm and 1cm of main, align=center] {\parbox{.3\linewidth}{Bla 7,\begin{compactitem}\item Bla Bla \item Bla Bla \item Bla Bla\end{compactitem}}};
\node (pro7) [process3, below=1cm of main, align=center] {\parbox{.3\linewidth}{Bla 8,\begin{compactitem}\item Bla Bla \item Bla Bla \item Bla Bla \end{compactitem}}};
\node (pro8) [process3, below right=1cm and 1cm of main, align=center] {\parbox{.3\linewidth}{Bla 9,\begin{compactitem}\item Bla Bla \item Bla Bla \item Bla Bla \end{compactitem}}};
\node (pro9) [process3, right of=pro8, align=center, xshift=2cm] {\parbox{.3\linewidth}{Bla 10,\begin{compactitem}\item Bla Bla \item Bla Bla \item Bla Bla \end{compactitem}}};
\draw[-Stealth] (start) edge (pro3)
(pro1.south) edge (pro3) (pro1.south) edge (pro5)
(pro2.south) edge (pro4) (pro2.south) edge (pro5);
% braces
\draw[BC=2mm/mirror/0.500] (pro3.south west) -- (pro5.south east);
\draw[BC=2mm/ /0.375] (pro6.north west) -- (pro9.north east);
\end{tikzpicture}
\end{document}
答案1
第一张图:
\documentclass[tikz,border=2pt]{standalone}
\usepackage{tikz, tikzscale}
\usetikzlibrary{
shapes.geometric,
arrows,
arrows.meta,
calc,
positioning,
decorations.pathreplacing,
calligraphy, % had to be after lib. decorations.pathreplacing
bending} % add geometric shapes and arrows for flowcharts, plus calc package, positioning for relative positions
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process2} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process3} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[transform shape, node distance=2cm]
\centering\node (start) [process3,fill=black!30] {Start}; % ============
\node (pro1) [startstop, below of=start,fill=black!10] {Center*}; % ============
\node (pro2) [process, left=1.2cm of pro1] {Bla 1};
\node (pro3) [process, right=1.2cm of pro1, align=center] {Bla 2};
\node (pro4) [process2, below left= 0.3cm and -0.5cm of pro2, align=center] {Bla 3};
\node (pro5) [process2, below right= 0.3cm and -0.5cm of pro2, align=center,fill=black!10] {Bla 4}; % ============
\node (pro6) [process2, below left= 0.3cm and -0.5cm of pro3, align=center,fill=black!10] {Bla 5}; % ============
\node (pro7) [process2, below right= 0.3cm and -0.5cm of pro3, align=center] {Bla 6};
\node (OR) [right=0.6cm of pro4] {OR};
\draw [arrow] (pro1) -- (start);
\draw [arrow] (pro2.north) |- (start.west);
\draw [arrow] (pro3.north) |- (start.east);
\draw [arrow] (pro4.north) |- (pro2.west);
\draw [arrow] (pro5.north) |- (pro2.east);
\draw [arrow] (pro6.north) |- (pro3.west);
\draw [arrow] (pro7.north) |- (pro3.east);
\end{tikzpicture}
\end{document}
第二个:
\documentclass[tikz,border=2pt]{standalone}
\usepackage{tikz, tikzscale}
\usepackage{paralist} % compactitem
\usetikzlibrary{
shapes.geometric,
arrows,
arrows.meta,
calc,
positioning,
decorations.pathreplacing,
calligraphy, % had to be after lib. decorations.pathreplacing
bending} % add geometric shapes and arrows for flowcharts, plus calc package, positioning for relative positions
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process2} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{process3} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=white]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\begin{tikzpicture}[
transform shape,
node distance = 22mm and 11mm,
box/.style = {shape=rectangle, draw, thin,
minimum height=10mm, text width=32mm, align=center,
top color=#1!20, bottom color=#1!80,
anchor=south west
},
BC/.style args = {#1/#2/#3}{ % Braces Calligraphic
decorate,
decoration={calligraphic brace, amplitude=6pt,
raise=#1,
#2, % for mirroring of brace
aspect=#3},
very thick
},
]
\node (start) [process, align=center] {Bla 1};
\node (pro1) [process, right of=start, align=center, xshift=2cm] {Bla 2};
\node (pro2) [process, right of=pro1, align=center, xshift=2cm] {Bla 3};
\node (pro3) [process2, below of=start, align=center, yshift=-.5cm] {Bla 4};
\node (pro4) [process2, below of=pro1, align=center, yshift=-.5cm] {Bla 5};
\node (pro5) [process2, below of=pro2, yshift=-.5cm] {Bla 6};
\node (main) [startstop, below of=pro4, yshift= 0cm, fill=black!30] {Center*};
\node (pro6) [process3, below =1cm of main,xshift=-6.3cm, align=center] {\parbox{.3\linewidth}{Bla 7,\begin{compactitem}\item Bla Bla \item Bla Bla \item Bla Bla\end{compactitem}}};
\node (pro7) [process3, below=1cm of main,xshift=-2.1cm, align=center] {\parbox{.3\linewidth}{Bla 8,\begin{compactitem}\item Bla Bla \item Bla Bla \item Bla Bla \end{compactitem}}};
\node (pro8) [process3, below=1cm of main,xshift=2.1cm, align=center] {\parbox{.3\linewidth}{Bla 9,\begin{compactitem}\item Bla Bla \item Bla Bla \item Bla Bla \end{compactitem}}};
\node (pro9) [process3, below=1cm of main,xshift=4.3cm, align=center, xshift=2cm] {\parbox{.3\linewidth}{Bla 10,\begin{compactitem}\item Bla Bla \item Bla Bla \item Bla Bla \end{compactitem}}};
\draw[-Stealth] (start) edge (pro3)
(pro1.south) edge (pro3) (pro1.south) edge (pro5)
(pro2.south) edge (pro4) (pro2.south) edge (pro5);
% braces
\draw[BC=2mm/mirror/0.500] (pro3.south west) -- (pro5.south east);
\draw[BC=2mm/ /0.500] (pro6.north west) -- (pro9.north east);
\end{tikzpicture}
\end{document}