# How do I Auto-Label Hyperref Fillable Forms \TextField?

Is there any way to put an automatic label into the hyperref package's \TextField parameters field like this:

\newcounter{lexemeCounter}
\newcommand\lexemeCount{\stepcounter{lexeme}\lexemeCounterrabic{lexemeCounter}}

\newcommand{\formlabel}{\value{lexemeCounter}}

\TextField[name=\formlabel]{}


The reason I need to do this is because I have a table with about 1000 entries and I would like to add an editable comment column.

A minimal example would look like this (Although this is a minimal example, I purposely chose to use the longtabu environment, because that is the real-world scenario):

\documentclass{scrartcl}
\usepackage{fontspec} %I only use xelatex
\usepackage{tabu}
\usepackage{longtable}
\usepackage{hyperref}

\newcounter{lexemeCounter}
\newcommand\lexemeCount{\stepcounter{lexemeCounter}\arabic{lexemeCounter}}
\newcommand{\formlabel}{\value{lexemeCounter}}

\begin{document}

\begin{longtabu} to \textwidth{|[1pt black] X[.10,l] | X[.20,l] || X[.20,l] | X|[1pt black]}
Row & English & German & Comments\\
\hline
\lexemeCount & apple   & Apfel  & \TextField[name=\formlabel]{}\\
\lexemeCount & mouse   & Maus   & \TextField[name=\formlabel]{}
\end{longtabu}

\end{document}


All of my attempts have failed. For some reason, the name=\formlabel stays literal (or does not increment) and therefore all edits are applied to each \TextField

• What about macro? Something like \def\TF{\expandafter\csname TextField\endcsname[name=\formlabel}? – Eddy_Em Jun 18 '13 at 5:02

\formlabel (i.e. \value{lexemeCounter}}) does not expand to something useful as a name for the \TextField command, so it's ignored and does show nothing.

Using \number\value{lexemeCounter} however works. The value must be explicitly changed to a literal number representation for a string label (i.e. a text field name)

\documentclass{article}
\usepackage{fontspec} %I only use xelatex
\usepackage{tabu}
\usepackage{longtable}
\usepackage{hyperref}

\newcounter{lexemeCounter}
\newcommand\lexemeCount{\stepcounter{lexemeCounter}\arabic{lexemeCounter}}%
\newcommand{\formlabel}{textfield::\number\value{lexemeCounter}}%

\begin{document}

\begin{Form}
\begin{longtabu} to \textwidth{|[1pt black] X[.10,l] | X[.20,l] || X[.20,l] | X|[1pt black]}
Row & English & German & Comments\tabularnewline
\hline
\lexemeCount & apple   & Apfel  & \TextField[name=\formlabel]{} \tabularnewline
\lexemeCount & mouse   & Maus   & \TextField[name=\formlabel]{}
\end{longtabu}
\end{Form}

\end{document}


• Thanks for the explanation and answer that is to the point! I forgot about this question. I have since found a new way to accomplish my goals, but this will come in handy again I am sure. (btw, I read your profile. There are no stupid questions as they all lead to understanding. (just stupid people haha) – Jonathan Komar Mar 9 '15 at 19:51
• @macmadness86: That profile text was a rant due to anger ;-) I will insert my original text in near future. – user31729 Mar 9 '15 at 21:00