
我正在嘗試製作帶有圓形的一維隔間圖,但是用圓形更改 tikzstyle 不會將其從方形更改為圓形。
\documentclass[12pt]{report}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\tikzstyle{int}=[draw, line width = 0.5mm, minimum size=5em]
\tikzstyle{make circle}=[circle, line width = 0.5 mm, minimum size=5em]
\begin{figure}
\centering
\begin{tikzpicture}[node distance=3cm,auto,>=latex']
\node [int] (a) {};
%%%%%%%%%%%%%
\node [makecircle] (c) [] {$M$}; %% This is the problem (still makes a square)
%%%%%%%%%%%
\node [int] (d) [right of=c, node distance=4cm] {$E$};
\draw[->, ultra thick, blue] (c) edge node {$r(1-p)$} (d);
\draw [green, ultra thick, ->]
([xshift=-0.25cm]a.north) to[out=120, in=60, distance=1.5cm] ([xshift=0.25cm]a.north);
\node [above=1.0cm,text=green] at (a.north) {$pr$};
\draw [red, ultra thick, ->] (0,-1) -- (0,-2);
\node [right=0.5cm,below=0.15cm,text=red] at (a.south) {$\approx 0$};
\end{tikzpicture}
\caption{This is a two compartment model}
\end{figure}
\end{document}
答案1
\node [int] (a) {};
你用(這裡沒有定義圓)畫圓,但用\node [makecircle] (c) [] {$M$};
(這裡沒有draw
)寫文本M(你寫的是makecircle
而不是make circle
。)
因為make circle
只會添加circle
,所以我刪除了 tikzstyle 並重複使用了該int
樣式。
\documentclass[12pt]{report}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\tikzstyle{int}=[draw, line width = 0.5mm, minimum size=5em]
\begin{figure}
\centering
\begin{tikzpicture}[node distance=3cm,auto,>=latex']
\node[int, circle] (c) [] {$M$};
\node [int] (d) [right of=c, node distance=4cm] {$E$};
\draw[->, ultra thick, blue] (c) edge node {$r(1-p)$} (d);
\draw [green, ultra thick, ->]
([xshift=-0.25cm]c.north) to[out=120, in=60, distance=1.5cm] ([xshift=0.25cm]c.north);
\node [above=1.0cm,text=green] at (c.north) {$pr$};
\draw [red, ultra thick, ->] (0,-1) -- (0,-2);
\node [right=0.5cm,below=0.15cm,text=red] at (c.south) {$\approx 0$};
\end{tikzpicture}
\caption{This is a two compartment model}
\end{figure}
\end{document}