TransWikia.com

How can I use a dice symbol inside a math equation?

TeX - LaTeX Asked by Julien__ on February 20, 2021

I would like to use a dice symbol such as those defined in Andrew Swann’s answer, given to Dice symbols for digits up to 9, inside a math equation.

For instance, to model the set of results after a throw, I would like to write :

$$ Omega = {1, 2, 3, 4, 5, 6} $$

Where each number is replaced by the corresponding dice symbol.

One Answer

The epsdice, hhcount, and stix packages all contain macros for drawing dice. For instance, here's an example that loads and makes use of the epsdice package.

enter image description here

documentclass{article}
usepackage{epsdice}
begin{document}
[
Omega={ epsdice{1}, epsdice{2}, epsdice{3}, epsdice{4}, epsdice{5}, epsdice{6} }
]
end{document}

Addendum to address the OP's follow-up query: To center the die symbols vertically, i.e, to align them on the math axis, you could encase them in vcenter{hbox{...}} "wrappers".

enter image description here

documentclass{article}
usepackage{epsdice}
newcommandvcdice[1]{vcenter{hbox{epsdice{#1}}}}
begin{document}
[
Omega={ vcdice{1}, vcdice{2}, vcdice{3}, vcdice{4}, vcdice{5}, vcdice{6} }
]
end{document}

2nd addendum: If you're free to use LuaLaTeX, you could use a Lua for loop to generate most of the die symbols. This may not seem like a big deal if just five symbols are generated; however, it becomes a lot more interesting for use cases that involve more than a dozen or so calls to the same macro.

% !TEX program = lualatex
documentclass{article}
usepackage{epsdice}
newcommandvcdice[1]{vcenter{hbox{epsdice{#1}}}}
begin{document}
[
  Omega = { 
  directlua{ for i=1,5 do tex.sprint ( "vcdice{" .. i .. "}," ) end }
  vcdice{6} }
]
end{document} 

Correct answer by Mico on February 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP