Mark every centimeter on a line

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I am building a TikZ graph for a set of furniture for example a table.



Because the exact lengths are important there I would like every of the four lines that make the border of the rectangle to have a little mark for every centimeter they span, so I can easily spot the lengths with my eyes.



I thought a decoration might be a way to go but I did not find anything suitable in the TikZ documentation. Also the axes from the plot area might be a way?



My current workaround is a slihtly different approach, but perhaps someone knows a good way to handle it in TikZ?



documentclassstandalone

usepackagetikz
usetikzlibrarybackgrounds

begindocument

begintikzpicture
node[%
rectangle,
draw,
gray,
line width=.5mm,
minimum width=2.2cm, minimum height=1.6cm,
inner sep=0.2mm] (box) %
Table%
;

% measure lines
draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.north west) -- (box.north east);
draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.north west) -- (box.south west);
draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.south west);
draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

beginscope[on background layer]
node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
draw[gray] (box.north east) -- (box.south west) ;
draw[gray] (box.north west) -- (box.south east) ;
endscope

endtikzpicture

enddocument


Thank you for your thoughts and input!










share|improve this question







New contributor




jœ. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    2
    down vote

    favorite












    I am building a TikZ graph for a set of furniture for example a table.



    Because the exact lengths are important there I would like every of the four lines that make the border of the rectangle to have a little mark for every centimeter they span, so I can easily spot the lengths with my eyes.



    I thought a decoration might be a way to go but I did not find anything suitable in the TikZ documentation. Also the axes from the plot area might be a way?



    My current workaround is a slihtly different approach, but perhaps someone knows a good way to handle it in TikZ?



    documentclassstandalone

    usepackagetikz
    usetikzlibrarybackgrounds

    begindocument

    begintikzpicture
    node[%
    rectangle,
    draw,
    gray,
    line width=.5mm,
    minimum width=2.2cm, minimum height=1.6cm,
    inner sep=0.2mm] (box) %
    Table%
    ;

    % measure lines
    draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.north west) -- (box.north east);
    draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.north west) -- (box.south west);
    draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.south west);
    draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

    beginscope[on background layer]
    node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
    draw[gray] (box.north east) -- (box.south west) ;
    draw[gray] (box.north west) -- (box.south east) ;
    endscope

    endtikzpicture

    enddocument


    Thank you for your thoughts and input!










    share|improve this question







    New contributor




    jœ. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I am building a TikZ graph for a set of furniture for example a table.



      Because the exact lengths are important there I would like every of the four lines that make the border of the rectangle to have a little mark for every centimeter they span, so I can easily spot the lengths with my eyes.



      I thought a decoration might be a way to go but I did not find anything suitable in the TikZ documentation. Also the axes from the plot area might be a way?



      My current workaround is a slihtly different approach, but perhaps someone knows a good way to handle it in TikZ?



      documentclassstandalone

      usepackagetikz
      usetikzlibrarybackgrounds

      begindocument

      begintikzpicture
      node[%
      rectangle,
      draw,
      gray,
      line width=.5mm,
      minimum width=2.2cm, minimum height=1.6cm,
      inner sep=0.2mm] (box) %
      Table%
      ;

      % measure lines
      draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.north west) -- (box.north east);
      draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.north west) -- (box.south west);
      draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.south west);
      draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

      beginscope[on background layer]
      node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
      draw[gray] (box.north east) -- (box.south west) ;
      draw[gray] (box.north west) -- (box.south east) ;
      endscope

      endtikzpicture

      enddocument


      Thank you for your thoughts and input!










      share|improve this question







      New contributor




      jœ. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I am building a TikZ graph for a set of furniture for example a table.



      Because the exact lengths are important there I would like every of the four lines that make the border of the rectangle to have a little mark for every centimeter they span, so I can easily spot the lengths with my eyes.



      I thought a decoration might be a way to go but I did not find anything suitable in the TikZ documentation. Also the axes from the plot area might be a way?



      My current workaround is a slihtly different approach, but perhaps someone knows a good way to handle it in TikZ?



      documentclassstandalone

      usepackagetikz
      usetikzlibrarybackgrounds

      begindocument

      begintikzpicture
      node[%
      rectangle,
      draw,
      gray,
      line width=.5mm,
      minimum width=2.2cm, minimum height=1.6cm,
      inner sep=0.2mm] (box) %
      Table%
      ;

      % measure lines
      draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.north west) -- (box.north east);
      draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.north west) -- (box.south west);
      draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.south west);
      draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

      beginscope[on background layer]
      node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
      draw[gray] (box.north east) -- (box.south west) ;
      draw[gray] (box.north west) -- (box.south east) ;
      endscope

      endtikzpicture

      enddocument


      Thank you for your thoughts and input!







      tikz-pgf






      share|improve this question







      New contributor




      jœ. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      jœ. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      jœ. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 4 hours ago









      jœ.

      133




      133




      New contributor




      jœ. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      jœ. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      jœ. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          This is taken almost literally from the 2nd example on p. 585 of the pgfmanual.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarybackgrounds,decorations.markings

          begindocument

          begintikzpicture[cm mark/.style=postaction=decorate,
          decoration=markings,% switch on markings mark=% actually add a mark
          mark=between positions 0 and 1 step 1cm
          with

          draw[#1] (0pt,-2pt) -- (0pt,2pt);

          ]
          node[%
          rectangle,
          draw,
          gray,
          line width=.5mm,
          minimum width=2.2cm, minimum height=1.6cm,
          inner sep=0.2mm] (box) %
          Table%
          ;

          % measure lines
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=blue,thin] (box.north west) -- (box.north east);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,,cm mark=red,line width=0.4pt] (box.north west) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark] (box.south east) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

          beginscope[on background layer]
          node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
          draw[gray] (box.north east) -- (box.south west) ;
          draw[gray] (box.north west) -- (box.south east) ;
          endscope

          endtikzpicture

          enddocument


          enter image description here



          Here is another version which prints the distances.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarybackgrounds,decorations.markings

          begindocument

          begintikzpicture[cm mark/.style args=#1 with labels #2postaction=decorate,
          decoration=markings,% switch on markings mark=% actually add a mark
          mark=between positions 0 and 1 step 1cm
          with

          pgfmathtruncatemacromydistpgfkeysvalueof/pgf/decoration/mark
          info/sequence number-1
          draw[#1] (0pt,-2pt) -- (0pt,2pt);
          coordinate (Xmark) at (0,0);
          pgftransformreset
          path (Xmark) node[#1,outer sep=3pt,#2] $mydist$cm;

          ]
          node[%
          rectangle,
          draw,
          gray,
          line width=.5mm,
          minimum width=2.2cm, minimum height=1.6cm,
          inner sep=0.2mm] (box) %
          Table%
          ;

          % measure lines
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=blue,thin with labels above] (box.north west) -- (box.north east);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=line width=0.4pt,green!60!black with labels left] (box.north west) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=line width=0.4pt,red with labels below] (box.south east) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

          beginscope[on background layer]
          node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
          draw[gray] (box.north east) -- (box.south west) ;
          draw[gray] (box.north west) -- (box.south east) ;
          endscope

          endtikzpicture
          enddocument


          enter image description here



          There are many ways I see how this might be customized, e.g. by dropping 0 and so on. However, as my crystal ball got stolen, I do not know if you are interested in such options.






          share|improve this answer






















          • Thank your very much for your nice hint and even putting it into code I could directly use. Very nice!
            – jœ.
            3 hours ago










          • @jœ. You're welcome! And welcome to TeX.SE!
            – marmot
            3 hours ago










          • awesome, that is a great addition too! And I am feeling with you for the loss of your beloved crystal ball. Really hoping you get it back one day! ;)
            – jœ.
            3 hours ago










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "85"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          jœ. is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f452034%2fmark-every-centimeter-on-a-line%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          This is taken almost literally from the 2nd example on p. 585 of the pgfmanual.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarybackgrounds,decorations.markings

          begindocument

          begintikzpicture[cm mark/.style=postaction=decorate,
          decoration=markings,% switch on markings mark=% actually add a mark
          mark=between positions 0 and 1 step 1cm
          with

          draw[#1] (0pt,-2pt) -- (0pt,2pt);

          ]
          node[%
          rectangle,
          draw,
          gray,
          line width=.5mm,
          minimum width=2.2cm, minimum height=1.6cm,
          inner sep=0.2mm] (box) %
          Table%
          ;

          % measure lines
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=blue,thin] (box.north west) -- (box.north east);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,,cm mark=red,line width=0.4pt] (box.north west) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark] (box.south east) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

          beginscope[on background layer]
          node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
          draw[gray] (box.north east) -- (box.south west) ;
          draw[gray] (box.north west) -- (box.south east) ;
          endscope

          endtikzpicture

          enddocument


          enter image description here



          Here is another version which prints the distances.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarybackgrounds,decorations.markings

          begindocument

          begintikzpicture[cm mark/.style args=#1 with labels #2postaction=decorate,
          decoration=markings,% switch on markings mark=% actually add a mark
          mark=between positions 0 and 1 step 1cm
          with

          pgfmathtruncatemacromydistpgfkeysvalueof/pgf/decoration/mark
          info/sequence number-1
          draw[#1] (0pt,-2pt) -- (0pt,2pt);
          coordinate (Xmark) at (0,0);
          pgftransformreset
          path (Xmark) node[#1,outer sep=3pt,#2] $mydist$cm;

          ]
          node[%
          rectangle,
          draw,
          gray,
          line width=.5mm,
          minimum width=2.2cm, minimum height=1.6cm,
          inner sep=0.2mm] (box) %
          Table%
          ;

          % measure lines
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=blue,thin with labels above] (box.north west) -- (box.north east);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=line width=0.4pt,green!60!black with labels left] (box.north west) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=line width=0.4pt,red with labels below] (box.south east) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

          beginscope[on background layer]
          node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
          draw[gray] (box.north east) -- (box.south west) ;
          draw[gray] (box.north west) -- (box.south east) ;
          endscope

          endtikzpicture
          enddocument


          enter image description here



          There are many ways I see how this might be customized, e.g. by dropping 0 and so on. However, as my crystal ball got stolen, I do not know if you are interested in such options.






          share|improve this answer






















          • Thank your very much for your nice hint and even putting it into code I could directly use. Very nice!
            – jœ.
            3 hours ago










          • @jœ. You're welcome! And welcome to TeX.SE!
            – marmot
            3 hours ago










          • awesome, that is a great addition too! And I am feeling with you for the loss of your beloved crystal ball. Really hoping you get it back one day! ;)
            – jœ.
            3 hours ago














          up vote
          3
          down vote



          accepted










          This is taken almost literally from the 2nd example on p. 585 of the pgfmanual.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarybackgrounds,decorations.markings

          begindocument

          begintikzpicture[cm mark/.style=postaction=decorate,
          decoration=markings,% switch on markings mark=% actually add a mark
          mark=between positions 0 and 1 step 1cm
          with

          draw[#1] (0pt,-2pt) -- (0pt,2pt);

          ]
          node[%
          rectangle,
          draw,
          gray,
          line width=.5mm,
          minimum width=2.2cm, minimum height=1.6cm,
          inner sep=0.2mm] (box) %
          Table%
          ;

          % measure lines
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=blue,thin] (box.north west) -- (box.north east);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,,cm mark=red,line width=0.4pt] (box.north west) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark] (box.south east) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

          beginscope[on background layer]
          node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
          draw[gray] (box.north east) -- (box.south west) ;
          draw[gray] (box.north west) -- (box.south east) ;
          endscope

          endtikzpicture

          enddocument


          enter image description here



          Here is another version which prints the distances.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarybackgrounds,decorations.markings

          begindocument

          begintikzpicture[cm mark/.style args=#1 with labels #2postaction=decorate,
          decoration=markings,% switch on markings mark=% actually add a mark
          mark=between positions 0 and 1 step 1cm
          with

          pgfmathtruncatemacromydistpgfkeysvalueof/pgf/decoration/mark
          info/sequence number-1
          draw[#1] (0pt,-2pt) -- (0pt,2pt);
          coordinate (Xmark) at (0,0);
          pgftransformreset
          path (Xmark) node[#1,outer sep=3pt,#2] $mydist$cm;

          ]
          node[%
          rectangle,
          draw,
          gray,
          line width=.5mm,
          minimum width=2.2cm, minimum height=1.6cm,
          inner sep=0.2mm] (box) %
          Table%
          ;

          % measure lines
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=blue,thin with labels above] (box.north west) -- (box.north east);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=line width=0.4pt,green!60!black with labels left] (box.north west) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=line width=0.4pt,red with labels below] (box.south east) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

          beginscope[on background layer]
          node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
          draw[gray] (box.north east) -- (box.south west) ;
          draw[gray] (box.north west) -- (box.south east) ;
          endscope

          endtikzpicture
          enddocument


          enter image description here



          There are many ways I see how this might be customized, e.g. by dropping 0 and so on. However, as my crystal ball got stolen, I do not know if you are interested in such options.






          share|improve this answer






















          • Thank your very much for your nice hint and even putting it into code I could directly use. Very nice!
            – jœ.
            3 hours ago










          • @jœ. You're welcome! And welcome to TeX.SE!
            – marmot
            3 hours ago










          • awesome, that is a great addition too! And I am feeling with you for the loss of your beloved crystal ball. Really hoping you get it back one day! ;)
            – jœ.
            3 hours ago












          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          This is taken almost literally from the 2nd example on p. 585 of the pgfmanual.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarybackgrounds,decorations.markings

          begindocument

          begintikzpicture[cm mark/.style=postaction=decorate,
          decoration=markings,% switch on markings mark=% actually add a mark
          mark=between positions 0 and 1 step 1cm
          with

          draw[#1] (0pt,-2pt) -- (0pt,2pt);

          ]
          node[%
          rectangle,
          draw,
          gray,
          line width=.5mm,
          minimum width=2.2cm, minimum height=1.6cm,
          inner sep=0.2mm] (box) %
          Table%
          ;

          % measure lines
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=blue,thin] (box.north west) -- (box.north east);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,,cm mark=red,line width=0.4pt] (box.north west) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark] (box.south east) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

          beginscope[on background layer]
          node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
          draw[gray] (box.north east) -- (box.south west) ;
          draw[gray] (box.north west) -- (box.south east) ;
          endscope

          endtikzpicture

          enddocument


          enter image description here



          Here is another version which prints the distances.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarybackgrounds,decorations.markings

          begindocument

          begintikzpicture[cm mark/.style args=#1 with labels #2postaction=decorate,
          decoration=markings,% switch on markings mark=% actually add a mark
          mark=between positions 0 and 1 step 1cm
          with

          pgfmathtruncatemacromydistpgfkeysvalueof/pgf/decoration/mark
          info/sequence number-1
          draw[#1] (0pt,-2pt) -- (0pt,2pt);
          coordinate (Xmark) at (0,0);
          pgftransformreset
          path (Xmark) node[#1,outer sep=3pt,#2] $mydist$cm;

          ]
          node[%
          rectangle,
          draw,
          gray,
          line width=.5mm,
          minimum width=2.2cm, minimum height=1.6cm,
          inner sep=0.2mm] (box) %
          Table%
          ;

          % measure lines
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=blue,thin with labels above] (box.north west) -- (box.north east);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=line width=0.4pt,green!60!black with labels left] (box.north west) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=line width=0.4pt,red with labels below] (box.south east) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

          beginscope[on background layer]
          node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
          draw[gray] (box.north east) -- (box.south west) ;
          draw[gray] (box.north west) -- (box.south east) ;
          endscope

          endtikzpicture
          enddocument


          enter image description here



          There are many ways I see how this might be customized, e.g. by dropping 0 and so on. However, as my crystal ball got stolen, I do not know if you are interested in such options.






          share|improve this answer














          This is taken almost literally from the 2nd example on p. 585 of the pgfmanual.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarybackgrounds,decorations.markings

          begindocument

          begintikzpicture[cm mark/.style=postaction=decorate,
          decoration=markings,% switch on markings mark=% actually add a mark
          mark=between positions 0 and 1 step 1cm
          with

          draw[#1] (0pt,-2pt) -- (0pt,2pt);

          ]
          node[%
          rectangle,
          draw,
          gray,
          line width=.5mm,
          minimum width=2.2cm, minimum height=1.6cm,
          inner sep=0.2mm] (box) %
          Table%
          ;

          % measure lines
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=blue,thin] (box.north west) -- (box.north east);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,,cm mark=red,line width=0.4pt] (box.north west) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark] (box.south east) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

          beginscope[on background layer]
          node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
          draw[gray] (box.north east) -- (box.south west) ;
          draw[gray] (box.north west) -- (box.south east) ;
          endscope

          endtikzpicture

          enddocument


          enter image description here



          Here is another version which prints the distances.



          documentclass[tikz,border=3.14mm]standalone
          usetikzlibrarybackgrounds,decorations.markings

          begindocument

          begintikzpicture[cm mark/.style args=#1 with labels #2postaction=decorate,
          decoration=markings,% switch on markings mark=% actually add a mark
          mark=between positions 0 and 1 step 1cm
          with

          pgfmathtruncatemacromydistpgfkeysvalueof/pgf/decoration/mark
          info/sequence number-1
          draw[#1] (0pt,-2pt) -- (0pt,2pt);
          coordinate (Xmark) at (0,0);
          pgftransformreset
          path (Xmark) node[#1,outer sep=3pt,#2] $mydist$cm;

          ]
          node[%
          rectangle,
          draw,
          gray,
          line width=.5mm,
          minimum width=2.2cm, minimum height=1.6cm,
          inner sep=0.2mm] (box) %
          Table%
          ;

          % measure lines
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=blue,thin with labels above] (box.north west) -- (box.north east);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=line width=0.4pt,green!60!black with labels left] (box.north west) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm,
          yshift=.25mm,cm mark=line width=0.4pt,red with labels below] (box.south east) -- (box.south west);
          draw[line width=.5mm, dash pattern=on 1cm off 0.01cm on 1cm, xshift=5mm, yshift=.25mm] (box.south east) -- (box.north east);

          beginscope[on background layer]
          node[circle,draw=black,fill=darkgray,minimum size=0.25cm] at (box.north east) ;
          draw[gray] (box.north east) -- (box.south west) ;
          draw[gray] (box.north west) -- (box.south east) ;
          endscope

          endtikzpicture
          enddocument


          enter image description here



          There are many ways I see how this might be customized, e.g. by dropping 0 and so on. However, as my crystal ball got stolen, I do not know if you are interested in such options.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 3 hours ago

























          answered 3 hours ago









          marmot

          59.4k463128




          59.4k463128











          • Thank your very much for your nice hint and even putting it into code I could directly use. Very nice!
            – jœ.
            3 hours ago










          • @jœ. You're welcome! And welcome to TeX.SE!
            – marmot
            3 hours ago










          • awesome, that is a great addition too! And I am feeling with you for the loss of your beloved crystal ball. Really hoping you get it back one day! ;)
            – jœ.
            3 hours ago
















          • Thank your very much for your nice hint and even putting it into code I could directly use. Very nice!
            – jœ.
            3 hours ago










          • @jœ. You're welcome! And welcome to TeX.SE!
            – marmot
            3 hours ago










          • awesome, that is a great addition too! And I am feeling with you for the loss of your beloved crystal ball. Really hoping you get it back one day! ;)
            – jœ.
            3 hours ago















          Thank your very much for your nice hint and even putting it into code I could directly use. Very nice!
          – jœ.
          3 hours ago




          Thank your very much for your nice hint and even putting it into code I could directly use. Very nice!
          – jœ.
          3 hours ago












          @jœ. You're welcome! And welcome to TeX.SE!
          – marmot
          3 hours ago




          @jœ. You're welcome! And welcome to TeX.SE!
          – marmot
          3 hours ago












          awesome, that is a great addition too! And I am feeling with you for the loss of your beloved crystal ball. Really hoping you get it back one day! ;)
          – jœ.
          3 hours ago




          awesome, that is a great addition too! And I am feeling with you for the loss of your beloved crystal ball. Really hoping you get it back one day! ;)
          – jœ.
          3 hours ago










          jœ. is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          jœ. is a new contributor. Be nice, and check out our Code of Conduct.












          jœ. is a new contributor. Be nice, and check out our Code of Conduct.











          jœ. is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f452034%2fmark-every-centimeter-on-a-line%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          Long meetings (6-7 hours a day): Being “babysat” by supervisor

          What does second last employer means? [closed]

          One-line joke