2

I want to set one argument of a function permanently to a specific value. In my case it is the function \TextField which has the argument bordercolor. I want to set it globally to "nothing" instead of writing \TextField[bordercolor=,name=xyz] everytime. This was my attempt which leads to an error: \renewcommand{\TextField}{\TextField[bordercolor=]}

TobiSonne
  • 271

2 Answers2

2
\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}
\let\TEXTFIELD\TextField
\renewcommand\TextField[1][]{\TEXTFIELD[bordercolor=,#1]}

\begin{document}
\begin{Form}
\TextField[name=xy]{foo}
\TextField[bordercolor=red,name=xy]{bar}
\end{Form}
\end{document}

enter image description here

user187802
  • 16,850
2

hyperref has a command to which you can append default keys for the textfield (by default it contains only "print"):

\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{etoolbox}
\apptocmd\DefaultOptionsofText{,bordercolor=}{}{\fail}

\begin{document}
\begin{Form}
\TextField[name=xy]{foo}
\TextField[bordercolor=red,name=xy]{bar}
\end{Form}
\end{document}

The alternative is to simply set the key with \kvsetkeys (this will affect the border of other field types too):

\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}


\begin{document}
\begin{Form}
\kvsetkeys{Field}{bordercolor=}

\TextField[name=x]{foo}
\TextField[bordercolor=red,name=y]{bar}


\end{Form}
\end{document}
Ulrike Fischer
  • 327,261