在父形状内垂直分布形状

在父形状内垂直分布形状

下图是双射的简化描述,目前为止效果不错,但肯定还有改进的空间。例如

 \draw [blue-node] (-2,2.5) circle (0.4cm) node[anchor=center] (a1) {$a_1$};

为文本设置节点,而不是圆形,这会导致箭头与圆的轮廓略微相交;我无法弄清楚如何用a1,a2,...变量标记每个元素(),同时绘制圆,使它们在集合内垂直分布均匀,parent这也是我使用硬编码坐标来放置圆的主要原因。我很想听听大家的建议,如何更好地解决这两个问题。

\documentclass[a4paper]{article}
\usepackage[american]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\begin{document}
\begin{figure}[hbt!]
    \centering
    \begin{tikzpicture}
        \tikzstyle{blue-node}=[color=blue!75,fill=blue!20,thick]
        \tikzstyle{red-node}=[color=red!75,fill=red!20,thick]
        \tikzstyle{parent}=[color=black!75,fill=black!5,very thick]
        \tikzstyle{mapsto}=[->,very thick]
        % set A
        \draw [parent] (-2,0) ellipse (1cm and 4cm);       
        \draw [blue-node] (-2,2.5) circle (0.4cm) node[anchor=center] (a1) {$a_1$};        
        \draw [blue-node] (-2,1.25) circle (0.4cm) node[anchor=center] (a2) {$a_2$};
        \draw [blue-node] (-2,0) circle (0.4cm) node[anchor=center] (a3) {$a_3$};
        \draw [blue-node] (-2,-1.25) circle (0.4cm) node[anchor=center] (a4) {$a_4$};
        \draw [blue-node] (-2,-2.5) circle (0.4cm) node[anchor=center] (a5) {$a_5$} (-2,-5) node[anchor=south,color=black] {$A$};
        % set B
        \draw [parent] (4,0) ellipse (1cm and 4cm);
        \draw [red-node] (4,2.5) circle (0.4cm) node[anchor=center] (b1) {$b_1$};
        \draw [red-node] (4,1.25) circle (0.4cm) node[anchor=center] (b2) {$b_2$};
        \draw [red-node] (4,0) circle (0.4cm) node[anchor=center] (b3) {$b_3$};
        \draw [red-node] (4,-1.25) circle (0.4cm) node[anchor=center] (b4) {$b_4$};
        \draw [red-node] (4,-2.5) circle (0.4cm) node[anchor=center] (b5) {$b_5$} (4,-5) node[anchor=south,color=black] {$B$};
        % mapsto
        \draw [mapsto] (a1) -- (b1);
        \draw [mapsto] (a2) -- (b5);
        \draw [mapsto] (a3) -- (b3);
        \draw [mapsto] (a4) -- (b4);
        \draw [mapsto] (a5) -- (b2);
    \end{tikzpicture}
    \label{sketch-bijective-function}
    \caption{Example of an bijective function}
\end{figure}
\end{document}

答案1

展示比解释更容易。

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[circle, draw, minimum width=0.8cm] (a1) {$a_1$};
\draw[red] (a1.north east) -- (a1.south west);
\end{tikzpicture}
\end{document}

演示

相关内容