2

Horizontal positioning of \tstar can be done with \hspace*{}, but attempts at vertical positioning with either \vspace{} or writing \node (x) at (somex,somey) {\tstar{}{}{}{}} fails.

How can I adjust the vertical placement of \tstar?

Minimal example:

\documentclass[landscape,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\usepackage{pstricks}
\usepackage{fix-cm}

\usepackage{geometry}
\geometry{
  top=0.5in,            
  inner=0.5in,
  outer=0.5in,
  bottom=0.5in,
  headheight=3ex,       
  headsep=2ex,          
}

\newcommand\score[2]{
\pgfmathsetmacro\pgfxa{#1+1}
\tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=0.15em,anchor=outer point 3]
\begin{tikzpicture}[baseline]
  \foreach \i in {1,...,#2} {
    \pgfmathparse{(\i<=#1?"yellow":"gray")}
    \edef\starcolor{\pgfmathresult}
    \draw (\i*1em,0) node[name=star\i,scorestars,fill=\starcolor]  {};
   }
   \pgfmathparse{(#1>int(#1)?int(#1+1):0}
   \let\partstar=\pgfmathresult
   \ifnum\partstar>0
     \pgfmathsetmacro\starpart{#1-(int(#1))}
     \path [clip] ($(star\partstar.outer point 3)!(star\partstar.outer point 2)!(star\partstar.outer point 4)$) rectangle
    ($(star\partstar.outer point 2 |- star\partstar.outer point 1)!\starpart!(star\partstar.outer point 1 -| star\partstar.outer point 5)$);
     \fill (\partstar*1em,0) node[scorestars,fill=yellow]  {};
   \fi

,\end{tikzpicture}
}

\newcommand{\tstar}[5]{% inner radius, outer radius, tips, rot angle, options
\pgfmathsetmacro{\starangle}{360/#3}
\draw[#5] (#4:#1)
\foreach \x in {1,...,#3}
{ -- (#4+\x*\starangle-\starangle/2:#2) -- (#4+\x*\starangle:#1)
}
-- cycle;
}

\begin{document}

\begin{tikzpicture}

%%% \node (st) at (x,y) {\tstar{1}{3}{27}{17}{fill=red}}; fails.

\tstar{1}{3}{27}{17}{fill=red};

\node (x) at (10,1) {{ \fontsize{100}{120}\selectfont\bf Stuff}};

\end{tikzpicture}


\end{document}
user39678
  • 381

1 Answers1

1

You can add xshift and yshift to the fifth argument of \tstar, e.g.

\tstar{1}{3}{27}{17}{fill=red,xshift=2cm,yshift=-5cm};

On an unrelated note, use \bfseries not \bf, the latter is deprecated (see Does it matter if I use \textit or \it, \bfseries or \bf, etc.).

enter image description here

\documentclass[landscape,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\usepackage{pstricks}
\usepackage{fix-cm}

\usepackage{geometry}
\geometry{
  top=0.5in,            
  inner=0.5in,
  outer=0.5in,
  bottom=0.5in,
  headheight=3ex,       
  headsep=2ex,          
}

\newcommand\score[2]{
\pgfmathsetmacro\pgfxa{#1+1}
\tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=0.15em,anchor=outer point 3]
\begin{tikzpicture}[baseline]
  \foreach \i in {1,...,#2} {
    \pgfmathparse{(\i<=#1?"yellow":"gray")}
    \edef\starcolor{\pgfmathresult}
    \draw (\i*1em,0) node[name=star\i,scorestars,fill=\starcolor]  {};
   }
   \pgfmathparse{(#1>int(#1)?int(#1+1):0}
   \let\partstar=\pgfmathresult
   \ifnum\partstar>0
     \pgfmathsetmacro\starpart{#1-(int(#1))}
     \path [clip] ($(star\partstar.outer point 3)!(star\partstar.outer point 2)!(star\partstar.outer point 4)$) rectangle
    ($(star\partstar.outer point 2 |- star\partstar.outer point 1)!\starpart!(star\partstar.outer point 1 -| star\partstar.outer point 5)$);
     \fill (\partstar*1em,0) node[scorestars,fill=yellow]  {};
   \fi

,\end{tikzpicture}
}

\newcommand{\tstar}[5]{% inner radius, outer radius, tips, rot angle, options
\pgfmathsetmacro{\starangle}{360/#3}
\draw[#5] (#4:#1)
\foreach \x in {1,...,#3}
{ -- (#4+\x*\starangle-\starangle/2:#2) -- (#4+\x*\starangle:#1)
}
-- cycle;
}

\begin{document}

\begin{tikzpicture}

%%% \node (st) at (x,y) {\tstar{1}{3}{27}{17}{fill=red}}; fails.

\tstar{1}{3}{27}{17}{fill=red};
\tstar{1}{3}{27}{17}{fill=red,xshift=2cm,yshift=-5cm};

\node (x) at (10,1) {{ \fontsize{100}{120}\selectfont\bfseries Stuff}};

\end{tikzpicture}


\end{document}
Torbjørn T.
  • 206,688
  • @user39678 Glad it helped. If you end up using this solution, you might consider accepting my answer by clicking the checkmark to the left (same for Jake's answer to your other question). That marks the question as solved, and awards some points to both yourself and me. – Torbjørn T. Nov 09 '13 at 14:50