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}
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:
\dice[yellow,black]{4}
\bigdotdice[white,brown]
\textdice[gray,blue]{\(\infty\)}
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
You can also change the basic unit of the dice to make bigger images. For example:
\Huge
Dice: \dice{5}
\setdicefacesize{3}
\dice{5}
\setdicefacesize{10}
\dice{5}
\setdicefacesize{20}
\dice{5}
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:
What is drawn on the face is arbitrary, so I can do things like this:
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).
\documentclass{article}
\usepackage{customdice}
\begin{document}
\dice{6}
\end{document}
I like this! Thanks
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.
Thanks
Saul Molina
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.
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.
Regards,
Peter.
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:
%\documentclass[a4paper]{article}
%\usepackage{a4wide}
%\usepackage{customdice}
%\usepackage{rotating}
%\usepackage{amsfonts}
%\usepackage{ltablex}
%\usepackage{doc}
%\usepackage{hyperref}
%\usetikzlibrary{shapes.geometric}
%\begin{document}
%\DocInput{customdice.dtx}
%\end{document}
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
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 runningpdflatex customdice.dtx
.I don’t know why you were having trouble with MiKTeX – I’ll reply to your other comment.
Peter.
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.
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 runlatex customdice.ins
to create customdice.sty and upload this to your Overleaf project.Peter.
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.
Thank so much!
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.
Thank you so much, it is quite simple.