TransWikia.com

Change symbol drawn in tikz by a character in the pdf text

TeX - LaTeX Asked on August 9, 2021

I was drawing my set of dice, like the following code:

documentclass{article}
usepackage   {ifthen}
usepackage   {tikz}

tikzset%
{%
  pics/die/.style={%
    code={%
      begin{scope}[x=1ex,y=1ex]
      draw[line width=0.15ex,rounded corners=0.3ex] (-0.75,-0.75) rectangle (0.75,0.75);
      ifthenelse{#1 > 3}
      {%
        fill (-0.4, 0.4) circle (0.15); % top left dot
        fill ( 0.4,-0.4) circle (0.15); % bottom right dot
      }{}% do nothing
      ifthenelse{#1 > 1}
      {%
        fill ( 0.4, 0.4) circle (0.15); % top right dot
        fill (-0.4,-0.4) circle (0.15); % bottom left dot
      }{}
      ifthenelse{#1 = 6}
      {%
        fill (-0.4,0) circle (0.15);    % center left dot
        fill ( 0.4,0) circle (0.15);    % center right dot
      }{}
      ifthenelse{#1 = 1 OR #1 = 3 OR #1 = 5}{fill (0,0) circle (0.15);}{} % center dot
      end{scope}
      }}
}

begin{document}
huge

foreachi in {1,...,6}{tikz pic[red] {die={i}};,}

Snake Eyes: tikzpic {die={1}}; tikzpic {die={1}};

Fever Five: tikzpic {die={4}}; tikzpic {die={1}};
end{document}

enter image description here

My question is whether it would be possible to assign a character to each die so that you could select it as text in the pdf. I want, for example, to select the ‘Fever Five: [die 4] [die 1]’ line in the pdf, and copy-paste in another document as ‘Fever Five: 4 1’.

I know that there are unicode characters for this purpose, and probably many packages that can do the same, but I want to do it this way (if possible).

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