1

I tried to set 10 points on the right side of a diamond with tikz and it does not give a good result. Would there be a better approach to specifying points on a geometric shape?

\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}
5

Some append after command tricks may be useful here:

\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}

enter image description here

3

like this?

enter image description here

node are not equidistant but code is simple:

\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}
1

Shape have angle anchors, i.e. you can write L.0 (same as L.east) or L.15 to get an anchor which is the intersection of a line from the center of a node in the angle given and the border.

enter image description here

Code:

\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}
  • \node [rectangle] (R) {Rectangle}; \node [anchor=south east] (r1) at (R.90) {R1}; \node [anchor=south east] (r2) at (R.75) {R2}; – Houda Araj Sep 28 '17 at 14:35
  • Suppose I want to add four rectangles east south west north that I can write text inside.\node [rectangle] (R) {Rectangle}; \node [anchor=south east] (r1) at (R.90) {R1}; \node [anchor=south east] (r2) at (R.75) {R2}; – Houda Araj Sep 28 '17 at 14:37
  • @HoudaAraj it's not clear what you want, but this may help: \node [draw,rectangle,minimum height=2cm,minimum width=4cm] (R) {Rectangle}; \node [draw=green,anchor=north] (r1) at (R.south) {R1}; \node [draw=green,anchor=west] (r2) at (R.east) {R2}; \node [draw=green,anchor=south] (r3) at (R.north) {R3}; \node [draw=green,anchor=east] (r4) at (R.west) {R4}; \node [draw=blue,anchor=south] (r5) at (R.south) {R5}; \node [draw=blue,anchor=east] (r6) at (R.east) {R6}; \node [draw=blue,anchor=north] (r7) at (R.north) {R7}; \node [draw=blue,anchor=west] (r8) at (R.west) {R8}; – Mike Sep 28 '17 at 14:55
  • Thanks@Mike\node [draw,rectangle,fill=blue!10, rounded corners,minimum height=2cm,minimum width=5cm, anchor=north] (r1) at (L.south) {R1}; \node [draw,rectangle,fill=blue!10, rounded corners,minimum height=2cm,minimum width=5cm, anchor=west] (r2) at (L.east) {R2}; \node [draw,rectangle,fill=blue!10, rounded corners,minimum height=2cm,minimum width=5cm, anchor=south] (r3) at (L.north) {R3}; \node [draw,rectangle,fill=blue!10, rounded corners,minimum height=2cm,minimum width=5cm,anchor=east] (r4) at (L.west) {R4}; How to put some space between the diamond and the rectangles. – Houda Araj Sep 28 '17 at 15:41
  • @HoudaAraj there are many ways to do this. One way is to add the option below=1cm to node r1, right=1cm to r2, above=1cm to r3, and left=1cm to r4. – Mike Sep 28 '17 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.