tikz add tag
For the following standalone approach, I need to use TikZ `external` library to:

1. make the externally built image have the same font size of main/calling document
2. rebuild the image in case of change in: (a) its source code, and (b) the font size of the parent document
3. know the best practice of saving the externally built `tikzpicture` code in an external file to be inputted in the main document. Is there a better approach than just using `\input`?

P.S. I don't understand why the following code stopped working as expected.

		\begin{tikzpicture}[x=1em, y=1em]
			\draw (0,0) rectangle node{\DTMcurrenttime} (4,4);

\usepackage[mode=buildnew, subpreambles=false]{standalone}
	\DTMcurrenttime	\includestandalone{pic\jobname}
Top Answer
user 3.14159
This is an attempt to answer parts 1 and 2 of the question. This answer uses the `external` library of Ti*k*Z. After adding the stuff between `\makeatletter` and `\makeatother` to the preamble all you need to do is to add 
\tikzset{external/watch/font size}
*after* `\begin{document}`. Some comments are in order:
1. The code is a bit excessive, i.e. if one wanted to solve just this issue less lines of code are needed. The rationale is to make it easier to watch other parameters. (One may also use a variation thereof to determine the relevant bounding boxes for animations.)
2. As mentioned, you have to add `\tikzset{external/watch/font size}` after `\begin{document}`. In principle one could waive this requirement. However, IMHO these days it is impossible to use hooks like `\AtBeginDocument` and friends unless you are a L3 team member. 
3. `external` is great. But it has deficits when used together with e.g. the `tikzmark` library. Conceivably similar tricks may ultimately allow those libraries to be used simultaneously.
4. If you have some additions or changes in mind, please let me know, this is really just a first proof-of-principle version.
5. This stuff does not work if you change the font size locally, but one could conceivably come up with something that covers such cases, too, yet it would be more complicated.

\immediate\write\@mainaux{\string\expandafter\xdef\noexpand\csname pgfk@/tikz/external/watch/stored/#1\string\endcsname{#2}}}%
\ifcsname pgfk@/tikz/external/watch/stored/#1\endcsname
\edef#2{\csname pgfk@/tikz/external/watch/stored/#1\endcsname}%
\tikzset{external/watch/.cd,store/.code 2 args={%
get/.code 2 args={\tikz@external@watch@get@from@aux{#1}{#2}},
font size/.code={\tikzset{external/watch/get={font size}{\pgfutil@tempa},
external/watch/store={font size}{\f@size}}%
\tikzset{/tikz/external/force remake}%

\tikzset{external/watch/font size}

\begin{tikzpicture}[x=1em, y=1em,blue]
\draw (0,0) rectangle node{\DTMcurrenttime} (4,4);

![Screen Shot 2020-12-18 at 5.46.15 PM.png](/image?hash=4c98c730d9a663b83ce7802a18a9743c40fbca76095a49585d99886bcf7f4580)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.