Tikz 填充循环包围的区域

Tikz 填充循环包围的区域

在 tikz 中可以填充循环内的区域,对吗?

我遇到了问题并且我不知道我搞砸了什么:

\documentclass[center]{article}
\usepackage{tikz}

\begin{document}

\centering
\begin{tikzpicture}[>=latex]
\node[circle, fill, inner sep = 0, minimum size = 2mm] (a) at (3,0,0) {};
\node[left of = a] {$a$};
\node[circle, fill, inner sep = 0, minimum size = 2mm] (b) at (5,0,4) {};
\node[left of = b] {$b$};
\node[circle, fill, inner sep = 0, minimum size = 2mm] (apb) at (8,0,1) {};
\node[right of = apb] {$a + b$};

\draw[->, very thin] (a) -- node[below] {$i_1$} (apb);
\draw[->, very thin] (b) -- node[below] {$i_2$} (apb);

\node[circle, fill, inner sep = 0, minimum size = 2mm] (fa) at (3,3,0) {};
\node[right of = fa, circle, minimum size = 6cm] {};
\node[left of = fa] {$f(a)$};
\node[circle, fill, inner sep = 0, minimum size = 2mm] (fb) at (5,3,4) {};
\node[right of = fb, circle, minimum size = 3cm] {};
\node[left of = fb] {$f(b)$};
\node[circle, fill, inner sep = 0, minimum size = 2mm] (fapb) at (8,3,1) {};
\node[right of = fapb, circle, minimum size = 3cm] {};
\node[right of = fapb] {$f(a + b)$};

\draw[very thin, dashed, blue, ->] (a) -- (fa);
\draw[very thin, dashed, blue, ->] (b) -- (fb);
\draw[very thin, dashed, blue, ->] (apb) -- (fapb);


\draw[very thin, ->] (fa) -- node[below] {$j_1$} (fapb);
\draw[very thin, ->] (fb) -- node[below] {$j_2$} (fapb);


\fill[red] (b) -- (apb) -- (a) -- cycle;
\end{tikzpicture}

\end{document}

在此处输入图片描述

如您所见,底部的两个箭头是红色的,但我希望底部三个点之间的三角形是红色的。然而,三角形是由路径描述的(b) -- (apb) -- (a) --cycle。那么...问题是什么?

答案1

\documentclass[center]{article}
\usepackage{tikz}

\begin{document}

\centering
\begin{tikzpicture}[>=latex]
\node[circle, fill,red, inner sep = 0, minimum size = 2mm] (a) at (3,0,0) {};
\node[left of = a] {$a$};
\node[circle, fill,red, inner sep = 0, minimum size = 2mm] (b) at (5,0,4) {};
\node[left of = b] {$b$};
\node[circle, fill,red, inner sep = 0, minimum size = 2mm] (apb) at (8,0,1) {};
\node[right of = apb] {$a + b$};

\draw[->, very thin,red] (a) -- node[below] {\color{black}$i_1$} (apb);
\draw[->, very thin,red] (b) -- node[below] {\color{black}$i_2$} (apb);

\node[circle, fill, inner sep = 0, minimum size = 2mm] (fa) at (3,3,0) {};
\node[right of = fa, circle, minimum size = 6cm] {};
\node[left of = fa] {$f(a)$};
\node[circle, fill, inner sep = 0, minimum size = 2mm] (fb) at (5,3,4) {};
\node[right of = fb, circle, minimum size = 3cm] {};
\node[left of = fb] {$f(b)$};
\node[circle, fill, inner sep = 0, minimum size = 2mm] (fapb) at (8,3,1) {};
\node[right of = fapb, circle, minimum size = 3cm] {};
\node[right of = fapb] {$f(a + b)$};

\draw[very thin, dashed, blue, ->] (a) -- (fa);
\draw[very thin, dashed, blue, ->] (b) -- (fb);
\draw[very thin, dashed, blue, ->] (apb) -- (fapb);


\draw[very thin, ->] (fa) -- node[below] {$j_1$} (fapb);
\draw[very thin, ->] (fb) -- node[below] {$j_2$} (fapb);


\fill[red] (b) -- (apb) -- (a) -- cycle;

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容