Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Suppose you have n variations of a small text or a formula like this:

% Formula 1
\begin{align}
      v(t_o) = \lim_{h \to 0} \frac{v(t_0 + h) - v(t_0)}{h}
\end{align}

% Formula 2
\begin{align}
      v(t_o) = \lim_{h \to 0} \frac{v(t_0 + \Delta t) - v(t_0)}{\Delta t}
\end{align}

%...

% Formula n
%...

Is it possible to distribute evenly those formulas randomly, on a page with random rotations of the formulas by +- x degree. The formulas must not overlap.

share|improve this question
1  
You can use tikz for this. –  Leo Liu Oct 19 '11 at 12:48
    
@'Leo Liu'. Thanks. Could you provide some more details? –  student Oct 19 '11 at 13:34
    
You could manually distribute them using \hspace and \vspace and take the random rotation from tex.stackexchange.com/questions/9323/… –  doncherry Oct 19 '11 at 18:30
1  
I'm a little confused by 'distribute evenly those formulas randomly'. Do you want the distribution even (on a rectangular or circular grid for example) and the formulas randomly assigned to the points, or would you like the distribution random (not on a grid)? –  cmhughes Oct 19 '11 at 21:27

1 Answer 1

Following @Leo's suggestion, here's a start for how you might do this in Tikz:

\usepackage{tikz}

\makeatletter

\pgfkeys{/rotatednodes/.cd, width/.initial=10cm, 
  height/.initial=10cm, maxrotation/.initial=20}
\newcount\@nodenum

\newcommand{\rotatednodes}[2][]{%
\pgfkeys{/rotatednodes/.cd, #1}
\begin{tikzpicture}[x=\pgfkeysvalueof{/rotatednodes/width}, 
                    y=\pgfkeysvalueof{/rotatednodes/height}]
\@nodenum=0
\def\@eqlist{#2}
\foreach\eq in \@eqlist{
  \advance\@nodenum by 1
  \pgfmathrandominteger{\x}{0}{100}
  \pgfmathrandominteger{\y}{0}{100}
  \pgfmathrandominteger{\r}{-\pgfkeysvalueof{/rotatednodes/maxrotation}}%
    {\pgfkeysvalueof{/rotatednodes/maxrotation}}
 \node[rotate=\r] (randomnode_\number\@nodenum) at (\x/100,\y/100) {\eq};
}
\end{tikzpicture}
}

\makeatother

which you would then use like

\rotatednodes[width=2cm, maxrotation=90]{$x$, $y$, $z$, $a$, $b$, $c$}

which gives

Equations positioned and rotated at random

or something similar to it.

The optional arguments are width, height, and maxrotation which all do more or less what they say. The fiddling with keys for the arguments was just for fun: the crucial bit is using \pgfmathrandominteger to randomise the position and rotation of the nodes, and I guess using \foreach to loop through the various equations.

There are several issues with this simple implementation, notably that absolutely no attempt is made to check for node overlap, and that only the centres of the nodes are guaranteed to fall within a widthxheight rectangle, but hopefully this will help you find a solution that works for your particular case.

share|improve this answer
    
You can use \pgfmathdeclarerandomlist and \pgfmathrandomitem to get random item from equations. –  Leo Liu Oct 20 '11 at 15:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.