我怎样才能在一个\tikz
节点中有 2 条线?例如,假设我想要:
A1
+
A2
在第一个节点中,在椭圆内。我该如何实现呢?
\documentclass[10pt]{beamer}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{arrows,shapes,calc}
\tikzset{every picture/.append style={remember picture},
na/.style={baseline=-.5ex}}
\everymath{\displaystyle}
\usepackage[english]{babel}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{setspace}
\usepackage{color}
\usepackage{subfiles}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\begin{document}
\begin{frame}
\begin{equation*}
\tikz[baseline]{
\node[fill=red!20, ellipse,anchor=base] (t2)
{A1};
}
\quad
\tikz[baseline]{
\node[fill=green!20, ellipse,anchor=base] (t4)
{B};
}
\quad
\tikz[baseline]{
\node[fill=purple!20, ellipse,anchor=base] (t5)
{C};
}
\quad
\tikz[baseline]{
\node[fill=brown!20, ellipse,anchor=base] (t6)
{D};
}
\end{equation*}
\bigskip
\centering\tikz[na]\node(n3)[fill=blue!20,anchor=base]{mixture};
\begin{tikzpicture}[overlay]
\path[->]<1-> (t2.south) edge [out=270,in=90] (n3);
\path[->]<1-> (t5.south) edge [out=270,in=90] (n3);
\path[->]<1-> (t4.south) edge [out=270,in=90](n3);
\path[->]<1-> (t6.south) edge [out=270,in=90](n3);
\end{tikzpicture}
\end{frame}
\end{document}
答案1
您可以使用\\
添加新行以及align
如下规范 align=center
:
\tikz[baseline]{
\node[fill=red!20, ellipse,anchor=base, align=center] (t2)
{A1 \\ + \\ A2};
}
代码:
\documentclass[10pt]{beamer}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{arrows,shapes,calc}
\tikzset{every picture/.append style={remember picture},
na/.style={baseline=-.5ex}}
\everymath{\displaystyle}
\usepackage[english]{babel}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{setspace}
\usepackage{color}
\usepackage{subfiles}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\begin{document}
\begin{frame}
\begin{equation*}
\tikz[baseline]{
\node[fill=red!20, ellipse,anchor=base, align=center] (t2)
{A1 \\ + \\ A2};
}
\quad
\tikz[baseline]{
\node[fill=green!20, ellipse,anchor=base] (t4)
{B};
}
\quad
\tikz[baseline]{
\node[fill=purple!20, ellipse,anchor=base] (t5)
{C};
}
\quad
\tikz[baseline]{
\node[fill=brown!20, ellipse,anchor=base] (t6)
{D};
}
\end{equation*}
\bigskip
\centering\tikz[na]\node(n3)[fill=blue!20,anchor=base]{mixture};
\begin{tikzpicture}[overlay]
\path[->]<1-> (t2.south) edge [out=270,in=90] (n3);
\path[->]<1-> (t5.south) edge [out=270,in=90] (n3);
\path[->]<1-> (t4.south) edge [out=270,in=90](n3);
\path[->]<1-> (t6.south) edge [out=270,in=90](n3);
\end{tikzpicture}
\end{frame}
\end{document}