GeneralOptions as \newcommand (package kvsetkeys error undefined)

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

Options as \newcommand (package kvsetkeys error undefined)

Post by loro »

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

Code: Select all

\newcommand{borderwidth=0.5pt,bordercolor={0.2 0.1 0.4},width=35mm}
and build the document i received as an error:

Code: Select all

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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Options as \newcommand (package kvsetkeys error undefined)

Post by Stefan Kottwitz »

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:

Code: Select all

\newcommand{\FixedField}[2][]{\TextField[#1,borderwidth=0.5pt,
    bordercolor={0.2 0.1 0.4},width=35mm]{#2}}
...
\FixedField[name=name]{text}
Stefan
LaTeX.org admin
Post Reply