How can I add a textfield in a Tikz drawing's node?

Given is the following TextField command:

\newcommand{\TF}[2][15em]{\TextField[borderwidth=0.1pt,
width=#1,
height=1.25em,
charsize=10pt,
backgroundcolor=blue!
50!gray!20,
color=blue!44!
black,
bordercolor=red!20,
name=#2
]{}}


I'd like to imbed it with in the red and blue rectangles in the following Tikz drawing:

\documentclass{article}
\usepackage{tikz, tikz-3dplot}
\usetikzlibrary{calc}
\usepackage{fouriernc}
\usepackage[top=2cm, bottom=2cm, outer=0cm, inner=0cm]{geometry}
\pgfmathsetmacro{\b}{0.1}
\pgfmathsetmacro{\c}{1-\b}
\newcommand{\pentagon}[6]{
\filldraw[fill=gray,draw=black]
($\c*(#1)+\b*(#2)$)--
($\c*(#1)+\b*(#3)$)--
($\c*(#1)+\b*(#4)$)--
($\c*(#1)+\b*(#5)$)--
($\c*(#1)+\b*(#6)$)--cycle;
}
\newcommand{\hexagon}[4]{
\draw[#4]
($\c*(#1)+\b*(#2)$)--
($\b*(#1)+\c*(#2)$)--
($\c*(#2)+\b*(#3)$)--
($\b*(#2)+\c*(#3)$)--
($\c*(#3)+\b*(#1)$)--
($\b*(#3)+\c*(#1)$)--cycle;
}
\begin{document}
\tdplotsetmaincoords{65}{100}
\begin{tikzpicture}[tdplot_main_coords,scale=1,line join=round, overlay]
\pgfmathsetmacro\a{1}
\pgfmathsetmacro{\phi}{\a*(1+sqrt(5))/2}
\path
coordinate(A) at (0+4,\phi+2,\a)
coordinate(B) at (0+4,\phi+2,-\a)
coordinate(C) at (0+4,-\phi+2,\a)
coordinate(D) at (0+4,-\phi+2,-\a)
coordinate(E) at (\a+4,0+2,\phi)
coordinate(F) at (\a+4,0+2,-\phi)
coordinate(G) at (-\a+4,0+2,\phi)
coordinate(H) at (-\a+4,0+2,-\phi)
coordinate(I) at (\phi+4,\a+2,0)
coordinate(J) at (\phi+4,-\a+2,0)
coordinate(K) at (-\phi+4,\a+2,0)
coordinate(L) at (-\phi+4,-\a+2,0);
coordinate(TF) at (-\phi+4,\a+2,0);
%MORE POINTS
\draw[red,ultra thick,rounded corners] (2.1,0.1) rectangle (4,3.46);
\draw[blue,ultra thick,rounded corners] (4.2,3) rectangle (7,1.65);
%G-CEAKL "TOP"
\hexagon{G}{C}{E}{draw opacity = 0.2}
\hexagon{G}{E}{A}{draw opacity = 0.2}
\hexagon{G}{A}{K}{draw opacity = 0.2}
\hexagon{G}{K}{L}{draw opacity = 0.2}
\hexagon{G}{L}{C}{draw opacity = 0.2}
%F-IJDHB "BOTTOM"
\hexagon{F}{I}{J}{draw opacity = 0.2}
\hexagon{F}{J}{D}{draw opacity = 0.2}
\hexagon{F}{D}{H}{draw opacity = 0.2}
\hexagon{F}{H}{B}{draw opacity = 0.2}
\hexagon{F}{B}{I}{draw opacity = 0.2}
%CJEIABKHLD "STRIP"
\hexagon{C}{J}{E}{draw opacity = 0.2}
\hexagon{J}{E}{I}{draw opacity = 0.2}
\hexagon{E}{I}{A}{draw opacity = 0.2}
\hexagon{I}{A}{B}{draw opacity = 0.2}
\hexagon{A}{B}{K}{draw opacity = 0.2}
\hexagon{B}{K}{H}{draw opacity = 0.2}
\hexagon{K}{H}{L}{draw opacity = 0.2}
\hexagon{H}{L}{D}{draw opacity = 0.2}
\hexagon{L}{D}{C}{draw opacity = 0.2}
\hexagon{D}{C}{J}{draw opacity = 0.2}
)
\end{tikzpicture}
\end{document}


Of course, the color of the rectangles is not important to the final result.

P.S. I do not know how to compile the example I gave here, please tell me how to do so

Just use the textbox with \TF[width]{name} at the place you need.

\documentclass{article}
\usepackage{tikz, tikz-3dplot}
\usetikzlibrary{calc}
\usepackage{fouriernc}
\usepackage[top=2cm, bottom=2cm, outer=0cm, inner=0cm]{geometry}

\usepackage{hyperref}

\newcommand{\TF}[2][15em]{\TextField[borderwidth=0.1pt,
width=#1,
height=2em,
charsize=10pt,
backgroundcolor=blue!50!gray!20,
color=blue!33!black,
bordercolor=red!20,
name=#2
]{}}

\pgfmathsetmacro{\b}{0.1}
\pgfmathsetmacro{\c}{1-\b}
\newcommand{\pentagon}[6]{
\filldraw[fill=gray,draw=black]
($\c*(#1)+\b*(#2)$)--
($\c*(#1)+\b*(#3)$)--
($\c*(#1)+\b*(#4)$)--
($\c*(#1)+\b*(#5)$)--
($\c*(#1)+\b*(#6)$)--cycle;
}
\newcommand{\hexagon}[4]{
\draw[#4]
($\c*(#1)+\b*(#2)$)--
($\b*(#1)+\c*(#2)$)--
($\c*(#2)+\b*(#3)$)--
($\b*(#2)+\c*(#3)$)--
($\c*(#3)+\b*(#1)$)--
($\b*(#3)+\c*(#1)$)--cycle;
}
\begin{document}
\tdplotsetmaincoords{65}{100}
\begin{tikzpicture}[tdplot_main_coords,scale=1,line join=round, overlay]
\pgfmathsetmacro\a{1}
\pgfmathsetmacro{\phi}{\a*(1+sqrt(5))/2}
\path
coordinate(A) at (0+4,\phi+2,\a)
coordinate(B) at (0+4,\phi+2,-\a)
coordinate(C) at (0+4,-\phi+2,\a)
coordinate(D) at (0+4,-\phi+2,-\a)
coordinate(E) at (\a+4,0+2,\phi)
coordinate(F) at (\a+4,0+2,-\phi)
coordinate(G) at (-\a+4,0+2,\phi)
coordinate(H) at (-\a+4,0+2,-\phi)
coordinate(I) at (\phi+4,\a+2,0)
coordinate(J) at (\phi+4,-\a+2,0)
coordinate(K) at (-\phi+4,\a+2,0)
coordinate(L) at (-\phi+4,-\a+2,0);
coordinate(TF) at (-\phi+4,\a+2,0);
%MORE POINTS
% \draw[red,ultra thick,rounded corners] (2.1,0.1) rectangle (4,3.46);
% \draw[blue,ultra thick,rounded corners] (4.2,3) rectangle (7,1.65);%
%TEXT BOXES
\coordinate (M) at ($(E)!0.5!(H)$);
\node[above] at (M) {\TF[8em]{top}};%
\node[below] at (M) {\TF[5em]{bot}};
%G-CEAKL "TOP"
\hexagon{G}{C}{E}{draw opacity = 0.2}
\hexagon{G}{E}{A}{draw opacity = 0.2}
\hexagon{G}{A}{K}{draw opacity = 0.2}
\hexagon{G}{K}{L}{draw opacity = 0.2}
\hexagon{G}{L}{C}{draw opacity = 0.2}
%F-IJDHB "BOTTOM"
\hexagon{F}{I}{J}{draw opacity = 0.2}
\hexagon{F}{J}{D}{draw opacity = 0.2}
\hexagon{F}{D}{H}{draw opacity = 0.2}
\hexagon{F}{H}{B}{draw opacity = 0.2}
\hexagon{F}{B}{I}{draw opacity = 0.2}
%CJEIABKHLD "STRIP"
\hexagon{C}{J}{E}{draw opacity = 0.2}
\hexagon{J}{E}{I}{draw opacity = 0.2}
\hexagon{E}{I}{A}{draw opacity = 0.2}
\hexagon{I}{A}{B}{draw opacity = 0.2}
\hexagon{A}{B}{K}{draw opacity = 0.2}
\hexagon{B}{K}{H}{draw opacity = 0.2}
\hexagon{K}{H}{L}{draw opacity = 0.2}
\hexagon{H}{L}{D}{draw opacity = 0.2}
\hexagon{L}{D}{C}{draw opacity = 0.2}
\hexagon{D}{C}{J}{draw opacity = 0.2}
)
\end{tikzpicture}
\end{document}


to get something like this:

P.S. Overleaf is a good place to get started.

• I tried something similar and also integrating your answer but it does not compile. I'm not sure why. I'll keep trying, because your answer alone works. Error reads: "! Undefined control sequence. \node[above] at (M) {\TF"
– Toma
May 4 at 3:26
• Have you defined the coordinate (M) with \coordinate (M) at ($(E)!0.5!(H)$); ? I used that so that the text boxes are placed above and below the centre of the figure which scales with the value of \a. If you decide not to change \a, you can replace (M) with some absolute coordinate like \node at (3, 2) {\TF[8em]{top}}; etc. May 4 at 3:37
• Also, check that you have defined the \newcommand{\TF} in the preamble. May 4 at 5:24