如何在 tikz 中绘制带有表情符号的图形?

如何在 tikz 中绘制带有表情符号的图形?

我想使用乳胶中的 tikz 绘制一个图形和一些表情符号,如下图所示。

NB:我在 beamer 中做一个演示,图片的意思是三角形代理在选择相应的圆形产品时感到高兴。

我发现这个问题可以给我一点帮助,但不是完全的。如何在乳胶中绘制一组小的二分图?

这是我的代码和我所做的事情。我使用了这两个代码12

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\usepackage{marvosym}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\newcommand{\smiley}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw (-145:0.9mm) arc (-120:-60:1.5mm);
}
}

\newcommand{\frownie}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw (-145:0.9mm) arc (120:60:1.5mm);
}
}

\newcommand{\neutranie}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw (-135:0.9mm) -- (-45:0.9mm);
}
}
\usetikzlibrary{arrows,chains,matrix,positioning,scopes}
%
\makeatletter
\tikzset{join/.code=\tikzset{after node path={%
\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)%
edge[every join]#1(\tikzchaincurrent)\fi}}}
\makeatother
%
\tikzset{>=stealth',every on chain/.append style={join},
every join/.style={->}}
\tikzstyle{labeled}=[execute at begin node=$\scriptstyle,
execute at end node=$]
%
\begin{document}
    \begin{tikzpicture}
        \matrix (m) [matrix of math nodes,row sep=3em, column sep=3em]
        {  \smiley\; A1 & A2 \\
        \smiley\; B1 & B2 \\
        \neutranie\; C1 & C2 \\
        };
        { [start chain] \chainin (m-1-1);
        \chainin (m-1-2); 
        }
        { [start chain] \chainin (m-2-1);
        \chainin (m-2-2); 
        }
    \end{tikzpicture}
\end{document}

我得到了这张照片:

在此处输入图片描述

在此处输入图片描述

答案1

我不确定这是你想要的。也许你可以只在某些情况下自动绘制箭头,但如果你需要这样做一次,那就不值得了。

一些说明:

输出

图1

代码

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\usepackage{marvosym}

\usetikzlibrary{arrows.meta,chains,matrix,positioning,scopes}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\newcommand{\smiley}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw[-] (-145:0.9mm) arc (-120:-60:1.5mm);
}
}

\newcommand{\frownie}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw[-] (-145:0.9mm) arc (120:60:1.5mm);
}
}

\newcommand{\neutranie}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw[-] (-135:0.9mm) -- (-45:0.9mm);
}
}

\newcommand{\mytri}{\tikz[baseline=.2em,black]{
    \draw[fill=white] (0,0) --++ (8pt,0) --++ (-4pt,10pt) -- cycle;
}
}

\newcommand{\mycir}{\tikz[baseline=-0.75ex,black]{
    \draw[fill=white] circle (2mm);
}
}

\begin{document}
    \begin{tikzpicture}[->, >={Stealth[round]}]
        \matrix (m) [matrix of math nodes,row sep=1em, column sep=2em]
        {  
        \smiley\;    \mytri & \mycir & \smiley\;    \mytri & \mycir \\
        \frownie\;   \mytri & \mycir & \neutranie\;   \mytri & \mycir \\
        \neutranie\; \mytri & \mycir & \frownie\; \mytri & \mycir \\
        };

\draw (m-1-1) -- (m-1-2);
\draw (m-2-1) -- (m-2-2);
\draw (m-1-3) -- (m-1-4);
\draw (m-3-3) -- (m-3-4);

    \end{tikzpicture}
\end{document}

相关内容