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.

2
  • 1
    search for TextField hyperref May 1, 2021 at 15:39
  • 1
    This post answers more than what you ask... Yes, \TextField[...options...]{tag} does the trick that comes with the hyperref package.
    – Partha D.
    May 2, 2021 at 1:56

2 Answers 2

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}
4
  • 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 2, 2021 at 2: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 2, 2021 at 2: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 2, 2021 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 3, 2021 at 6: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

1
  • 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 1, 2021 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .