0

I'm sure this has been answered already but I couldn't find it.

Because I have no idea how it's called I don't know what tag to use, this may have nothing to do with text manipulation.

I want to make a form with empty boxes that the user could write in (change the text after the pdf compiles).

I should be able to:

  1. Set the color inside the box
  2. Set the size of the box

Please include in the answer all packages required and an example would also be appreciated.

Partha D.
  • 2,250
Toma
  • 494

2 Answers2

2

A simple, minimal example to get started for just what you want:

Textbox image with \TextField

\documentclass{article}

\usepackage{xcolor} \usepackage{hyperref}

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

\begin{document}

My name is: \TF{a}\

I would like to: \TF[25em]{b}

\end{document}

Partha D.
  • 2,250
  • Yes! How do you call these text boxes with user defined text? I asked the most inaccurate question without the name, well done for understanding what I meant. Thank you very very much – Toma May 02 '21 at 02:17
  • 1
    In general computer terminology, they are called "text-box", while we use the LaTeX command \TextField to invoke that. Welcome. – Partha D. May 02 '21 at 02:29
  • A follow up question, is there a way to have that in a way that does not require a different instance of every command (without needing the names a and b)? To be used in big tables and such – Toma May 02 '21 at 16:46
  • Using the macro \TF{tag} you can use as many text boxes you like. I put in an optional argument \TF[width]{tag} in case you want a text box with a different width than the default value (15em here). If you need more optional arguments, try this. Otherwise, if all textboxes you need are to be of the same color, width, etc., just use something like Name: TF{a}\\ Place: \TF{b}\\ Phone: \TF{c}\\ ...\\ Hobby: \TF{p}. For a table just replace the : with & and embed in a tabular environment. – Partha D. May 03 '21 at 06:00
1

Not sure to understand the question. Empty boxes can be done with tcolorbox.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lmodern}

\tcbset{sharp corners}

\begin{document} Name: \tcbox[colback=red!30, on line]{\hspace*{3cm}}

Explain what you want \begin{tcolorbox}[colback=blue!20, height=5cm] \end{tcolorbox} \end{document}

enter image description here

Ignasi
  • 136,588
  • I want to create the pdf such that a user can enter text in the boxes and change that text. Like a form. – Toma May 01 '21 at 15:19