我正在尝试绘制下图,但似乎无法理解 TikZ 包:
我该怎么做?
我正在使用以下代码:
\usepackage{tikz}
\usetikzlibrary{arrows, decorations.markings}
% for double arrows a la chef
% adapt line thickness and line width, if needed
\tikzstyle{vecArrow} = [thick, decoration={markings,mark=at position
1 with {\arrow[semithick]{open triangle 60}}},
double distance=1.4pt, shorten >= 5.5pt,
preaction = {decorate},
postaction = {draw,line width=1.4pt, white,shorten >= 4.5pt}]
\tikzstyle{innerWhite} = [semithick, white,line width=1.4pt, shorten >= 4.5pt]
\usetikzlibrary{positioning}
\begin{tikzpicture}
\matrix [column sep=7mm, row sep=5mm] {
\node (a) [draw, shape=rectangle] {Controlador de Solicitudes}; &
\node (b) [draw, shape=rectanble] {Receptor Satelital}; &
\node (c) [draw, shape=rectangle] {Decodificador}; \\
\node (d) [draw, shape=rectangle] {Almacenamiento de Informacion}; \\
\node (e) [draw, shape=rectangle] {Transmisor con GPRS}; \\
\node (f) [draw, shape=rectangle] {Servidor Web}; \\
\node (g) [draw, shape=rectangle] {Interfaz Web}; \\
\node (h) [draw, shape=rectangle] {Autentificacion}; \\
};
\draw[->, thick] (a) -- (b);
\draw[->, thick] (b) -- (c);
\draw[->, thick] (c) -- (d);
\draw[->, thick] (d) -- (e);
\draw[->, thick] (e) -- (f);
\draw[->, thick] (f) -- (g);
\draw[->, thick] (g) -- (h);
\draw[->, thick] (h) -- (f);
\draw[->, thick] (a) -- (e);
\draw[->, thick] (e) -- (a);
\end{tikzpicture}
答案1
一方面,TikZ非常另一方面,虽然功能强大、功能全面,但很难找到针对具体任务的解决方案。此外,图形的实现方式往往有很多种。
我尝试使用您现有的代码并添加了绘制给定图形所需的代码。
大多数事情应该很清楚。也许我错了,但似乎你还没有理解如何将内容放入矩阵中。我希望现在情况会更清楚。
代码
\begin{tikzpicture}
\definecolor{blue1}{HTML}{6095C9}
\definecolor{blue2}{HTML}{55779A}
\matrix [column sep=10mm, row sep=8mm, every node/.style={
shape=rectangle,
text width=2.75cm,
minimum height=1.75cm,
text centered,
font=\sffamily\small,
very thick,
color=white,
draw=blue2,
fill=blue1,
}] {
\node (a1) {Controlador de solicitudes}; &
\node (a2) {Receptor Satelital}; &
\node (a3) {Alimentatión Inteligente}; \\
&
\node (b2) {Decodificador desde NMAE a algo}; &
\node (b3) {Interfaz Web}; \\
&
\node (c2) {Almacenamiento de Informacion}; &
\node[xshift=15mm] (c3) {Autorizar y Autentificar}; \\
&
\node (d2) {Transmisor con GMS/GPRS}; &
\node (d3) {Servidor Web}; \\
};
\begin{scope}[->, very thick, blue1]
\draw (a1) -- (a2);
\draw ([xshift=3mm]a1.south) |- ([yshift=3mm]d2.west);
\draw (a2) -- (b2);
\draw (b2) -- (c2);
\draw (c2) -- (d2);
\draw ([yshift=-3mm]d2.west) -| ([xshift=-3mm]a1.south);
\draw[-, dashed] (d2) -- (d3);
\draw ([xshift=5mm]b3.south) -- ([xshift=-10mm]c3.north);
\draw ([xshift=-10mm]c3.south) -- ([xshift=5mm]d3.north);
\draw ([xshift=-5mm]d3.north) -- ([xshift=-5mm]b3.south);
\end{scope}
\end{tikzpicture}
形象的
答案2
为了比较,这里有一个版本元帖子,使用boxes
库,如中所述使用 Metapost 绘制方框这里主要关注的是如何让框在蓝色背景上绘制白色文字:您不能使用提供的命令drawboxed
,因为这不允许您指定颜色,所以我分别使用了bpath
和pic
命令来获取框轮廓和内容。
prologues := 3;
outputtemplate := "%j%c.eps";
% load the boxes library
input boxes;
% a little bit of plain TeX to wrap text in the boxes
verbatimtex
\def\wrap#1{\let\\\cr\font\sf=cmss10\vbox{\halign{\hfil\strut\sf ##\hfil\cr#1\crcr}}}
etex
beginfig(1);
% define all the box names and text
boxit.con(btex \wrap{Controlador de\\solicitudes} etex);
boxit.rec(btex \wrap{Receptor\\Satellital} etex);
boxit.dec(btex \wrap{Decodifcar desde\\NMEA a algo} etex);
boxit.alm(btex \wrap{Almacenar\\Informaci\'on} etex);
boxit.trx(btex \wrap{Transmisor con\\GMS/GPRS} etex);
boxit.ali(btex \wrap{Alimentaci\'on\\Intellegente} etex);
boxit.inw(btex \wrap{Interfaz Web} etex);
boxit.aya(btex \wrap{Autorizar y\\Autentificar} etex);
boxit.svw(btex \wrap{Servidor Web} etex);
% position the centres relative to each other
con.c + 140 right = rec.c;
rec.c + 80 down = dec.c;
dec.c + 80 down = alm.c;
alm.c + 80 down = trx.c;
con.c + 290 right = ali.c;
ali.c + 80 down = inw.c;
inw.c + 80 down = aya.w;
aya.w + 80 down = svw.c;
% best guess at the required colors
color mid_blue, dark_blue;
mid_blue = (79/255, 129/255, 189/255);
dark_blue = (56/255, 93/255, 138/255);
% draw the boxes with blue background and white text
forsuffixes $=con,rec,dec,alm,trx,ali,inw,aya,svw:
$.ne-$.sw = (89,55); % make them all the same size
fill bpath $ withcolor mid_blue;
draw pic $ withcolor .95white;
draw bpath $ withcolor dark_blue;
endfor
% draw the lines
drawoptions(withcolor mid_blue);
drawarrow con.e -- rec.w;
drawarrow rec.s -- dec.n;
drawarrow dec.s -- alm.n;
drawarrow alm.s -- trx.n;
z1 = (xpart con.c, ypart trx.c);
drawarrow con.s + 5 right -- z1 + (5,5) -- trx.w + 5 up;
drawarrow trx.w + 5 down -- z1 - (5,5) -- con.s + 5 left;
draw trx.e -- svw.w dashed evenly;
drawarrow (svw.n -- inw.s) shifted 10 left;
drawarrow (inw.s -- aya.nw) shifted 10 right;
drawarrow (aya.sw -- svw.n) shifted 10 right;
% draw a rounded frame
drawoptions(dashed evenly scaled .8 withcolor dark_blue);
draw quartercircle scaled 1cm rotated 0 shifted urcorner currentpicture
-- quartercircle scaled 1cm rotated 90 shifted ulcorner currentpicture
-- quartercircle scaled 1cm rotated 180 shifted llcorner currentpicture
-- quartercircle scaled 1cm rotated 270 shifted lrcorner currentpicture
-- cycle ;
endfig;
end.