我尝试使用 tikz 在菱形的右侧设置 10 个点,但结果并不理想。有没有更好的方法来指定几何形状上的点?
\documentclass{article}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage{amsmath,tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{arrows,shapes,positioning}
\usetikzlibrary{calc,decorations.markings}
\usepackage{environ}
\begin{document}
\tikzstyle{losange} = [diamond, draw, text badly centered, inner sep=1cm]
\begin{center}
\begin{tikzpicture}
\node [losange] (L) {Losange};
\node [above = 0.1mm of L] (s1) {S1};
\node [below right= 1mm of s1] (s2) {S2};
\node [below right= 1mm of s2] (s3) {S3};
\node [below right= 1mm of s3] (s4) {S4};
\node [below right= 5.5mm of s4] (s5) {S5};
\node [below left= 1mm of s5] (s6) {S6};
\node [below left= 1mm of s6] (s7) {S7};
\node [below left= 1mm of s7] (s8) {S8};
\node [below left= 1mm of s8] (s9) {S8};
\node [below left= 1mm of s9] (s10) {S9};
\node [below left= 1mm of s10] (s11) {S10};
\end{tikzpicture}
\end{center}
\end{document}
答案1
这里有一些append after command
技巧可能会有用:
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{shapes.geometric,calc}
\tikzset{create marks/.style={
append after command={
\pgfextra{\let\savednode=\tikzlastnode}%
\foreach \i [count=\j] in {0,.2,...,1}{
($(\savednode.north)!\i!(\savednode.east)$)
coordinate (\savednode-\j) }
\foreach \i [count=\j from 6] in {0,.2,...,1}{
($(\savednode.east)!\i!(\savednode.south)$)
coordinate (\savednode-\j) }}}}
\begin{document}
\begin{tikzpicture}
\node [draw=red, shape=diamond, minimum size=3cm, create marks] (A) {A};
\foreach \i in {1,...,11}
\fill [fill=red] (A-\i) circle [radius=.05] node [right] {\i};
\node [draw=blue, shape=diamond, minimum size=4cm, create marks]
at (0, 4) (B) {B};
\foreach \i in {1,...,11}
\fill [fill=blue] (B-\i) circle [radius=.05] node [right] {\i};
\end{tikzpicture}
\end{document}
答案2
像这样?
节点不等距但代码很简单:
\documentclass{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{shapes}
\begin{document}
\tikzstyle{losange} = [diamond, draw, text badly centered, inner sep=1cm]
\begin{center}
\begin{tikzpicture}
\node [losange] (L) {Losange};
\foreach \i [count=\j from 1] in {90,72,...,-90}
\node [right=1mm] at (L.\i) {S\j};
\end{tikzpicture}
\end{center}
\end{document}
答案3
形状具有角度锚点,即您可以写入L.0
(与相同L.east
)或L.15
来获取一个锚点,该锚点是从给定角度的节点中心到边界的线的交点。
代码:
\documentclass{article}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage{amsmath,tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{arrows,shapes,positioning}
\usetikzlibrary{calc,decorations.markings}
\usepackage{environ}
\begin{document}
\tikzstyle{losange} = [diamond, draw, text badly centered, inner sep=1cm]
\begin{center}
\begin{tikzpicture}
\node [losange] (L) {Losange};
\node [anchor=south west] (s1) at (L.90) {S1};
\node [anchor=south west] (s2) at (L.75) {S2};
% for illustration
\draw [blue] (L.center) -- ++(55:3cm) node[right] {$55^\circ$ (L.55)};
\fill [red] (L.55) circle (0.1);
%
\node [anchor=south west] (s3) at (L.55) {S3};
\node [anchor=south west] (s4) at (L.35) {S4};
\node [anchor=south west] (s5) at (L.15) {S5};
\node [anchor=west] (s6) at (L.0) {S6};
\node [anchor=north west] (s7) at (L.-15) {S7};
\node [anchor=north west] (s8) at (L.-35) {S8};
\node [anchor=north west] (s9) at (L.-55) {S9};
\node [anchor=north west] (s10) at (L.-75) {S10};
\node [anchor=north west] (s11) at (L.-90) {S11};
\end{tikzpicture}
\end{center}
\end{document}