\foreach \i[count=\t from 0] in {16,...,23}
    \path (\t+0.25,1) coordinate (P\i);
    \fill (P\i) circle (2pt);



Compiling this results in

! Undefined control sequence.
\UseTextAccent ...up \@firstofone \let \@curr@enc 
                                              \cf@encoding \@use@text@en...
l.14   }

Why does TeX have a problem with the closing brace in Line 14? It is just used to close the foreach.

  • With TexLive 2013 and pgf 3.0 it just runs fine at me. No error. How do you build? – moospit Aug 28 '14 at 5:28
  • @moospit Using pdflatex on Ubuntu... tex --version returns TeX 3.1415926 (TeX Live 2009/Debian) and pgf 2.0 – boaten Aug 28 '14 at 5:31
  • What command do you use (e.g pdflatex or latex) to build your document? Also insert \pgfversion in your document to get the version of pgf you are running. – moospit Aug 28 '14 at 5:33
  • @moospit Using pdflatex, and pgf 2.0 – boaten Aug 28 '14 at 5:34
  • Hm okay. Need to rebuild your tex-setup to get closer to this. What you also could try is: \fill({P\i}) circle (2pt); on line 13. – moospit Aug 28 '14 at 5:44

From your comments i got that you're running TexLive 2009 with pgf 2.0 - Depending on the package information this is an Ubuntu 10.04 (no support for clients anymore). For the test i installed the server edition and ran some tests.

It looks like this installation is so outdated (had no looks at the changelogs yet), that there's no proper support for the [count=...] function in the \foreach loop.

I also gave it another shot by using \foreach \i\t in {16/0,17/1,...} but this also raised errors.

Now there are the following solutions:

  1. Get your system up to date - unless you are using Ubuntu 10.04 Server which still has a little support left

  2. Update your Texlive-installation (pgf is missing many features)

  3. If there's no way you can update your system, avoid the [count=...]

If the code from your question is everything you want to draw, you can simplify it:


  \foreach \i in {16,...,23} {
   \fill (\i+0.25,1) circle (2pt);

To sum it all up. Do you a favor and update your OS/Latex-installation.

If there's no way of doing an upgrade, you could explain why you need the count in the \foreach-loop. Then we can try to get another solution for your problem.

| improve this answer | |
  • Thanks! I needed the count in order to name another variable. (Your current code would start the variable i from 16.) But I think I can just rescale by doing \fill (\i-15.75,1)? – boaten Aug 28 '14 at 7:24
  • This would have been my next answer ;) Just calculate the needed values in the \foreach if you need them. – moospit Aug 28 '14 at 7:25
  • No problem. You're welcome. – moospit Aug 28 '14 at 7:35

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.