# Text on rectangular spiral with automatic sizing to fill page

I'm wondering how this could be done in TeX:

This is along the lines of Text spirals with TikZ but in a rectangle, with all text the same size, and all text should be at right angles (unlike the above example, where some letters at corners are not.)

Needs to be dynamic as I'm trying to get a whole lot of text on one letter-sized page - think for example a page filled up with text in 7-point font - and have the text fill the entire page (and never overflow onto other pages), no matter how much text exists.

Here's an algorithm in python that gives the kind of rectangular spiral I'm talking about:

def spiral(X, Y):
x = y = 0
dx = 0
dy = -1
for i in range(max(X, Y)**2):
if (-X/2 < x <= X/2) and (-Y/2 < y <= Y/2):
print (x, y)
# DO STUFF...
if x == y or (x < 0 and x == -y) or (x > 0 and x == 1-y):
dx, dy = -dy, dx
x, y = x+dx, y+dy

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Apr 8 '15 at 7:43
• Oh sorry I should have mentioned that the example image I have above was just done manually in Inkscape; it's not something that came from TeX. – Diova Eid Apr 8 '15 at 8:33
• No, I meant: Give us a starter with the relevant packages, not just an image – user31729 Apr 8 '15 at 10:56

It looks... well... basically, awful in my opinion but anyway...

\documentclass[tikz, border=15]{standalone}
\usetikzlibrary{decorations.text}
\usepackage[nopar]{lipsum}
\UnpackLipsum[1]
\begin{document}
\tikz\draw [gray, thick,
postaction={decoration={text along path, text/.expanded=\lipsumexp}, decorate}]
(0,0) \foreach \i in {0,...,20}{ -- ++(-\i*90:.5+\i/5) };
\end{document}


• Thanks! It'll probably look better as just art as I'm planning on using it (e.g. 500k characters at 4-point size). – Diova Eid Apr 11 '15 at 17:49
• @DiovaEid you may find the decoration might "choke" on very large texts spread out over long paths, as all the calculations in the decoration are done using pure TeX and TeX is not so good with the kind of maths required. But it might work. – Mark Wibrow Apr 11 '15 at 17:57