LaTeX forum ⇒ GeneralOptions as \newcommand (package kvsetkeys error undefined) Topic is solved

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

Options as \newcommand (package kvsetkeys error undefined)

Postby loro » Wed Sep 09, 2015 11:28 pm

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
  1. \newcommand{borderwidth=0.5pt,bordercolor={0.2 0.1 0.4},width=35mm}

and build the document i received as an error:
  1. 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.
Reason: added code markup


User avatar
Stefan Kottwitz
Site Admin
Posts: 8523
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany

Postby Stefan Kottwitz » Thu Sep 10, 2015 2:47 pm

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:

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

Site admin

Return to “General”

Who is online

Users browsing this forum: No registered users and 9 guests