答案1
您可以将此作为起点。
arrows.meta
根据需要调整文本大小和类型。例如,查看以下文章,了解不同的箭头这个问题。
这是代码。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\[
\begin{tikzpicture}
\draw[{Latex[length=2mm,width=2mm]}-{Latex[length=2mm,width=2mm]}]
(5,.75)node[right]{\Large\textsf{K-means}}
-- (0,0)node[left]{\Large\textsf{\begin{tabular}{c}Squared-\\error\end{tabular}}}
-- (5,-.75)node[right]{\Large\textsf{\begin{tabular}{c}Kernel\\K-means\end{tabular}}};
\end{tikzpicture}
\]
\end{document}
答案2
如果您想通过箭头连接文本的某些元素,您可能需要这样做。
\documentclass{article}
\usepackage{tikz}
\newcommand{\tikznode}[2]{%
\ifmmode%
\tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$#2$};%
\else
\tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
\fi}%from https://tex.stackexchange.com/questions/402462/tikz-equivalent-of-pstricks-commands-ncbar-and-rnode/402466#402466
\begin{document}
\begin{flushright}
\tikznode{km}{K--means}
\end{flushright}
\tikznode{se}{\begin{tabular}{c}
squared\\ error
\end{tabular}}
\begin{flushright}
\tikznode{ke}{\begin{tabular}{c}
Kernel\\ K--means
\end{tabular}}
\end{flushright}
\tikz[overlay,remember picture]{\draw[->] (se.east)--(km.west);
\draw[->] (se.east)--(ke.west);}
\end{document}
答案3
纯tikz
解决方案。使用positioning
库来定位节点:
\documentclass[tikz, margin=3mm]{standalone}% very suitable for test of image drawings
\usetikzlibrary{arrows.meta, positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 0mm and 22mm, % vertical and horizontal distances between nodes
mynode/.style = {align=center, font=\sffamily}
]
% nodes
\node (n1) [mynode] {Squared-\\error};
\node (n21) [mynode,above right=of n1] {K-means};
\node (n22) [mynode,below right=of n1] {Kernel\\ K-means};
% arrow
\draw[Triangle-Triangle] (n21.west) -- (n1.east) -- (n22.west);
\end{tikzpicture}
\end{document}