After reading a bit on random coloring in LaTeX, I had the idea to use randomly colored leaders in a document. I came up with the following piece of code, which was stolen and modified from the \dotfill
implementation.
\documentclass{article}
\usepackage{tikz}
\makeatletter
\pgfmathsetseed{1}
\def\qfill{
\leavevmode \cleaders \hb@xt@ 1em{%
\hss
\pgfmathparse{rnd}
\textcolor[hsb]{\pgfmathresult, 1.0, 1.0}{?}
}\hfill
\kern \z@
}
\makeatother
\begin{document}
\qfill What will be the answer?\qfill
\end{document}
However, it seems that, for one call of qfill
, all the question marks will have the same color, with a new color being randomly selected once per call of qfill
, and not once for every ?
-character (as intended).
What do I need to change in order to have randomly colored leaders?
\leaders
you would have to position each box within the macro,\leaders
repeats the same box multiple times, which is not configurable from tex macros%
from ends of lines in your definition it will add space to the output as well as the leader dots.