1

I’d love to create something like this using latex. enter image description here

There’s a great post achieving something similar with letters, so I think I just need some tikz code for the digits themselves. Is anybody able to help?

Thanks so much!

  • Sort of depends on how much resolution you want. You can do a pretty good job using a 5x9 grid. Somewhat related http://www.elfsoft2000.com/worksheets/statplot.pdf – John Kormylo Sep 18 '23 at 03:07
  • Welcome to TeX.SX! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. – dexteritas Sep 18 '23 at 06:44
  • You have already linked a possible solution that could be applied to the digits in the same way. Where is the problem? – dexteritas Sep 18 '23 at 06:46

2 Answers2

0

Here's a starting point for you. To better follow the code you cited I took the liberty to:

  • indicate by comments, what the various parts do
  • remove some parts not needed here (let's call it simplification)
  • adjusted the indenting to better see the codes structures
  • added "1" and "4" as a demo

As Tikz can be overwhelming for the beginner, though it's "simple" once you understood its basic concepts, I suggest to study the 4 tutorials at the beginning of the pgfmanual several times. To separate frequently from less frequently used commands I suggest to focus on these first:

  • \draw and styles (put as [options]) ... ;
  • \path ... ;

Amongst the more advanced statements used here try to get the essence of these:

\foreach \X [count=\Y] in {A,1,4}
  • lets variable \X take values A, 1 and 4
  • uses index-counts (of \X), which runs through 1, 2, and 3, used for placements
code={
...
}
  • a way to put a series of "drawing"-commands inside a \pic
  • where you can consider a picture \pic as a kind of tikz-macro

That should make ~ 70 % of the code quite readable to you.

Finally, just introduce more digits inside the \tikzset-statement the way I indicated AND expand the list at the end of this statemen \foreach \X [count=\Y] in {A,1,4} . Take care to define the -mid coordinate somewhere in the drawing path, as it's needed to draw those lines of characters in the documents main-code.

Look for \arc, circle, ellipse for the other digits inside the manual, while recapitulating the path-concept : to perform a series of actions until the ; .

result

\documentclass[tikz,border=3mm]{standalone}
 % ~~~ drawing on 3 layers, display-order as stated ~~~~~~~~~
 \pgfdeclarelayer{background} 
 \pgfdeclarelayer{behind} 
 \pgfdeclarelayer{foreground} 
 \pgfsetlayers{behind,background,main,foreground}
% from https://tex.stackexchange.com/a/460842/121799
%
% ~~~ drawing each character ~~~~~~~~~~~~~~~~~~~~~
\tikzset{pics/.cd,
  A/.style={
    code={
            % ~~~ the A's outer shape (start, up, down) ~~~
            \draw[pic actions] 
            (0,-0.5) -- (0.3,0.4) -- (0.6,-0.5);
            % ~~~ the A's line in the middle ~~~~~~~
            \draw[pic actions](0.1,1/3-0.45) -- coordinate(-mid)
            (0.5,1/3-0.45);
            % ~~~│ some kind of advance ~~~
            \path (0.7,0);
      }
    },
  %
  1/.style={
    code={
            % ~~~ the 1, with coordinate defined for the middle ~~~
            \draw[pic actions] 
            (0.3,0.4)-- coordinate(-mid) (0.3,-.1) -- (0.3,-0.5);
            % ~~~│ some kind of advance ~~~
            \path (0.7,0);
      }
    },
  %
  4/.style={
    code={
            % ~~~ the 4, with coordinate defined for the middle ~~~
            \draw[pic actions] 
            (0.5,0.4)-- (0.5,-0.5);
            \draw[pic actions] 
            (0.1,0.4)-- coordinate(-mid) (0.1,-.1) -- (0.6,-.1);
            % ~~~│ some kind of advance ~~~
            \path (0.7,0);
      }
    },
  %
}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
 \begin{tikzpicture}
  \begin{scope}[local bounding box=letters]
    % ~~~ left column of letters A-Z ~~~~~~~~
    \foreach \X [count=\Y] in {A,1,4}
     {
        % ~~~ drawing upper and lower line for the characters ~~~
        \draw[thick,blue] (0,-\Y-0.25) -- ++ (5,0) (0,-\Y+0.25) -- ++ (5,0);
        % ~~~ drawing the character as a \pic ~~~~~~~~~~
        \path[thick] (0.5,-\Y) pic[scale=0.5](\X){\X}% first solid character
            % ~~~ introducing 4 dashed characters ~~~
            foreach \Z in {1,...,4}
            {(\Z+0.5,-\Y) pic[scale=0.5,dash pattern=on 1.5pt off 1.2pt]{\X}}
        ;
    % ~~~ drawing the dashed red line in the middle
    \begin{pgfonlayer}{background}
      \draw[red,dashed] (0,-\Y|-\X-mid) -- ++ (5,0);
    \end{pgfonlayer}
  }
        % ~~~ NOT NEEDED HERE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        %   % ~~~ right column of letters a-z ~~~~~~~~
        %   \foreach \X [count=\Y] in {a,...,z}
        %    {\draw[thick,blue] (6,-\Y-0.25) -- ++ (5,0) (6,-\Y+0.25) -- ++ (5,0);
        %     \path[thick] (6.5,-\Y) pic[scale=0.5](\X){\X} foreach \Z in {1,...,4}
        %     {(\Z+6.5,-\Y) pic[scale=0.5,dash pattern=on 1.5pt off 1.2pt]{\X}};
        %    \begin{pgfonlayer}{background}
        %     \draw[red,dashed] (6,-\Y|-\X-mid) -- ++ (5,0);
        %    \end{pgfonlayer}
        %     }  

\end{scope}

% ~~~ NOT NEEDED HERE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ % ~~~ putting all those blueish colors on paper ~~~
% \begin{pgfonlayer}{behind} % \path[left color=cyan!10,right color=cyan!30] % (letters.south west) rectangle (letters.north east); % \end{pgfonlayer} % \draw[line width=2mm,blue!30] ([xshift=-3mm,yshift=3mm]letters.north west) % -- ([xshift=-3mm,yshift=-3mm]letters.south west);

\end{tikzpicture} \end{document}

MS-SPO
  • 11,519
  • 1
    That is extremely helpful! I can see how you’ve defined the characters and how I could do similar for the other digits. Thanks so much. The only thing I didn’t understand what what was meant be “some kind of advance”. Could you explain this and the final \path?

    Thanks again!

    – Wendy Taylor Sep 18 '23 at 09:28
  • Fine :) // Right, I didn’t fully understand that one either. Commenting it out and changing the first coordinate (x) didn‘t seem to do much, if anything. Changing the second (y) had impact on the amount of space at the top of the page. So, it‘s up to you to leave it in there or to delete it. – MS-SPO Sep 18 '23 at 10:09
  • BTW, it may be a good idea to experiment with arcs and ellipses in a test document first. Once you understand the plotting-like mechanism, transfer may be more self-evident. – MS-SPO Sep 18 '23 at 10:10
0

Thanks to your great help, I figured out the other digits. It was good fun!

    \pgfdeclarelayer{behind} 
    \pgfdeclarelayer{foreground} 
       \pgfsetlayers{behind,background,main,foreground}
    % from     https://tex.stackexchange.com/a/460842/121799
    %
    % ~~~ drawing each character     ~~~~~~~~~~~~~~~~~~~~~
    \tikzset{pics/.cd,
     9/.style={code={\draw[pic actions] (0.2,0.15) circle[x radius=0.2,y radius=0.25]; 
    \draw[pic actions] (0.4,-0.5) -- coordinate[pos=0.5](-mid)(0.4,0.4);}}, 
      %
      6/.style={code={\draw[pic actions] (0.2,-0.25) circle[x radius=0.2,y radius=0.25];
    \draw[pic actions] (0.0,-0.175) -- coordinate[pos=0.5](-mid)(0.3,0.4);}}, 
      %
      %
      2/.style={
    code={
            % ~~~ the 4, with coordinate defined for the middle ~~
            \draw[pic actions]
   (0,0.25) to[out=45,in=45,looseness=2.5]  (0,-0.45);
  \draw[pic actions](0,-0.45) -- (0.5,-0.45);
   \path (0.7,0);}},
    1/.style={code={\draw[pic actions] (0.3,0.4) -- (0.3,-0.5);}}, 
  %
        4/.style={code={\draw[pic actions] (0.3,0.4) -- (0.3,-0.5);
    \draw[pic actions] (0,0.4) -- (0,-0.1) -- (0.5,-0.1);}}, 
  %
    Is    5/.style={code={\draw[pic actions] (0.5,0.4) -- (0,0.4) -- (0,0.1)-- (0.15,0.1);
\draw (0.15,0.1) arc(90:-90:0.4cm and 0.275cm);
\draw[pic actions] (0,-0.45) -- (0.15,-0.45);
%\draw (-0.02,0.1) arc(90:-90:0.5cm and 0.3cm);
  %\draw[pic actions] (0,0.1)  to[out=0,in=0,looseness=3] (0,-0.45);
  }}, 
  %
        3/.style={code={
\draw (0.0,0.35) arc(130:-90:0.25cm and 0.2cm);
\draw (0.15,0) arc(90:-120:0.3cm and 0.225cm);
  }}, 
  %
   7/.style={code={\draw[pic actions] (0.0,0.4) -- (0.5,0.4) -- (0.2,-0.45);
  }}, 
  %
     8/.style={code={
 \draw (0.25,0.4) arc(90:-90:0.2cm and 0.2cm);
  \draw (0.25,0.4) arc(90:270:0.2cm and 0.2cm);
   \draw (0.25,0) arc(90:-90:0.25cm and 0.25cm);
  \draw (0.25,0) arc(90:270:0.25cm and 0.25cm);
  }}, 
  %
      0/.style={code={
 \draw (0.25,0.4) arc(90:-90:0.25cm and 0.45cm);
  \draw (0.25,0.4) arc(90:270:0.25cm and 0.45cm);
  }}, 
  %
}
 % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
 \begin{tikzpicture}

\begin{scope}[local bounding box=letters] % ~~~ left column of letters A-Z ~~~~~~~~ \foreach \X [count=\Y] in {1,2,3,4,5,6,7,8,9,0} { % ~~~ drawing upper and lower line for the characters ~~~ \draw[thick,blue] (0,-\Y-0.25) -- ++ (5,0) (0,-\Y+0.25) -- ++ (5,0); % ~~~ drawing the character as a \pic ~~~~~~~~~~ \path[thick] (0.5,-\Y) picscale=0.5{\X}% first solid character % ~~~ introducing 4 dashed characters ~~~ foreach \Z in {1,...,4} {(\Z+0.5,-\Y) pic[scale=0.5,dash pattern=on 1.5pt off 1.2pt]{\X}} ;

  }
        % ~~~ NOT NEEDED HERE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        %   % ~~~ right column of letters a-z ~~~~~~~~
        %   \foreach \X [count=\Y] in {a,...,z}
        %    {\draw[thick,blue] (6,-\Y-0.25) -- ++ (5,0) (6,-\Y+0.25) -- ++ (5,0);
        %     \path[thick] (6.5,-\Y) pic[scale=0.5](\X){\X} foreach \Z in {1,...,4}
        %     {(\Z+6.5,-\Y) pic[scale=0.5,dash pattern=on 1.5pt off 1.2pt]{\X}};
        %    \begin{pgfonlayer}{background}
        %     \draw[red,dashed] (6,-\Y|-\X-mid) -- ++ (5,0);
        %    \end{pgfonlayer}
        %     }  

\end{scope}

% ~~~ NOT NEEDED HERE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ % ~~~ putting all those blueish colors on paper ~~~
% \begin{pgfonlayer}{behind} % \path[left color=cyan!10,right color=cyan!30] % (letters.south west) rectangle (letters.north east); % \end{pgfonlayer} % \draw[line width=2mm,blue!30] ([xshift=-3mm,yshift=3mm]letters.north west) % -- ([xshift=-3mm,yshift=-3mm]letters.south west);

\end{tikzpicture} \end{document}

Roland
  • 6,655