我需要绘制一个带有递归矩形指针的类图。我的目的是绘制两个矩形并旋转其中一个,如在另一篇文章中所述...但我如何正确定位它们?
微波功率
\documentclass[12pt]{article}
\usepackage{geometry} % see geometry.pdf on how to lay out the page. There's lots.
\usepackage{tikz}
\usetikzlibrary{%
arrows,
shapes,
chains,
matrix,
positioning,
shapes.multipart,
calc,
scopes}
\usepackage{tikz-uml}
\usepackage{ifthen}
\usepackage{xstring}
\usepackage{pgfkeys}
\begin{document}
\begin{tikzpicture}
\node[rectangle,draw,yscale=1.2,x=3,rotate=135,fill=black,name=1] {};
\node[rectangle,draw,yscale=1.8,rotate=0,name=2] {};
\umluniaggreg{1}{2}
\end{tikzpicture}
\end{document}
答案1
纯 TikZ 解决方案。其中用于箭头的arrows.meta
库是:
\documentclass[tikz, 12pt, margin=3mm]{standalone}
%\usepackage{geometry} % see geometry.pdf on how to lay out the page. There's lots.
\usetikzlibrary{arrows.meta,
calc,
% chains,
% matrix,
% positioning,
% scopes,
% shapes,
% shapes.multipart
}
%\usepackage{tikz-uml}
%\usepackage{ifthen}
%\usepackage{xstring}
%\usepackage{pgfkeys}
\begin{document}
\begin{tikzpicture}
\node (n1) [draw, minimum height=2em, align=center, fill=cyan] {Baustein\\[1em]};
\draw[-{Diamond[length=7mm]}] (n1.north) |- ++ (2,1) |- (n1);
\end{tikzpicture}
\end{document}
我这就是你在找的东西?