1

I really don't understand why this is happening, so I thought it was a bug from TeXStudio, but when I went on TeXShop and created a MWE it persists. I have the following code:

\documentclass[border=2pt]{standalone}

\usepackage{tikz}

\usetikzlibrary{arrows}

\tikzstyle{style1}=[rectangle, rounded corners, text centered, draw=black, fill=red, text width=7em]
\tikzstyle{arrow}=[very thick, ->, >=latex]
\tikzstyle{title}=[text centered, text width=6em, circle, draw=black, fill=blue]

\begin{document}

\begin{tikzpicture}
    \def \radius {9em}

        \path (90 :\radius) node[style1](n1){n1}
        (145:\radius) node[style1](n2){n2}
        (180:\radius) node[style1](n3){n3}
        (215:\radius)node[style1](n4){n4};
        (270:\radius)node[style1](n5){n5};
        (325:\radius)node[style1](n6){n6};
        (0:\radius)node[style1](n7){n7};
        (35:\radius)node[style1](n8){n8};


        \node[title]{Big Title};
\end{tikzpicture}

\end{document}

This is my output

Where did my final four nodes go off to? I can't figure it out!

The reason I thought it was a bug was because TeXStudio is weird every so often and does this thing where it will always jump back to a previously-built document, despite the code... It's really strange.

Anyway, any help would be greatly appreciated!

  • 5
    Check out semicolons. – ferahfeza Apr 7 at 11:50
  • The first semicolon closes the path, the rest is thrown away... Just remove all semicolons minus the last one (or add more path commands). – Rmano Apr 7 at 12:02
  • You can shorten your code as \foreach \i/\angle in {1/90,2/145,3/180,4/215,5/270,6/325,7/0,8/35}{ \path (\angle :\radius) node[style1](n\i){n\i};} \node[title](BB){Big Title}; – ferahfeza Apr 7 at 12:08
  • Ah, thank you @ferahfeza. Bit of a noob question... Sorry! And thanks for the suggested code. I never really knew how to use the \foreach command, so thanks for that! – Christopher Tatlock Apr 7 at 12:16
  • @ChristopherTatlock, your welcome. – ferahfeza Apr 7 at 12:17
2

As mentioned @Romano, the first semicolon closes the \path. Also as mentioned @marmot, \tikzstyle was converted to \tikzset

\documentclass[margin=3.1415mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows}

\tikzset{style1/.style={rectangle,rounded corners,  text centered, draw=black, fill=red, text width=7em}}

\tikzset{title/.style={text centered, text width=6em, circle, draw=black, fill=blue}}

\tikzset{arrow/.style={very thick,->, >=latex}}

\begin{document}
\begin{tikzpicture}
    \def \radius {9em}
    \foreach \i/\angle in {1/90,2/145,3/180,4/215,5/270,6/325,7/0,8/35}{
    \path (\angle :\radius) node[style1](n\i){n\i};} 
    \node[title](BB){Big Title};
    \draw[arrow] (n1.270)--(n2.90); 
    \draw[arrow] (BB.270)--(n5.90); 
\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.