4

I would like to draw two differents pictures. One of them consists of two rectangles, one with text and the other (below the first) with fillable text, as shown below:

Picture with fillable text

Here is text of this length is just normal text, and the fillable text consists in three TextField of the hyperref package separated by a /, like the date DD/MM/YYYY.

The other picture is very similar but the only difference is that the fillable text is deleted:

Picture without fillable text

However, I am not able to produce the combination of the two rectangles in one (so that the bottom one is centered) using tikzset.

MWE:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{hyperref}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usetikzlibrary{shapes.multipart}
\tikzset{pics/fillable subject/.style n args={1}{code={\node[draw,text height=1.5ex,text width=5em,rounded corners] (#1) {\TextField[name=day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~/~\TextField[name=month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1 1}]~/~\TextField[name=year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1 1}]\\};}}}

\begin{document}

\begin{Form}
    \begin{tikzpicture}
        \pic at (0,0) {fillable subject={Geography}};
    \end{tikzpicture}
\end{Form}

\end{document}

What I have done

Requirements

  • There are two pictures: fillable subject and non-fillable subject.
  • fillable subject must have one argument: the name of the subject (Math, History, etc.). non-fillable subject must have no arguments.
  • Each picture has a specified size, it does not change depending on the length of the text.
  • There are a lot of them in one tikzpicture environment, so the code should be as handle as possible, since we can add several pictures one next to the other.
  • We must be able to create an arrow between two pictures that connect the upper rectangles.

Note

The background color of the TextField command does not matter.

This is what I want:

What I want

Thanks!!

  • P.S. When I delete \\ inside the argument of subject/.style I get ! Paragraph ended before \@TextField was complete. Is it possible to eliminate the redundant line break? I do not know why it happens. – manooooh Mar 8 at 2:11
  • 2
    You can replace \\ by {}. Perhaps you can mention that the blue boxes only appear on certain viewers. – marmot Mar 8 at 2:31
4

This is a refined proposal.

\documentclass{article}
\usepackage[showframe,margin=1in]{geometry}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{hyperref}
\usepackage{tikz}
%\usetikzlibrary{calc}
\tikzset{text field/.style={text height=1.5ex,align=center,rounded corners},
title field/.style={text height=2ex,text depth=0.3em,anchor=south,text
width=11em,align=center,font=\sffamily},
pics/fillable subject/.style={code={%
\node[text field] (-TF) 
{\hspace*{-0.5em}\TextField[name=#1-day,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1
1}]~~/\hspace*{-0.15em}\TextField[name=#1-month,width=1em,charsize=7pt,maxlen=2,bordercolor={1 1
1}]~~/\hspace*{-0em}\TextField[name=#1-year,width=2em,charsize=7pt,maxlen=4,bordercolor={1 1
1}]{}~};
%\path let \p1=($(-TF.east)-(-TF.west)$) in \pgfextra{\typeout{\x1}};
\node[title field] (-Title) 
at ([yshift=0.4em]-TF.north) {#1};
\draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
 -- cycle;
\draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
 }},
pics/nonfillable subject/.style={code={%
\node[text field] (-TF) 
{\hspace{1.55em}~/~\hspace{1.6em}~/~\hspace{1.55em}{}};
\node[title field] (-Title) 
at ([yshift=0.4em]-TF.north) {#1};
%\path let \p1=($(-TF.east)-(-TF.west)$) in \pgfextra{\typeout{\x1}};
\draw[rounded corners] (-TF.south west) |- (-Title.south west)
|- (-Title.north east) -- (-Title.south east) -| (-TF.south east)
 -- cycle;
\draw ([xshift=4pt]-Title.south west) -- ([xshift=-4pt]-Title.south east);
 }}, 
 }

\begin{document}

\begin{Form}
    \begin{tikzpicture}
        \path (0,0) pic (Geo)  {fillable subject={Geography}}
        (5,0) pic (Whatever)  {nonfillable subject={Whatever}}
        (10,0) pic[draw=red] (Math)  {fillable subject={Math}};
        \draw[-latex] (Geo-Title) -- (Whatever-Title);
        \draw[-latex] (Whatever-Title) -- (Math-Title);
    \end{tikzpicture}
\end{Form}

\end{document}

enter image description here

I also loaded the geometry package to increase the width of the page, showframe is only to show that the figure fits.

  • It looks very nice, thanks! Some requirements: 1) I do not find the necessary commands to make the lower rectangle of the non-fillable subject have the same size as the fillable subject. 2) It is necessary to correct the position of the / (I tried to add a space with \hspace in non-fillable subject but it generates error). 3) It is necessary to center the three TextField commands and the ´/´. Visually, imgur.com/a/BC0jIlW. – manooooh Mar 8 at 4:14
  • Are the names of the subjects vertically centered? – manooooh Mar 8 at 4:20
  • 1
    @manooooh Better now? – marmot Mar 8 at 5:15
  • Now you have fulfilled all the requirements, great! – manooooh Mar 8 at 6:53
  • 1
    @manooooh According to what I find you only need to give the text fields unique names. I updated my answer accordingly. – marmot Mar 8 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.