I'm writing a document where there are some equations which I'm commenting with hf-tikz
package. It needs two LaTeX compilations in order to get the right coordinates and to draw everything in the right place.
Looking at How to make a standalone document with one equation? I've been able to build a standalone
file with my equation. But I don't know what's the best way to include it in a main document.
Besides, I wonder if it's even possible to keep fonts and sizes, so the inserted equation looks like the main document. Or is the standalone equation always included as an image?
Here is an example of one of my standalone equations:
\documentclass[preview]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[customcolors]{hf-tikz}
\begin{document}
\vspace*{10mm}
\begin{equation*}
\begin{split}
4x^2 + 12x + 9 & = \tikzmarkin{a1}(0.05,-0.2)(-0.05,0.4)(2x)^2 \tikzmarkend{a1} + 2\cdot \tikzmarkin{a2}(0.05,-0.2)(-0.05,0.4)(2x)\tikzmarkend{a2} \cdot \tikzmarkin{a3}(0.05,-0.2)(-0.05,0.4)3\tikzmarkend{a3} + \tikzmarkin{a4}(0.05,-0.2)(-0.05,0.4)3^2\tikzmarkend{a4} \\[6ex]
& = (\,\, \tikzmarkin{a9}2x \tikzmarkend{a9}+ \tikzmarkin{a10} 3\tikzmarkend{a10} \,\,)^2
\end{split}
\end{equation*}
\begin{tikzpicture}[remember picture,overlay]% adjust the shift from "col" to move the position of the annotation
\coordinate (a5) at ($(a1)+(0.5,0.6)$);
\node[align=left,above] at (a5) {\large$a^2$};
\path[-stealth,red,draw] (a5) -- ($(a1)+(0.5,0)$);
\coordinate (a6) at ($(a2)+(0.4,0.6)$);
\node[align=left,above] at (a6) {\large$a$};
\path[-stealth,red,draw] (a6) -- ($(a2)+(0.4,0)$);
\coordinate (a7) at ($(a3)+(0.15,0.6)$);
\node[align=left,above] at (a7) {\large$b$};
\path[-stealth,red,draw] (a7) -- ($(a3)+(0.15,0)$);
\coordinate (a8) at ($(a4)+(0.2,0.6)$);
\node[align=left,above] at (a8) {\large$b^2$};
\path[-stealth,red,draw] (a8) -- ($(a4)+(0.2,0)$);
\coordinate (a11) at ($(a9)+(0.3,0.3)$);
\node[align=left,above] at (a11) {\large$a$};
\path[-stealth,red,draw] (a11) -- ($(a9)+(0.3,0)$);
\coordinate (a12) at ($(a10)+(0.2,0.3)$);
\node[align=left,above] at (a12) {\large$b$};
\path[-stealth,red,draw] (a12) -- ($(a10)+(0.2,0)$);
\end{tikzpicture}
\end{document}
UPDATE TO CLARIFY I don't want the standalone file to be included as raw tex, since it's possible I reuse some of the coordinates names in other equations. The following doesn't work, as I'm not loading the required packages in the main preamble.
\documentclass{article}
\usepackage{standalone}
\begin{document}
\includestandalone{my-standalone-file}
\end{document}
\includestandalone
\input
or similar to insert the raw text, I have to be careful to not repeat coordinate names, and always have to run LaTeX two times to ge the right result. On the other way, if I insert this equations as images...in order to keep font formatting from the main document, some kind of preamble should be shared, doesn't it? What is the best option to manage this?