Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
Editing it thrice makes my rep increase 6 points. Lucky! –  stalking is prohibited Nov 9 '13 at 13:42
1  
The problem is: where do you want to place it? –  egreg Nov 9 '13 at 13:43
    
Not sure yet! I'd like to be able to adjust the vertical positioning of \tstar.... –  user39678 Nov 9 '13 at 14:19

1 Answer 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}
share|improve this answer
    
T. Torbjorn, many thanks! –  user39678 Nov 9 '13 at 14:45
    
@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 9 '13 at 14:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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