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.

I'm using a random steps decoration with a path that appears through several uncover transitions. Currently the decoration is redrawn in each instance of the slide. How can I change this behavior. A minimal example follows. Thanks.

\documentclass[presentation]{beamer}  
\usepackage{tikz, pgf}  
\usetikzlibrary{decorations.pathmorphing}  
\begin{document}  
\begin{frame}  
\begin{center}  
\begin{tikzpicture}  
\uncover<1-3>{  
\fill [decorate, decoration={random steps,segment length=2pt,amplitude=2pt}] (0,0) ellipse (0.5cm and 0.4cm);  
}  
\end{tikzpicture}  
\end{center}  
\end{frame}  
\end{document} 
share|improve this question
    
I think this should be more mentioned in tutorials since it's really necessary whenever you have to deal with randomly generated graphics. It's often the case that you need to repeat a drawing multiple times with slight differences and there's no simple way to generate the data and store it, all from latex. –  facuq Nov 28 '13 at 21:14
add comment

1 Answer 1

up vote 12 down vote accepted

You can set the random seed each time you draw the ellipse, like so:

\documentclass[presentation]{beamer}
\usepackage{tikz, pgf}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}

\begin{frame}
\begin{center}
\begin{tikzpicture}
\uncover<1-3>{
\pgfmathsetseed{1234} % Choose a four-digit number here
\fill [decorate, decoration={random steps,segment length=2pt,amplitude=2pt}] (0,0) ellipse (0.5cm and 0.4cm);
}
\end{tikzpicture}
\end{center}
\end{frame}

\end{document} 

The best part is that \pgfmathsetseed is local so outside this tikzpicture environment the pseudo-random number generator will behave as usual.

And by the way random.org is a cool place to get random numbers to use as seeds. Here's one just for you.

share|improve this answer
    
Worked perfectly, thanks. –  Derek Mar 16 '11 at 3:23
    
Was looking for this for a time... thanks, too! –  Marcel Nov 10 '11 at 22:27
add comment

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.