3

I was wondering if it is just a question of someones own opionion or is there a clear superior way of using unit-of-measure such as

  • pt,
  • px,
  • cm,
  • ex,
  • ...

when drawing a picture or setting the tikzstyles? Maybe some way is more "dynamic" or have other advantages?

SRel
  • 1,313
  • 4
    If you don't specify a unit, TikZ assumes it's in centimetres. After that, they are all converted to sp (scaled points) inside TeX, so I guess the answer is "the one you need or the one you like" – Phelype Oleinik Aug 20 '18 at 18:06
  • 5
    @PhelypeOleinik Not really. Try \documentclass[tikz,border=3.14mm]{standalone} \begin{document} \begin{tikzpicture} \draw (0,0) circle (1); \begin{scope}[xshift=2] \draw (0,0) circle (1); \end{scope} \end{tikzpicture} \end{document} to see that the argument of xshift is interpreted as points whereas the circle radii are interpreted as cm. Actually, most of the more low-level stuff used points rather than centimeters. –  Aug 20 '18 at 18:17
  • @marmot Ooh, this is new for me... This seems messy :P But either way, everything is converted using the appropriate scale factor. – Phelype Oleinik Aug 20 '18 at 18:22
  • @PhelypeOleinik Yes, if you specify the units. Again, I think that the "default" units for TikZ are points, not centimeters. What I mean by that is that internally TikZ is using points. –  Aug 20 '18 at 18:24
  • 2
    @marmot I think that's because TeX defaults everything to points. If you say \the\dimexpr1cm you'll get it converted to pt. – Phelype Oleinik Aug 20 '18 at 18:26
  • The default for inner sep is .333em, so it depends. – John Kormylo Aug 20 '18 at 18:37
  • I really think that all relevant information is contained in the answers to this question. TikZ is IMO not special, it just comes with very nice means to convert lengths. Try e.g. \pgfmathsetmacro{\mylen}{1cm+2pt+3ex}, you'll get the sum of the three dimensions in points. (Of course, \mylen here is no length, just a macro, in this case just 43.36937, which specifies the distance in points.) –  Aug 20 '18 at 18:53

0 Answers0