As part of an attempt to debug another problem, I have a need for a TeX/LaTeX command that generates some dummy text in place. I know of lipsum and blindtext, but they are not what they want. What I have in mind is a command that takes the following arguments: a string (s
) and integers (k
and n
), and produces k
occurrences of s
per line (no spaces) for n
lines. I think this should be possible, even if one has to drop down to TeX to do it. After all, TeX is a text processing Turing complete programming language. Unfortunately, my knowledge of TeX could fit on a postage stamp with space left over, so I'm asking on this forum.
[Tex/LaTex] Generating dumthe text programatically using TeX/LaTeX
programmingstrings
Best Answer
The simplest way IMHO to do it is to use
\foreach
provided by thepgffor
package. There is also the lower level\loop\ifnum\j<\k ... \repeat
loop which could also be used. However, you need to wrap the inner loop in a group to mask the inner\repeat
.As Andrey already stated there are the open question about how to handle line breaks exactly. I simply use a
\\
here, but you might need something else instead, dependent on the exact application. However, the principle usage of the loops is the same.