title: How do I change the color of each letter in a sentence in LaTeX?
body: <p>I've been struggling in find the solution for the following problem.</p>
  
  <p>If I want to change the color of each letter in a sentence in latex, how can I do it? Let's say that I want to write "Merry Christmas" using the colors red and green and alternating between them.</p>
  
  <p>I want to define a command and use a forloop to change the color of each letter, but I don't know:</p>
  
  <ol>
  <li><p>How can I find the number of letters in a sentence (excluding spaces) to give the upper limit for the forloop?</p></li>
  <li><p>How can I define a string with the two colors to use in the forloop?</p></li>
  </ol>
  
  <p>So far my silly "solution" is to do it manually, like:</p>
  
  <pre><code>\documentclass[a4paper,12pt]{article}
    \usepackage[utf8x]{inputenc}
    \usepackage{xcolor}
  
  \begin{document}
  
  \textcolor{red}{M}\textcolor{green}{e}\textcolor{red}{r}
  \textcolor{green}{r}\textcolor{red}{y}\textcolor{green}{C}
  \textcolor{red}{h}\textcolor{green}{r}\textcolor{red}{i}
  \textcolor{green}{s}\textcolor{red}{t}\textcolor{green}{m}
  \textcolor{red}{a}\textcolor{green}{s}\textcolor{red}{!}
  
  \end{document}
  </code></pre>
  
  <p>From what I saw I can define an environment and use a loop to alternate between the colors, I don't have a sensilble solution, but it would be something like:</p>
  
  <pre><code>\newenvironment{redgreen}{
    \forloop{WORDNUMBER}{1}{\VALUE{WORDNUMBER} &lt; \LENGHT{WORDNUMBER}}{
      \textcolor{red}{WORDNUMBER}
      \textcolor{green}{WORDNUMBER + 1}
      WORDNUMBER = WORDNUMBER + 2
    }
  }
  </code></pre>
  
  <p>The parts with capital letters I know won't work, I just want to give an example of what I'm willing to do. I want to find a way to get the number of letters in the sentence that I would put inside the redgreen block and somehow use the forloop to change the color of each letter in the sentence alternating between red and green. I'm not sure how the forloop works in latex, so everything in the example above may be trash.</p>