3

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!!

manooooh
  • 3,203
  • 2
  • 21
  • 46
  • 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 08 '19 at 02:11
  • 2
    You can replace \\ by {}. Perhaps you can mention that the blue boxes only appear on certain viewers. –  Mar 08 '19 at 02:31

1 Answers1

5

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, https://imgur.com/a/BC0jIlW. – manooooh Mar 08 '19 at 04:14
  • Are the names of the subjects vertically centered? – manooooh Mar 08 '19 at 04:20
  • 1
    @manooooh Better now? –  Mar 08 '19 at 05:15
  • Now you have fulfilled all the requirements, great! – manooooh Mar 08 '19 at 06:53
  • I have noticed a (big) problem: when wanting to complete a TextField, it is automatically completed in all TextFields with the same name. For example, take our MWEs and try to complete the first date and you will see how it is completed in the one on the right. Will it be very difficult to correct? :S I am killing you since I know you do not know anything about Form environment :(, do you want me to ask a new question? – manooooh Mar 08 '19 at 06:55
  • 1
    @manooooh According to what I find you only need to give the text fields unique names. I updated my answer accordingly. –  Mar 08 '19 at 14:52