The way to determine the width of the entire image in PGF (latex)

I have a latex macro that draws an image using PGF and Tikz according to the given parameters. The width of the picture depends on these parameters.

PGF automatically calculates the resulting width of any pattern, so the user does not need to explicitly specify it (for example, when using the latex assembly in the image environment).

However, I need to know the width of the drawing to be drawn. Because of this, I could calculate it as PGF, but it will be quite some work (many if statements ...). Is there a way to ask PGF what is the width of the image to be drawn (some kind of command I expect)? Either inside the tikzpicture environment, or immediately after it? Thanks for the help.

+3
source share
1 answer

What I will probably do is set the environment tikzpicturein the field and then find the width of the field:

\setbox0=\vbox{\hbox{%
  \begin{tikzpicture}
    % ...
  \end{tizpicture}%
}}
The width of the following picture is {\the\wd0}.
\box0

Please note that after starting the \box0window will be inserted into the document and its contents will be destroyed; you need to request the width of the window before you do this. If you want to keep the width, you can save it in the measurement register with \dimen0=\wd0; alternatively, you can use \copybox0one that inserts the field but does not destroy it (although this may lead to a memory leak).

, , , < \vbox (, , ); , \hbox, - unboxing ( ). , , - , TikZ PDF .

+5

Source: https://habr.com/ru/post/1740661/


All Articles