Want to fill line with repeating string

Similar to the \dotfill command, but with your own text, rather than dots.

If the string was: kitty!

The entire line would look like the following: kitty!kitty!kitty!kitty!kitty!kitty!kitty!kitty!kitty!

Is there any way to do this?

• Have a look at the file latex.ltx. THere you will find the definition of dotfill and hruefil – Marco Daniel Dec 15 '11 at 20:40

One way of doing this is using leaders:

\documentclass{article}

\begin{document}
This is a test. \kitty \par
This is a test.

\noindent \kitty
\end{document}


The general format for constructing leaders is \leaders<box or rule><glue> (which repeats <box or rule>). There are three kinds of leaders that you can use: \leaders, \cleaders and \xleaders. Here is an informal description of each, taken from The Advanced TeXBook:

When \leaders is used, TeX first locates the innermost box A containing the \leader command. It then fills up A, from the left, with copies of the leader. There may be some space left on the right. ...

The \cleaders command centers the leaders in the leader window, regardless of the size of the enclosing box A. There is normally some space left on both sides of the window. The \xleaders is still different. It distributes the window space evenly between the individual copies of the leader.

Here, and just for fun, the difference between using \kitty with \leaders, \cleaders and \xleaders:

\documentclass{article}
\usepackage{showframe}% http://showframe
\begin{document}

\leaders<box or rule>\hskip<glue>

and the effect will be the same as if you had said just \hskip<glue>, except that the space will be occupied by copies of the specified <box or rule>. The glue stretches or shrinks in the usual way.