I'm trying to print out a series of colour boxes, using the wave option of xcolor.

The result should be a (long) series of color boxes (possibly, but not necessarily) on two columns, which differ from each other by a constant value (I mean whose whavelength is incremented by a constant value).

My proto-code currently looks like:

 \colorbox[wave]{363}{ \ \strut   } 363\\
 \colorbox[wave]{368}{ \ \strut   } 368\\


But I was tired before reaching the end of the spectrum.

How is it possible to obtain the result in which the wavelength (and the number printed afterwards) are discretely incremented (and whose increment is configurable?


Just to clarify: this question is about loops, not colors per se: I'm fine with the output of xcolor


This way?

\foreach \lambda in {363,368,373,...,763} {\colorbox[wave]{\lambda}{ \ \strut } \lambda\\}
  • 1
    if you are not drawing then \usepackage{pgffor} is enough. Otherwise TikZ already loads xcolor – percusse Mar 30 '17 at 10:07
  • @ percusse: Thanks for the hint. I will modify my answer. – Jürgen Mar 30 '17 at 10:14

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.