2

I have a diamond split in four triangles and I would like to write inside each triangle at it center and having difficulties with position. Please help me fix that problem.Thanks

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{wasysym}
\usetikzlibrary{shapes.geometric, calc}
\newcommand{\mydiamond}[7][]{%
  \begin{scope}[transform shape]
     \node [alias=los, diamond, draw, fill=#3, #1] (#2) {} ;

    \draw ([yshift=-0.3] los.north) -- ([yshift=0.3] los.south) ;
    \draw ([xshift=-0.3] los.east) -- ([xshift=0.3] los.west) ;


    \path [auto=false] (los.west) -- ([xshift=0.3] los.west)
          node (G) [pos=0.8] {} ;
    \path [auto=false] (los.east) -- ([xshift=-0.3] los.east)
          node (D) [pos=0.5] {} ;
   \path [auto=false] (los.north) -- ([yshift=0.3] los.north)
          node (V) [pos=0.6] {} ;
   \path [auto=false] (los.south) -- ([yshift=-0.3] los.south)
          node (U) [pos=0.3] {} ;


    \node [font=\tiny, scale=0.5] at (G) {#4} ;
      \node [font=\tiny, scale=0.5] at (D) {#5} ;
  \node [font=\tiny, scale=0.5] at (V) {#6} ;
\node [font=\tiny, scale=0.5] at (U) {#7} ;
\end{scope}

}%
\begin{document}

\begin{tikzpicture}[scale=5, auto]
\mydiamond{init}{green!10}{$\CIRCLE$}{\tiny{$\CIRCLE$$\CIRCLE$}}{3}{4}
\end{tikzpicture}

\end{document} 
9

The barycentric coordinate system can be useful here.

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{wasysym}
\usetikzlibrary{shapes.geometric, calc}
\newcommand{\mydiamond}[7][]{%
\begin{scope}[transform shape]
   \node [alias=los, diamond, draw, fill=#3, #1] (#2) {} ;

   \draw ([yshift=-0.3] los.north) -- ([yshift=0.3] los.south) ;
   \draw ([xshift=-0.3] los.east) -- ([xshift=0.3] los.west) ;

   \coordinate (n) at (los.north);
   \coordinate (s) at (los.south);
   \coordinate (w) at (los.west);
   \coordinate (e) at (los.east);
   \coordinate (c) at (los.center);

   \coordinate (G) at (barycentric cs:n=1,c=1,w=1);
   \coordinate (D) at (barycentric cs:s=1,c=1,w=1);
   \coordinate (V) at (barycentric cs:n=1,c=1,e=1);
   \coordinate (U) at (barycentric cs:s=1,c=1,e=1);


    \node [font=\tiny, scale=0.5] at (G) {#4} ;
    \node [font=\tiny, scale=0.5] at (D) {#5} ;
    \node [font=\tiny, scale=0.5] at (V) {#6} ;
    \node [font=\tiny, scale=0.5] at (U) {#7} ;
\end{scope}
}%
\begin{document}

\begin{tikzpicture}[scale=5, auto]
\mydiamond[minimum size=1cm]{init}{green!10}{$\CIRCLE$}{\tiny{$\CIRCLE\CIRCLE$}}{3}{4}
\end{tikzpicture}

\end{document} 

enter image description here

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.