From my previous question/answer Tikz image within a defined box (& the textpos package), @frougon provided a great solution. And now, I'm seeking to have a standard scaling for all of my Tikz-pictures (see the edit/addition).
I want all of my Tikz-pictures to be 3.5cm x 3.5cm, and I can do this by using scale = 3.5/k, where k is the "coordinate-length" of the Tikz-picture.
I'm wondering if there is a way to get the outermost (or length of) coordinates in a Tikz-picture? For example,
\begin{tikzpicture}
\draw (1,4)--(10,7);
\end{tikzpicture}
would have k=9, as the x-axis ranges from 1 to 10 (a difference of 9), while the y=axis ranges from 4 to 7 (a difference of 3).
I would envision some sort of "maximum" function coming into play here. Something like k = max(<largest x coordinate> - <smallest x coordinate >, <largest y coordinate > - <smallest y coordinate >) = max(10-1,7-4) = max(9,3) = 9.
For a more detailed example, consider the following:
\begin{tikzpicture}
\draw[thick] (0,0)--(10,5);
\draw[thick] (0,0)--(5,-10);
\draw[thick] (0,0)--(-10,5);
\draw[thick] (0,0)--(-5,-10);
\draw[thick] (0,0)--(10,-5);
\draw[thick] (0,0)--(-5,10);
\draw (.5,2) node {1};
\draw (-2.5,2.5) node {2};
\draw (-2,-.5) node {3};
\draw (0,-2.5) node {4};
\draw (2.5,-2.5) node {5};
\draw (2.5,0) node {6};
\end{tikzpicture}
In this case, I would want k = 20, as the "length" of the x-axis (and y-axis, in fact), is 20 coordinate units.
Thanks in advance!



tikzpictureby3.5/maximum. Also, I'm confused how\n1and\n2are actually stored and how I would scale the picture (something like\begin{tikzpicture}[scale = 3.5/max{\n1, \n2}) – ryanj1823 Jun 28 '19 at 06:21tikzpicturehow large it will be. However,adustboxallows you to do precisely that, it has some maximum functions of that type. – Jun 28 '19 at 06:24tikzpictures whereas yours won't, as you said (he can use yours with my code, then there should be no font scaling and all should still work). – frougon Jun 28 '19 at 19:15scalebox,adjustboxetc., you can no longer access coordinates withremember picture. In many situations this won't matter, but in some it does. – Jun 28 '19 at 19:18remember pictureusing your technique, my code will apply 1:1 scaling using\scalebox(that is, if you fix yours to usemin:-). Is such 1:1 scaling going to break theremember picturemechanism, or not? If yes, I'll provide an option to disable automatic scaling for the pictures where it is undesirable. (I will try it if you don't know the answer by heart, of course) – frougon Jun 28 '19 at 19:40subnodes by LoopSpace are really cool.) – Jun 28 '19 at 20:11minis better and corrected it, thanks! – Jun 28 '19 at 20:43ptunits, so TikZ converts back and forth and loses the edges. Try e.g.\documentclass[tikz, border=3.14mm]{standalone} \usetikzlibrary{calc} \begin{document} \path let \p1=($(A)-(1,5)$) in \pgfextra{\typeout{\x1,\y1}}; \end{tikzpicture} \end{document}. We probably need to live with these limitations. – Jun 28 '19 at 22:38grid, so I had the impression I was only polluting this discussion with some problem not really relevant (now that I know it was not due to your code). Unrelated: I've added support for thenoscaleoption in my code. To be more useful for real-word usage, I believe your code should accept a parameter used as prefix or suffix for the control sequence... – frougon Jun 28 '19 at 22:41\figscale) written to the.auxfile. Otherwise, only one figure per document can use this mechanism. Also, I don't know why you put\relaxafter the definition in the.auxfile. – frougon Jun 28 '19 at 22:44\relaxbecause LaTeX does not understand\hibernate. ;-) – Jun 29 '19 at 00:17\let\hibernate\relaxin the marmotTeX format. ;-) More seriously, I've extended your style a little bit (mainly: to allow several pictures per document and a target frame that isn't necessarily a square). You can see the short description and the code in my answer. – frougon Jun 29 '19 at 12:11noscaleoption I mentioned above has been renamed toautoscale=false(the corresponding argument is now processed withl3keys). In case the OP wantsautoscale=falseto be the default (probably in order to use your scaling technique most of the time), it can be done with a one-word change that is described in my already-linked answer. – frougon Jun 29 '19 at 12:16