6

This is what I got so far with the code given below.

enter image description here

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}

\makeatletter

\providecommand{\tabularnewline}{\\}

\usepackage{hyperref}

\makeatother

\usepackage{babel}
\begin{document}
\begin{Form}[action=http://your-web-server.com/path/receiveform.cgi]

\begin{tabular}{ll>{\centering}p{0.6cm}ll}
Name: & \TextField[height=0.01cm, width=5cm] &  & Name: & Need TextField here  \tabularnewline
Client's Name: & \TextField[height=0.01cm, width=5cm] &  & Advisor Name: & \rule{5cm}{1pt}\tabularnewline
\end{tabular}

\vspace*{0.3cm}

Have you ? \hfill{} \CheckBox[height=0.01cm, width=0.4cm] \enspace{} Yes
\hfill{} \CheckBox[height=0.01cm, width=0.4cm] \enspace{} No


\Submit{Submit}

\end{Form}
\end{document}

Questions

  1. How to control the height of TextField as two TextFields are overlapping?
  2. How to change color of TextField?
  3. How to make two CheckBoxes mutually exclusive so only one can be checked at once?

An help will be highly appreciated. Thanks

4
+50

You can change the height of a textfield with the height option or by redefining \DefaultHeightofText. But the minimal height of the field will always be the height of the surrounding box. In a tabular cell (which contains a \strut) this is the height of the cell. If you want to avoid this you can add an additional box:

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

\begin{document}
%suppress the label:
\def\LayoutTextField#1#2{% label, field
  #2%
}
\begin{Form}
\def\DefaultHeightofText{5pt}

\mbox{\strut\TextField[width=3cm]{namea}} \mbox{\TextField[width=3cm]{namea}}


\begin{tabular}{ll}
Name: & \mbox{\TextField[width=3cm]{namea}} \\%smaller
Name: & \TextField[width=3cm]{namea}
\end{tabular}


\end{Form}
\end{document}

enter image description here

  • Thanks @Ulrike for helpful answer. Would appreciate if you can guide me how to get green color TextFields? Thanks – MYaseen208 Dec 28 '16 at 14:47
2
  1. In general, the height of a TextField is controlled by the macro \DefaultHeightofText; I can't tell you why it does not work in a table. I had this issue also once and I gave up on it. It works in regular text (see below).
  2. You can change to color of text inside TextField with color key. The color spec must be in RGB triple, in the range 0..1. There is also a bordercolor key.
  3. CheckBoxes and TextFields take a mandatory label argument. This label is used to make them unambiguous. If you want to leave this argument empty, use the name key for a unique label.

Code:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{babel}
\usepackage{xcolor}

\usepackage{hyperref}

\begin{document}

\begin{Form}[action=http://your-web-server.com/path/receiveform.cgi]

\noindent \def\DefaultHeightofText{5pt}%
\begin{tabular}{@{}ll>{\centering\arraybackslash}p{0.6cm}ll}
  Name: &  \TextField[name=name, width=5cm, color=0.18 0.55 0.34, % seagreen
          bordercolor=1 0 1, charsize=9pt, height=3pt]{}
        &  & Name: & Need TextField here \\
  Client's Name: & \TextField[name=client, width=5cm]{}
                 &  & Advisor Name: & \rule{5cm}{1pt}
\end{tabular}

\vspace*{0.3cm}

\noindent
Have you ? \hfill{} \CheckBox[height=0.01cm, width=0.4cm]{Yes}
\hfill{} \CheckBox[height=0.01cm, width=0.4cm]{No}

\noindent
\Submit{Submit}

\vspace{3ex}

\def\DefaultHeightofText{5pt}
\TextField{5pt}

\vspace{3ex}

\def\DefaultHeightofText{\baselineskip}
\TextField{baselineskip}

\end{Form}

\end{document}

enter image description here

  • Thanks @Arash for your answer. I need TextField in the last column of the table. Would appreciate if you address that too. Thanks – MYaseen208 Dec 26 '16 at 20:54
  • Just add \TextField[width=4cm]{} to the last column – Salim Bou Dec 27 '16 at 9:26
  • @MYaseen208 - Maybe I'm missing something, you can add a TextField in the last column by adding something like \TextField[name=namei, width=5cm]{}. Just make sure you have a unique value to name key. – Arash Esbati Dec 27 '16 at 10:17
2

Rather then tabular environment you can use multicol package to split your fields on two columns, in this case you can modify height of textfield as you like

More detail can be found in this answer

\documentclass[english]{article}
\usepackage[margin=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{babel}
\usepackage{xcolor}
\usepackage{multicol}
\usepackage{hyperref}

\parindent0pt

\renewcommand*{\LayoutTextField}[2]{\makebox[7em][l]{#1: }%
  \raisebox{\baselineskip}{\raisebox{-\height}{#2}}}


\begin{document}

\begin{Form}[action=http://your-web-server.com/path/receiveform.cgi]

\begin{multicols}{2}
 \TextField[name=name, width=4cm, color=0.18 0.55 0.34, % seagreen
          bordercolor=1 0 1, charsize=9pt]{Name} \vskip2ex
 \TextField[name=client ,width=4cm]{Client's Name}       

 \columnbreak

 \TextField[name=name2,width=4cm]{Name} \vskip2ex
  Advisor Name:  \rule{4cm}{1pt}
\end{multicols}

\vspace*{0.3cm}

\noindent
Have you ? \hfill{} \CheckBox[height=0.01cm, width=0.4cm]{Yes}
\hfill{} \CheckBox[height=0.01cm, width=0.4cm]{No}

\noindent
\Submit{Submit}
\end{Form}

\end{document}

enter image description here

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.