4

On my computer, Mac OSX 10.8.5, with texshop, the following code produces only a line between (0,0) and (1,2), like if the loop was ignored. Why?

\documentclass[reqno]{amsart}
\usepackage{amsmath}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (0,0)
    \foreach \x in {1,...,5}
      { --++ (1,2) }
      ;
\end{tikzpicture}

\end{document}

Thanks for the quick reply!

I did what you said and the version is 2.00

With the command \fill (5,10) circle (2pt); I get the circle at the correct position (5,10).

The code should produce a straight line. Now with the replacement by --++ (\x,2) I get a line from (0,0) to (1,2) and an horizontal line from (1,2) to (5,2).


In fact I downloaded the pgf version 3.00 but it seems that Tex does not see it since \pgfversion gives always 2.00

I put the downloaded pgf folder (the name was pgf3) in texmf/tex/generic/

cedric
  • 41
  • Works fine here, which version of TikZ do you have? Add \pgfversion in your document, that prints the version number. (By the way OS and editor shouldn't matter for the output, but the version of MacTeX/TeX Live you're running, and package versions, might.) – Torbjørn T. Aug 19 '16 at 08:17
  • 1
    Welcome to TeX.SX. As Torbjørn already stated you should get the desired result. You state to go 5 times (1,2) which results in a straight line ending at (5,10). Add \fill (5,10) circle (2pt); to your code and you will see that the line ends exactly there, right? – Stefan Pinnow Aug 19 '16 at 08:22
  • Can you clarify what you expect as output from the code. I guess it is not a straight line form (0,0) to (5,10) as it is now. To test if the loop is used change to { --++ (\x,2) } which does not give a straight line. – StefanH Aug 19 '16 at 08:45
  • Ok, maybe this was a bug in v2.00. Could you update to the current v3.0.1a? Then this issue should be solved. – Stefan Pinnow Aug 19 '16 at 09:19
  • 1
    v2.00 is quite old (about 8 years). You need to update and the problem goes away. – percusse Aug 19 '16 at 09:50
  • It looks like you've got two separate accounts. The Stack Exchange staff can merge them together for you. – samcarter_is_at_topanswers.xyz Aug 19 '16 at 12:43
  • Check your help menu for details on updating packages. It may keep a list of all sty files loaded rather than run through the directories every time. – John Kormylo Aug 19 '16 at 13:55
  • @cedric follow this guide. It is amazingly comprehensive http://tex.stackexchange.com/questions/1092/how-to-install-vanilla-texlive-on-debian-or-ubuntu/95373#95373 – percusse Aug 19 '16 at 14:20
  • Do NOT follow the guide @percusse linked. You are using Mac OS X and that guide is designed for users of Debian-based distros. It can be easily applied to other GNU/Linux and similar Unix-ish systems, but is not the recommended way to proceed on OS X. Instead, download the current version of MacTeX (2016) and install that. Also, that guide will not work on recent OS X installations. – cfr Aug 19 '16 at 22:42
  • Also, that guide will not work on recent OS X installations which will block altering or creating /etc/environment and several other commands will fail for similar reasons. – cfr Aug 19 '16 at 22:48
  • @cfr Did you try ? I did. – percusse Aug 20 '16 at 07:20
  • @percusse The instructions will work on older OS X installations, but that is not the recommended installation method. I wouldn't expect them to work correctly on recent OS X. But maybe I'm wrong about that. It still isn't a good idea to use these instructions on that system, though. As far as I know, PATH should be set differently on OS X, for example. (And, of course, the OP will not get any of the GUI conveniences and goodies like convert if they forswear MacTeX.) – cfr Aug 20 '16 at 12:56
  • The current version of MacTeX is available at https://www.tug.org/mactex/. – cfr Aug 21 '16 at 22:10
  • 4
    I'm voting to close this question as off-topic because the problem was caused by using an old version of TikZ, updating will solve it. – Torbjørn T. Sep 10 '16 at 20:34

0 Answers0