Skip to main content
\\
Source Link
David Carlisle
  • 828.7k
  • 74
  • 1.7k
  • 2.6k
\documentclass{article} \usepackage{pgffor} \begin{document} \noindent \foreach \x in {1,1.1,...,2}{\x\\ } \ \\ \foreach \x in {1,1.2,...,2}{\x\\ } \end{document} 
\documentclass{article} \usepackage{pgffor} \begin{document} \noindent \foreach \x in {1,1.1,...,2}{\x\\ } \ \foreach \x in {1,1.2,...,2}{\x\\ } \end{document} 
\documentclass{article} \usepackage{pgffor} \begin{document} \noindent \foreach \x in {1,1.1,...,2}{\x\\ } \\ \foreach \x in {1,1.2,...,2}{\x\\ } \end{document} 
replaced http://tex.stackexchange.com/ with https://tex.stackexchange.com/
Source Link

However, a preferable way of obviating that round-off-error problem is, as suggested in g.kov's answerg.kov's answer, percusse's commentpercusse's comment, and Qrrbrbirlbel's commentQrrbrbirlbel's comment, to iterate over integers and compute the value of interest elsewhere, either like so

However, a preferable way of obviating that round-off-error problem is, as suggested in g.kov's answer, percusse's comment, and Qrrbrbirlbel's comment, to iterate over integers and compute the value of interest elsewhere, either like so

However, a preferable way of obviating that round-off-error problem is, as suggested in g.kov's answer, percusse's comment, and Qrrbrbirlbel's comment, to iterate over integers and compute the value of interest elsewhere, either like so

added reference to Tikz/PGF v3.0
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295

The problem illustrated by your example is due to round-off error. See section 56 in the TikZ/PGF documentation (v2section 56 in v2.10, p.505505; or section 83 in v3.0, p.910):

[...] for fractional steps that are not multiples of 2n2^{-n} for some small n, rounding errors can occur pretty easily. Thus, in \foreach \x in {0,0.1,...,0.5} {\x, }, 0.5 should probably be replaced by 0.501 for robustness.

The problem illustrated by your example is due to round-off error. See section 56 in the TikZ/PGF documentation (v2.10, p.505):

[...] for fractional steps that are not multiples of 2n for some small n, rounding errors can occur pretty easily. Thus, in \foreach \x in {0,0.1,...,0.5} {\x, }, 0.5 should probably be replaced by 0.501 for robustness.

The problem illustrated by your example is due to round-off error. See the TikZ/PGF documentation (section 56 in v2.10, p.505; or section 83 in v3.0, p.910):

[...] for fractional steps that are not multiples of 2^{-n} for some small n, rounding errors can occur pretty easily. Thus, in \foreach \x in {0,0.1,...,0.5} {\x, }, 0.5 should probably be replaced by 0.501 for robustness.

Bounty Awarded with 200 reputation awarded by kiss my armpit
refactored answer
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
improved answer
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
added a reference
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
Mod Removes Wiki by Joseph Wright
added 9 characters in body
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
deleted 1 characters in body
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
added 820 characters in body
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
added 30 characters in body
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
added a link
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
added 153 characters in body
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
added 153 characters in body
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
deleted 1 characters in body
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
added 15 characters in body
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
added 15 characters in body
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
added 98 characters in body
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading
Source Link
jub0bs
  • 60.3k
  • 25
  • 213
  • 295
Loading