12

I am trying to use the package epsdice in a beamer presentation.

This package provides the command \epsdice which takes a numerical argument between 1 and 6 and draws the corresponding face of a die. (It's quite useful for teaching Probability.)

I have noticed the following problem. If I use \setbeamercovered{dynamic}, then any instance of \epsdice inside an overlay appears in all the frames, ignoring the overlay specification.

I'm guessing that this is because all epsdice does is to include a portion of a PDF file containing the corresponding face of the die and there is no way to control its opacity.

Still, if anyone has any ideas on how I could get this to work, I'd be grateful.

1
  • Weirdly, I was about to ask a question about epsdice from a different perspective: epsdice doesn't work in XeLaTeX exactly because XeLaTeX doesn't seem to support clipping. We need someone like Andrew Stacey or Jake to come along and throw together a superior dice package in five minutes…
    – Seamus
    Commented Jan 19, 2012 at 17:37

1 Answer 1

13

For fun, here's a very quick mock up of a tikz replacement. Still needs tweaking, obviously.

\documentclass[border=2em]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
  \draw[very thick, rounded corners] (0,0) rectangle (1,1);
  \node[ellipse,fill=black,minimum height=0.1em] at (0.5,0.5){};
\end{tikzpicture}
\end{document}

a die


Clearly, I have too much time on my hands. Here's a customisable tikz-y replacement for epsdice:

\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\tikzset{
  dot hidden/.style={},
  line hidden/.style={},
  dot colour/.style={dot hidden/.append style={color=#1}},
  dot colour/.default=black,
  line colour/.style={line hidden/.append style={color=#1}},
  line colour/.default=black
}

\def\dotsize{0.1}

\usepackage{xparse}
\NewDocumentCommand{\drawdie}{O{}m}{
\begin{tikzpicture}[x=1em,y=1em,#1]
  \draw[thick, rounded corners=0.5,line hidden] (0,0) rectangle (1,1);
  \ifodd#2
    \fill[dot hidden] (0.5,0.5) circle (\dotsize);
  \fi
  \ifnum#2>1
  \fill[dot hidden] (0.2,0.2) circle (\dotsize);
  \fill[dot hidden] (0.8,0.8) circle (\dotsize);
  \ifnum#2>3
    \fill[dot hidden] (0.2,0.8) circle (\dotsize);
    \fill[dot hidden] (0.8,0.2) circle (\dotsize);
    \ifnum#2>5
      \fill[dot hidden] (0.8,0.5) circle (\dotsize);
      \fill[dot hidden] (0.2,0.5) circle (\dotsize);
    \fi
  \fi
\fi
\end{tikzpicture}
}  
\begin{document}

\drawdie{3}

\drawdie[line colour=red]{4}

\drawdie[dot colour=blue]{6}
\end{document}

This uses the trick of optional arguments from over here. The mandatory argument is the number and the optional argument takes one of two keys line colour=<colour> and dot colour=<colour> where <colour> is any colour tikz recognises.

enter image description here

3
  • 1
    I have a presentation to give in 20 minutes, so I'll have to stop messing around now, but with some tweaking, this could be a reasonable replacement. Not as quick to compile as a font, I expect…
    – Seamus
    Commented Jan 19, 2012 at 17:46
  • 1
    This would make the basis of a useful tikz library, I think. I modified it a bit to use for my purposes but the basic idea was really helpful - thanks!
    – cfr
    Commented Jul 26, 2014 at 14:48
  • @cfr Yes, one day I might even turn this into a library...
    – Seamus
    Commented Jul 27, 2014 at 16:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .