So I want to create a macro that I can use to automatically generate a rectangle in TikZ. I would like to specify text (an equation) that should be placed in the middle and automatically generate nodes that I can attach arrows and lines to.
I'll be honest, I don't really have any idea what I'm doing. Here is my attempt so far:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{math}
\begin{document}
\newcommand{\tikzTF}[5]{%
\tikzmath{
\hcenter = 0.5*#1 + 0.5*#3;
\vcenter = 0.5*#2 + 0.5*#4;
function min(\x,\y) {
if \x > \y then {return \y;} else {return \x;}
};
function max(\x,\y) {
if \x > \y then {return \x;} else {return \y;}
};
\l = min(#1,#3);
\ri = max(#1,#3);
\t = max(#2,#4);
\b = min(#2,#4);
\draw [black] (#1,#2) rectangle (#3,#4);
\node (#5-c) at ( \hcenter, \vcenter ) {#5};
\node (#5-tc) at ( \hcenter, \t ) {#5};
\node (#5-bc) at ( \hcenter, \b ) {#5};
\node (#5-lc) at ( \ri , \vcenter ) {#5};
\node (#5-rc) at ( \l , \vcenter ) {#5};
}
}
\begin{tikzpicture}
\tikzTF{0}{0}{1.5}{1}{text}
\end{tikzpicture}
\end{document}