I was wondering if it was possible to color every second letter in a text string in LaTeX
. I'm writing a report on decrypting a Vigenere cipher, and have a text string that I would like to have every alternate letter be colored differently.
So for example the string might be 'abcdefg', and I would like the output to show 'aceg' in blue and 'bdf' in red, or something like that.
Is this easily feasible in LaTeX
?
Thank you guys!
Best Answer
Here's an
expl3
version for alternating colours, but not for strings with whitespace (so far)Another version, with alternating colours
... and providing more than two colours, as well as using in an environment. However, no empty lines are allowed! No real tests on printable characters are done so far.