You're reading: Travels in a Mathematical World

customdice: a new LaTeX package for drawing dice

dice, regular ones and ones with different symbols on their faces, in multiple colours

I made a new LaTeX package for drawing dice, customdice.

I’ve long struggled to find a dice package I fully like. I have been using epsdice, but it only offers white or black standard dice. I found myself in a situation where I wanted to draw dice with other text on the faces. This package draws the dice face in TikZ and the aim is to offer simple commands that offer high levels of customisation.

Standard dice faces are created using \dice{num} for num an integer from 1-6. For example

\dice{1} \dice{2} \dice{3} \dice{4} \dice{5} \dice{6}
dice faces showing 1, 2, 3, 4, 5 and 6 dots.

There are commands for drawing a face with one big dot and for drawing faces with text (or other LaTeX content). The colour defaults to black on white but can be changed with optional parameters. The size can also be altered. This example shows a range of possibilities:

Three dice, yellow standard showing 4 dots, white face with big brown dot, and grey face with blue infinity symbol.

The size is set to fit inline with the text and to respond to the LaTeX font sizes (\small, \Large, etc.). For example:

D\dice{3}CE \Huge D\dice{3}CE
The dice face is a similar size to a capital letter, even when the font size changes.

You can also change the basic unit of the dice to make bigger images. For example:

Dice: \dice{5}
One '\Huge' dice face followed by three increasingly larger ones.

There is also a command \layoutdice{face1}{face2}{face3}{face4}{face5}{face6} that takes six inputs and places them on an expanded net of a dice cube, like these:

Dice nets

What is drawn on the face is arbitrary, so I can do things like this:

Dice face with Aperiodical logo.

The package is live on CTAN. If you run the following code in MikTeX you should find it installs the package. With TeXLive, you may need to update your packages (or install TeXLive 2022).


12 Responses to “customdice: a new LaTeX package for drawing dice”

  1. Avatar Saul Molina

    The package looks very useful if I could get it to work.
    I tried to use the package with TeXstudio but it didn’t find the package when compiling. I also tried directly in MikTex but still did not work.
    Are there any specific settings that I need to have in TeXstudio or in MikTex.


    Saul Molina

    • Peter Rowlett Peter Rowlett

      Hi Saul,

      I don’t know why you are having this trouble. Though I’m a bit confused by your message. TeXstudio is an editor for .tex files and others, so you edit files in TeXstudio but that has nothing to do with the compiling of the document. I don’t know what you mean by “I also tried directly in MikTex”. MiKTeX gets you the LaTeX compilers like pdflatex and handles installation of packages. I don’t use MikTeX – I use TeXstudio with TeX Live. For me, I had to update my TeX Live packages. For MiKTeX, my understanding is that it should just install as needed. customdice is in the MiKTeX package directory, so I’m not sure why it hasn’t. I’ll see if I can find someone with MiKTeX to try it.


      • Peter Rowlett Peter Rowlett

        Hi Saul,

        My friend ran it through MiKTeX and it worked but he had to check for updates in MiKTeX and update to the latest version before it found the customdice package.



  2. Avatar Saul Molina

    I think I figured out why it wasn’t working with TeXstudio or MikTex.
    When downloading the zip file from CTAN, we can see the actual customdice.sty is not included. What is included in the zip file is customdice.dtx.
    I copied the zip file in a local folder. Then I changed the extension of the .dtx file to .sty.
    Then I commented the following lines which were causing the problem:


    Now, the package works as expected.

    I think that if this is fixed in the original documentation, then there will be no problem when MiKTeX is trying to install the package.

    Kind regards

    Saul Molina

    • Peter Rowlett Peter Rowlett

      Hi Saul,

      A .sty file is not a LaTeX package, exactly. The package is the .dtx and the .ins files. The .dtx, as you have identified, does contain the .sty code as well as the documentation. If you want to install manually, you can make customdice.sty by running latex customdice.ins and make the documentation by running pdflatex customdice.dtx.

      I don’t know why you were having trouble with MiKTeX – I’ll reply to your other comment.


    • Avatar Sanatan

      This solution worked for me on Overleaf.

      Including the customdice package gave an error, customdice.sty not found. The author of the package should look into why.

      • Peter Rowlett Peter Rowlett

        Hi Sanatan,

        The reason for this is that Overleaf doesn’t have the customdice package installed. This is no mystery: my package has been added to CTAN and can be added to your own machine via MiKTeX or TeXLive, but Overleaf don’t routinely update their version of TeXLive with new packages. I believe it should be added to Overleaf within a year when they update their installation to TeXLive 2022. You can read more about this on the Overleaf website.

        So from your point of view, you put \usepackage{customdice} and Overleaf doesn’t have that installed, so yes you will need to add it manually. To do this, download customdice.ins and customdice.dtx, then run latex customdice.ins to create customdice.sty and upload this to your Overleaf project.


        • Avatar Sanatan

          Hi Peter,

          Thank you for your prompt response. I found customdice to be convenient and faster to compile than epsdice, as the render with that took time. Have used it with the workaround for now.

  3. Avatar Paulo Gonzalez

    Thank you very much for the package. It’s very useful! I’ve created the .sty to run it in Overleaf, as you said in a comment, and it works very goog.


(will not be published)

$\LaTeX$: You can use LaTeX in your comments. e.g. $ e^{\pi i} $ for inline maths; \[ e^{\pi i} \] for display-mode (on its own line) maths.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>