## LaTeX forum ⇒ General ⇒ Options as \newcommand (package kvsetkeys error undefined) Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
loro
Posts: 5
Joined: Wed Sep 09, 2015 10:44 pm

### Options as \newcommand (package kvsetkeys error undefined)

Hi at all,
I'm pretty new to Latex and I'm not shure if this is the right Section, so please be gentle to me and my questions .Her is my first one.
Is it possible to declare options as a newcommand or similar to use it multiple times.
I have some TextFields in my document defined like this:

`\TextField[name=name,borderwidth=0.5pt,bordercolor={0.2 0.1 0.4},width=35mm]{}`

The Options `borderwidth`, `bordercolor` and `width` are always be the same. How can I define this Options as a `\newcommand`?
If I define a
`\newcommand{borderwidth=0.5pt,bordercolor={0.2 0.1 0.4},width=35mm}`

and build the document i received as an error:
`package kvsetkeys error undefined key borderwidth=0.5pt,bordercolor={0.2 0.1 0.4},width=35mm`

How can I solve this problem.
Last edited by cgnieder on Thu Sep 10, 2015 4:10 pm, edited 1 time in total.

Tags:

Stefan Kottwitz
Posts: 8523
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Hi Loro,

welcome to the forum!

Yes, in LaTeX is very good practice, to put repeated things into a macro. It's more than just saving time: you have the settings in one place, which makes changing much easier.

I would create a macro which calls \TextField with the desired options. Such as:

`\newcommand{\FixedField}[2][]{\TextField[#1,borderwidth=0.5pt,     bordercolor={0.2 0.1 0.4},width=35mm]{#2}}...\FixedField[name=name]{text}`

Stefan