来自 geogebra 的流程图

来自 geogebra 的流程图

流程图

我试图在 latex 中绘制流程图,但画不出来,所以我在 geogebra 中画了出来,然后我从 geogebra 生成了 Tikz 代码到 latex,但我收到了诸如“未定义的控制序列”之类的错误,我知道如何解决该错误。我还想为圆圈添加阴影颜色。

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-23.7,-17.42) rectangle (30.11,9.65);
\draw(6.97,3.04) circle (1.26cm);
\draw(12.92,3.04) circle (1.17cm);
\draw [->] (3.93,2.9) -- (5.73,2.87);
\draw [->] (8.23,2.93) -- (11.75,2.94);
\draw [->] (14.09,2.91) -- (16.2,2.9);
\draw [->] (6.93,4.31) -- (6.93,6.32);
\draw(9.97,-1.26) circle (1.17cm);
\draw [->] (11.14,-1.12) -- (14.19,-1.12);
\draw [->] (6.04,-1.12) -- (8.8,-1.22);
\draw (4.16,4.45) node[anchor=north west] {$$ \pi_w $$};
\draw (6.04,8.06) node[anchor=north west] {$$ \mu_w S_w $$};
\draw (8.57,4.64) node[anchor=north west] {$$ \lambda_w S_w $$};
\draw (14.14,4.4) node[anchor=north west] {$$ \mu_w C_w $$};
\draw (6.13,0.42) node[anchor=north west] {$$ \mu_w C_w $$};
\draw (11.42,0.52) node[anchor=north west] {$$ \epsilon_w A_w $$};
\draw (0,8)-- (0,-4);
\draw (0,-4)-- (20,-4);
\draw (20,-4)-- (20,8);
\draw (0,8)-- (20,8);
\draw (6.27,3.93) node[anchor=north west] {$$ S_w $$};
\draw (12.22,4.03) node[anchor=north west] {$$ C_w $$};
\draw (9.36,-0.28) node[anchor=north west] {$$ A_w $$};
\draw(-18.97,-8.95) circle (1.36cm);
\draw(-13.03,-9.04) circle (1.29cm);
\draw(-7.03,-8.92) circle (1.34cm);
\draw [->] (-22.06,-8.9) -- (-20.33,-8.95);
\draw [->] (-17.62,-8.99) -- (-14.32,-9.04);
\draw [->] (-19.04,-7.59) -- (-19.02,-5.85);
\draw [->] (-19.11,-10.3) -- (-19.11,-12.22);
\draw [->] (-12.98,-7.75) -- (-12.98,-5.76);
\draw(-13.12,-14.99) circle (1.32cm);
\draw [->] (-20.19,-15.08) -- (-14.44,-15.09);
\draw (-21.83,-7.21) node[anchor=north west] {$$ \pi_f $$};
\draw (-20.61,-4.07) node[anchor=north west] {$$ (\mu + \nu_f) S_f$$};
\draw (-19.86,-11.57) node[anchor=north west] {$$ \nu_m S_m $$};
\draw (-17.15,-7.31) node[anchor=north west] {$$ \lambda_f Sf $$};
\draw [->] (-11.73,-9.04) -- (-8.35,-9.14);
\draw [->] (-5.72,-9.2) -- (-3.84,-9.23);
\draw (-13.73,-4.03) node[anchor=north west] {$$ \mu I_f $$};
\draw (-10.92,-7.35) node[anchor=north west] {$$ \delta I_f $$};
\draw (-5.86,-7.59) node[anchor=north west] {$$ \epsilon_f D_f $$};
\draw (-21.36,-13.3) node[anchor=north west] {$$ \rho_f (\sigma_1 I_f + D_f +\sigma_2 C_w) $$};
\draw (-11.85,-13.58) node[anchor=north west] {$$ \tau_f A_f $$};
\draw [->] (-11.81,-15.17) -- (-9.84,-15.18);
\draw (-19.58,-8.01) node[anchor=north west] {$$ S_f $$};
\draw (-13.49,-8.15) node[anchor=north west] {$$ I_f $$};
\draw (-7.78,-7.87) node[anchor=north west] {$$ D_f $$};
\draw (-13.82,-13.86) node[anchor=north west] {$$ A_f $$};
\draw (-23.42,-4.03)-- (-2,-4);
\draw (-2,-4)-- (-2.02,-17.47);
\draw (-2.02,-17.47)-- (-23.56,-17.42);
\draw (-23.56,-17.42)-- (-23.42,-4.03);
\draw(8.85,-11.05) circle (1.32cm);
\draw(15.03,-11.01) circle (1.28cm);
\draw(20.98,-11.01) circle (1.3cm);
\draw [->] (10.17,-11.1) -- (13.76,-11.15);
\draw [->] (16.31,-11.05) -- (19.69,-11.2);
\draw [->] (22.27,-11.18) -- (23.93,-11.15);
\draw [->] (5.85,-11.1) -- (7.54,-11.21);
\draw(15.31,-15.03) circle (1.35cm);
\draw [->] (10.25,-15.08) -- (13.97,-15.15);
\draw [->] (16.66,-15.03) -- (20.84,-15.18);
\draw [->] (8.95,-9.74) -- (8.94,-7.82);
\draw [->] (15.16,-9.73) -- (15.12,-7.59);
\draw (5.57,-9.37) node[anchor=north west] {$$ \nu_f S_f $$};
\draw (7.26,-6.32) node[anchor=north west] {$$(\mu + \nu_m) S_m $$};
\draw (10.82,-9.23) node[anchor=north west] {$$ \lambda_m S_m $$};
\draw (14.42,-6.14) node[anchor=north west] {$$ \mu I_m $$};
\draw (17.04,-9.27) node[anchor=north west] {$$ \delta I_m $$};
\draw (22.15,-9.6) node[anchor=north west] {$$ \epsilon_m D_m $$};
\draw (9.04,-13.35) node[anchor=north west] {$$ \rho_m(D_m + \alpha I_m) $$};
\draw (17.33,-13.25) node[anchor=north west] {$$ \tau_m A_m $$};
\draw (8.43,-10.16) node[anchor=north west] {$$ S_m $$};
\draw (14.47,-10.02) node[anchor=north west] {$$ I_m $$};
\draw (20.42,-10.07) node[anchor=north west] {$$ D_m $$};
\draw (14.94,-14) node[anchor=north west] {$$ A_m $$};
\draw (4,-6)-- (26,-6);
\draw (26,-6)-- (25.94,-17.38);
\draw (25.94,-17.38)-- (3.93,-17.19);
\draw (4,-6)-- (3.93,-17.19);
\draw [->,dash pattern=on 6pt off 6pt] (0,3.47) -- (-8.81,-4.01);
\draw [->,dash pattern=on 6pt off 6pt] (-2.01,-13.07) -- (3.95,-14);
\end{tikzpicture}
\end{document}

答案1

正如评论中提到的,错误来自双美元符号 。$$但是,即使修复了这个问题,不幸的是代码也不是特别优雅。我不会放置一个文本节点并在其周围画一个圆圈,而是使用圆形节点等等。然后可以轻松对其进行着色,如下所示。我不知道您是否想对所有圆形节点进行着色,如果是的话,只需mycirc通过添加 来重新定义即可fill=blue!30

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows,positioning,fit}
\begin{document}
\tikzset{mycirc/.style={circle,draw}}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
\node[mycirc] (Sw) {$S_w$};
\draw[<-] (Sw) -- ++(-1,0) node[above] (w1) {$\pi_w$};
\draw[->] (Sw) -- ++(0,1) node[above] (w2) {$\mu_wS_w$};
\node[right=1.5cm of Sw,mycirc,fill=blue!30] (Cw) {$C_w$};
\draw[->] (Sw) -- (Cw) node[midway,above] (SCw) {$\lambda_wS_w$};
\draw[->] (Cw) -- ++(1,0) node[above] (w3) {$\mu_wC_w$};
\node[below=1cm of SCw,mycirc] (Aw) {$A_w$};
\draw[<-] (Aw) -- ++(-1,0) node[above] {$\mu_wC_w$};
\draw[->] (Aw) -- ++(1,0) node[above] {$\epsilon_wA_w$};
\node[draw,fit=(Aw) (Sw) (Cw) (w1) (w2) (w3)] (w){};
%
\node[mycirc,below left=3cm and 8cm of Sw] (Sf) {$S_f$};
\draw[<-] (Sf) -- ++(-1,0) node[above] (f1) {$\pi_f$};
\draw[->] (Sf) -- ++(0,1) node[above] (f2) {$\mu_fS_f$};
\draw[->] (Sf) -- ++(0,-1) node[below] {$\mu_mS_m$};
\node[right=1.5cm of Sf,mycirc,fill=red!30] (If) {$I_f$};
\draw[->] (Sf) -- (If) node[midway,above] {$\lambda_fS_f$};
\draw[->] (If) -- ++(0,1) node[above] (f3) {$\mu I_f$};
\node[right=1.5cm of If,mycirc] (Df) {$D_f$};
\draw[->] (If) -- (Df) node[midway,above] {$\delta I_f$};
\draw[->] (Df) -- ++(1,0) node[above] (f4) {$\epsilon_f D_f$};
\node[below=1.5cm of If,mycirc] (Af) {$A_f$};
\draw[<-] (Af) -- ++(-4,0) node[above,anchor=south west] (f5) {$\rho_f (\sigma_1 I_f + D_f +\sigma_2 C_w)$};
\draw[->] (Af) -- ++(1,0) node[above] {$\tau_f A_f$};
\node[draw,fit=(Af) (Sf) (Df) (If) (f1) (f2) (f3) (f4) (f5)] (f){};
%
\node[mycirc,below right=1cm and 9cm of Sf] (Sm) {$S_m$};
\draw[<-] (Sm) -- ++(-1,0) node[above] (m1) {$\pi_m$};
\draw[->] (Sm) -- ++(0,1) node[above] (m2) {$(\mu+\nu_m)S_m$};
\draw[->] (Sm) -- ++(0,-1) node[below] {$\mu_mS_m$};
\node[right=1.5cm of Sm,mycirc] (Im) {$I_m$};
\draw[->] (Sm) -- (Im) node[midway,above] (m3) {$\lambda_mS_m$};
\draw[->] (Im) -- ++(0,1) node[above] (m4) {$\mu I_m$};
\node[right=1.5cm of Im,mycirc] (Dm) {$D_m$};
\draw[->] (Im) -- (Dm) node[midway,above]  {$\delta I_m$};
\draw[->] (Dm) -- ++(1,0) node[above] (m5) {$\epsilon_m D_m$};
\node[below=1.5cm of Im,mycirc] (Am) {$A_m$};
\draw[<-] (Am) -- ++(-4,0) node[above,anchor=south west] (m6) {$\rho_m(D_m + \alpha I_m) $};
\draw[->] (Am) -- ++(1,0) node[above] {$\tau_m A_m$};
\node[draw,fit=(Am) (Sm) (Dm) (Im) (m1) (m2) (m3) (m4) (m5) (m6)] (m){};
%
\draw[dashed,->] (w.west) -- (f.50);
\draw[dashed,->] (f.-10) -- (m.170);
\end{tikzpicture}
\end{document}

在此处输入图片描述

更新:我没有收到任何报告错误。(当然,需要加载tikz,这可以通过 中的相应选项完成standalone。)

\documentclass{report}
\usepackage[margin=0.5in]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,fit}
\begin{document}
\tikzset{mycirc/.style={circle,draw,fill=blue!30}}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
\node[mycirc] (Sw) {$S_w$};
\draw[<-] (Sw) -- ++(-1,0) node[above] (w1) {$\pi_w$};
\draw[->] (Sw) -- ++(0,1) node[above] (w2) {$\mu_wS_w$};
\node[right=1.5cm of Sw,mycirc] (Cw) {$C_w$};
\draw[->] (Sw) -- (Cw) node[midway,above] (SCw) {$\lambda_wS_w$};
\draw[->] (Cw) -- ++(1,0) node[above] (w3) {$\mu_wC_w$};
\node[below=1cm of SCw,mycirc] (Aw) {$A_w$};
\draw[<-] (Aw) -- ++(-1,0) node[above] {$\mu_wC_w$};
\draw[->] (Aw) -- ++(1,0) node[above] {$\epsilon_wA_w$};
\node[draw,fit=(Aw) (Sw) (Cw) (w1) (w2) (w3)] (w){};
%
\node[mycirc,below left=3cm and 8cm of Sw] (Sf) {$S_f$};
\draw[<-] (Sf) -- ++(-1,0) node[above] (f1) {$\pi_f$};
\draw[->] (Sf) -- ++(0,1) node[above] (f2) {$\mu_fS_f$};
\draw[->] (Sf) -- ++(0,-1) node[below] {$\mu_mS_m$};
\node[right=1.5cm of Sf,mycirc,fill=red!30] (If) {$I_f$};
\draw[->] (Sf) -- (If) node[midway,above] {$\lambda_fS_f$};
\draw[->] (If) -- ++(0,1) node[above] (f3) {$\mu I_f$};
\node[right=1.5cm of If,mycirc] (Df) {$D_f$};
\draw[->] (If) -- (Df) node[midway,above] {$\delta I_f$};
\draw[->] (Df) -- ++(1,0) node[above] (f4) {$\epsilon_f D_f$};
\node[below=1.5cm of If,mycirc] (Af) {$A_f$};
\draw[<-] (Af) -- ++(-4,0) node[above,anchor=south west] (f5) {$\rho_f (\sigma_1 I_f + D_f +\sigma_2 C_w)$};
\draw[->] (Af) -- ++(1,0) node[above] {$\tau_f A_f$};
\node[draw,fit=(Af) (Sf) (Df) (If) (f1) (f2) (f3) (f4) (f5)] (f){};
%
\node[mycirc,below right=1cm and 9cm of Sf] (Sm) {$S_m$};
\draw[<-] (Sm) -- ++(-1,0) node[above] (m1) {$\pi_m$};
\draw[->] (Sm) -- ++(0,1) node[above] (m2) {$(\mu+\nu_m)S_m$};
\draw[->] (Sm) -- ++(0,-1) node[below] {$\mu_mS_m$};
\node[right=1.5cm of Sm,mycirc] (Im) {$I_m$};
\draw[->] (Sm) -- (Im) node[midway,above] (m3) {$\lambda_mS_m$};
\draw[->] (Im) -- ++(0,1) node[above] (m4) {$\mu I_m$};
\node[right=1.5cm of Im,mycirc] (Dm) {$D_m$};
\draw[->] (Im) -- (Dm) node[midway,above]  {$\delta I_m$};
\draw[->] (Dm) -- ++(1,0) node[above] (m5) {$\epsilon_m D_m$};
\node[below=1.5cm of Im,mycirc] (Am) {$A_m$};
\draw[<-] (Am) -- ++(-4,0) node[above,anchor=south west] (m6) {$\rho_m(D_m + \alpha I_m) $};
\draw[->] (Am) -- ++(1,0) node[above] {$\tau_m A_m$};
\node[draw,fit=(Am) (Sm) (Dm) (Im) (m1) (m2) (m3) (m4) (m5) (m6)] (m){};
%
\draw[dashed,->] (w.west) -- (f.50);
\draw[dashed,->] (f.-10) -- (m.170);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容