我想在 TikZ 中使用自定义节点,并从 SVG 文件加载(或以其他方式转换)形状,因为我没有足够的时间学习pgf
绘制我想要的形状。 我怎样才能做到这一点?
答案1
有一个适用于 inkscape 的 svg2tikz 扩展,可从
https://github.com/kjellmf/svg2tikz
我没有亲自尝试过,所以这里没有例子。Jake 在网站上有一个例子
答案2
这通过转换为.png
或的图形以及标准功能得到支持。让我分享一个例子,其中我用乐高节点构建了一个图形来可视化 BERTopic 模型架构:.jpg
pgfdeclareimage
tikz
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\pgfdeclareimage[width=4cm, height=2.5cm]{lego}{figures/lego-piece.png}
\begin{tikzpicture}
\node (embed) [label=center:\texttt{all-MiniLM-L6-v2}] {\pgfuseimage{lego}};
\node [right=1 cm of embed] {sentence embedding};
\node (reduce) [above=-0.85cm of embed, label=center:\texttt{PCA}] {\pgfuseimage{lego}};
\node [right=1 cm of reduce] {dimensionality reduction};
\node (cluster) [above=-0.85cm of reduce, label=center:\texttt{KMeans}] {\pgfuseimage{lego}};
\node [right=1 cm of cluster] {clustering};
\node (countvect) [above=-0.85cm of cluster, label=center:\texttt{CountVectorizer}] {\pgfuseimage{lego}};
\node [right=1 cm of countvect] {tokenizing};
\node (weight) [above=-0.85cm of countvect,
label=center:\texttt{c-TF-IDF}] {\pgfuseimage{lego}};
\node [right=1 cm of weight] {weighting schema};
\draw [<-] (weight) edge (countvect) (countvect) edge (cluster) (cluster) edge (reduce) (reduce) edge (embed) ;
\end{tikzpicture}
\end{document}