{pgfkeys} concerns a flexible key management system in TikZ/PGF.

learn more… | top users | synonyms

75
votes
2answers
15k views

Should \tikzset or \tikzstyle be used to define TikZ styles?

The PGF/TikZ manual states in section 12.4 Using Graphic Options, page 120 (v2.10), that TikZ styles can be set using: \tikzset{my style/.style={<tikz options>},...} However, in several ...
32
votes
1answer
3k views

optional arguments to tikzpicture to set style globally

I can't get my head around how to get tikz and pgfkeys to do what I want. I would like to define a command which draws a little tikz picture. I'd like this command that would take optional keyval ...
26
votes
2answers
718 views

How do I debug pgfkeys?

I'm sure if you're reading this question you are already familiar with my love for pgfkeys. However, it is absolutely impossible to debug: \tracingmacros is a total mess, with every key expanding to ...
25
votes
2answers
919 views

Arguments for TikZ style

Motivation To put arrows inside of a TikZ path I have defined myself a TikZ style arrow inside. To make it even more portable I want it to take arguments like this \draw[arrow inside={pos = 0.1, end ...
24
votes
2answers
604 views

What is the correct way to get a pgfkey value?

This is my first foray into the pgfkeys package and I found the following behavior really odd. The Tikz/pgfkeys manual mentions two ways for setting key values: \pgfkeys{key=value} and ...
17
votes
4answers
1k views

Multiple TikZ keys with foreach

Playing around with pgffor, I'm trying to slightly modify an example from the TikZ/pgf manual: \path \foreach \x/\content/\style in {% 0/a/draw, 1/b/{draw,red}, 2/c/{circle,blue}, 3/d/draw% } ...
17
votes
2answers
291 views

When to use a regular .initial key or a .store in key?

The excellent pgfkeys package provides, among others, two kinds of keys: regular "value-centric" keys that can be declared with /.initial, and "macro-centric" keys are declared with /.store in. Here ...
16
votes
2answers
793 views

How to extract the value from a pgfkeys style element

Lets say I have defined some style: \tikzset{mystyle/.style={inner xsep=2pt, outer xsep=10pt}} Given the name of the style: How can I later get the (possibly overriden) value of one of its element, ...
14
votes
3answers
458 views

The '.is if' handler of pgfkeys

Let us start with an example from the pgf manual, version 2.10, page 495: \pgfkeys{/flat world/.is if=theworldisflat} \pgfkeys{/flat world=false} \def\x#1{% code-A \iftheworldisflat Flat ...
14
votes
2answers
617 views

Is there a way to set a *global* key value using `pgfkeys`?

The simple answer to this question appears to be "No"; quoting from the pgf manual: The setting of a key is always local to the current TeX group. However, this is very annoying because it means ...
14
votes
2answers
394 views

PGF Keys differences between .initial and .default

I am not too sure just by reading the manual as to the subtle differences between the .initial and .default PGF key types. Can someone explain and demonstrate the differences with a minimal example?
13
votes
4answers
281 views

How do you test whether a known key value has been set in pgfkeys

Using the .code handler to my keys and a private macro, I can easily test whether a key has been set when using pgfkeys. For example: \documentclass{article} \newcounter{mytestenvcounter} ...
13
votes
1answer
132 views

Which arguments of `\includegraphics` cannot be set beforehand?

From the documentation of the graphicx package: Most of the keyval keys used in the graphicx package may also be set using the command \setkeys provided by the keyval package. For instance, ...
12
votes
3answers
199 views

Is there a compact way to set the same default for multiple pgfkeys?

I want to set the same default value for multiple PGF keys, like in this case where both a and b have a default of 1: \documentclass{article} \usepackage{pgfkeys} \pgfkeys{ a/.code={a:#1}, ...
12
votes
5answers
379 views

What do the pgfkeys key handlers .get and .store in do?

When I need to retrieve the value of a key in a macro, I use the key handlers .get and .store in. Here is what is written in the pgfkeys documentation: Key handler key /.get= macro Executes a ...
12
votes
2answers
419 views

Key that takes a list of other keys as argument and sets them

I would like to define a key, let's call it mystyle, which has several subkeys, like mystyle/A and mystyle/B, and I'd like to be able to choose which of these subkeys to set by calling mystyle=A, ...
12
votes
2answers
450 views

How to detect if option provided via \tikzset

I would like to be able to detect if a particular option has been provided via a \tikzset and issue a message based on that. The MWE yields: But once the conditional works (just a comment for ...
12
votes
2answers
125 views

Forbidding/requiring certain pgfkeys?

I have some commands whose named arguments are processed by pgfkeys \dog[breed=Labrador, name=Fido] \human[name=John, car owned=Porsche] How can I arrange that \dog[breed=Labrador, car ...
12
votes
2answers
10k views

Weird tikz/pgfkeys error while trying example from the tikz manual.

I am still learning to use tikz from the manual. I got an error for this code: \documentclass[twocolumn,english]{article} \usepackage{tikz} \begin{document} \begin{figure} \centering ...
11
votes
1answer
331 views

How can I put “=” in a TikZ node label specified as an option

When I try to put an = symbol into a TikZ node label specified as an option (using label=), I get an error: Extra }, or forgotten $. Is there a way to specify = in such cases that I'm missing? ...
11
votes
0answers
2k views

MacTeX pgfkeys/tikz package fails [closed]

the document listed below, (taken from here: texample.net) fails on my system (running MacTeX 2011) with the error: Package pgfkeys Error: I do not know the key '/tikz/drop shadow' and I am going to ...
10
votes
2answers
898 views

Using pgfkeys as an argument to a macro

I would like to use pgfkeys in a macro but find the documentation a bit hard to get started with. The following code should illustrate the problem I am trying to solve: \documentclass{article} ...
10
votes
2answers
286 views

What is the best way to alias a key using PGF Keys

I would like to be able to alias a PGF key to another name, is this possible and if it is, how do I do this? For example if I have defined a key as: \pgfkeys{path/ color/.store in=\color@cx ...
10
votes
2answers
1k views

pgfplotstable: How to access column name?

I have used \pgfplotstableset to assign column names in the preamble. However, I don't know how to access them. \documentclass{article} \usepackage{amsmath} \usepackage{pgfplots, pgfplotstable, ...
9
votes
3answers
768 views

Optional arguments in pgfkeys?

I need an optional argument in a pgfkey? Something like the following: \pgfkeys{example/.code = (Argument: #2, optional argument: #1)} \pgfkeys{example=[other]{some}} should result in (Argument: ...
9
votes
2answers
1k views

Simple example of pgfkeys

I'm struggling to get my head around the pgfkeys package. I currently use the keycommand package, which I find very easy to understand: it's just ordinary LaTeX commands with named rather than ...
9
votes
2answers
434 views

Can pgfkeys deal with active comma?

When I tried to compile \begingroup \def\iden#1{#1} \catcode`\,=13 \catcode`\==13 \iden{\endgroup \pgfkeys{/my family/.is family} \pgfkeys{/my family/my keys/.cd, ...
9
votes
2answers
216 views

Problem with loop-generated pkgkeys containing a space

I'm trying to use \pgfkeys in the following setting: \documentclass{article} \usepackage{tikz} \usepackage{pgfkeys} \begin{document} \begin{tikzpicture}[% m1 color/.initial=red, m2 ...
9
votes
1answer
321 views

Is it possible to set a default value for an argument in a TikZ style?

In a command like: \tikset{qar/.style={draw,rectangle,fill=#1}} is it possible to add a default key value for the option fill so that if you have: \node [qar] {}; the node will be filled with ...
9
votes
1answer
127 views

Working with keys instead of \def

I have looked around on TeX.SX and I have learnt a lot of things. One of the things I have not yet mastered is how to use the key=value function that packages like keyval or xkeyval offer or even ...
9
votes
1answer
170 views

Is it possible to store \pgfmathresult in a pgfkey?

I would like to perform a calculation using \pgfmathparse and then store \pgfmathresult as the value of a pgfkey. \documentclass{article} \usepackage{tikz} \begin{document} ...
9
votes
1answer
948 views

Style to make axis tick label opaque

I would like to make a specific tick label have a white opaque fill around it, so that the a line does not cross over it. Ideally I would like to be able to specify exactly which tick, but do not ...
9
votes
2answers
275 views

Expansion problems with pgfkeys

I'm using pgfkeys, and a fairly adventurous syntax in which the values for some keys contain additional key/value pairs. (For instance, the value of the nodes key is a list of pairs, and the second ...
9
votes
1answer
276 views

Creating tikz anchors based on pgfkey value

I'm trying to create several anchors equally spaced on the edge of my shape. The way I've tried to do this is to pass a key value in the node that would then define the anchors. The following code is ...
8
votes
3answers
327 views

How to know the status of a style? defined? empty?

mystyle/.style= {...} is perhaps used ? I would like to know how to verify if the style is really defined and in this case, I would like to know if the style is empty ? Is it possible to use ...
8
votes
2answers
579 views

Problems with pgfkeys

I'm trying to use pgfkeys to define commands with custom parameters, but I can't even get the example in pgfmanual to run: \documentclass{article} \usepackage{pgfkeys} \begin{document} ...
8
votes
2answers
266 views

Correct use of arguments pattern in pgfkeys/append after command in tikz?

I could not find many examples for the correct use of arguments patterns in pgfkes, but I was able to come up with the following: \documentclass{standalone} \usepackage{tikz} ...
8
votes
2answers
566 views

Accessing a style property in TikZ? [duplicate]

Possible Duplicate: How to extract the value from a pgfkeys style element Let us assume I have defined the following TikZ style: \tikzset{ mystyle/.style={draw, fill=green, node ...
8
votes
2answers
189 views

How to create and use a new pgf key

In this example, I would like to have a new key NbGrad then I could write : \begin{tikzpicture}[>=stealth,x=6cm,font=\footnotesize,NbGrad=12] And use the key as I use \NbGrad or another way if ...
8
votes
2answers
184 views

How to make this pgfkeys code more compact and streamlined?

I have just managed to create my first command with pgfkeys. I defined a command \myset, whose purpose is to make (for example) \myset[big]{abc} correspond to \bigl\{abc\bigr\} Part of my goal ...
8
votes
1answer
188 views

Avoiding `Dimension too large' and `ill-formatted floating point' errors in tikz

I am attempting to draw some pictures using tikz, with the decorations library, and am encountering a `Dimension too large' error. I have read the 20+ other questions/answers about this error, and ...
8
votes
2answers
121 views

Is there a way to define starred variants for a keyvalue system?

I've created an environment for which various parameters are set through key values. Instead of creating a hornet's nest of various booleans, I would just like to have a slight variant form for some ...
8
votes
1answer
235 views

Shorten both ends of a line with one key

Consider the following snippet: \begin{tikzpicture} \def\ptRad{2pt} \fill (0,0) circle (\ptRad); \fill (1,1) circle (\ptRad); \draw[<->, shorten <=\ptRad,shorten >=\ptRad] ...
8
votes
1answer
99 views

How do I pass an unknown value to a choice key in pgfkeys?

Why is the parameter value not being passed to my code for the unknown key value here? \documentclass{article} \usepackage{pgfkeys} \makeatletter \def\ae@size{2cm} \pgfkeys{/ae/example/.cd, ...
8
votes
1answer
351 views

pgfmathprintnumber in bold and/or sans serif

I've set some pgfkeys such as precision=2 and use comma. Now I wonder how do I get the results of \pgfmathprintnumber{123.567} to be bold and/or sans serif? I thought this is easy, but everything ...
8
votes
1answer
113 views

pgfkeys overeager in stripping away my braces

This is an extremely minimal example of what I'm trying to do. \documentclass{article} \usepackage{pgfkeys} \pgfkeys { /ae/example/set/parameters/.cd, keya/.code = { \def\mykeya{#1} }, ...
8
votes
1answer
81 views

Why is my /.is choice key not working correctly?

This example is much longer than it really needs to be, but I don't have the time to prune it down right now (apologies!). Everything in this example works as expected except the my fill key which is ...
7
votes
2answers
251 views

Creating anchors in a shape with a \foreach loop

I was playing around with this question, and in particular tried to modify and expand the linked example. It works fine, but there is an error when I try to use a \foreach loop to define the different ...
7
votes
2answers
199 views

Using LaTeX commands inside pgfplotsset

Is there any way to use LaTeX commands inside \pgfplotsset? For instance, the following code produces an error indicated in the \pgfplotsset line, whereas if one replaced \contents in the ...
7
votes
2answers
300 views

Restoring previous value of PGF/TikZ key?

How does one restore the previous value of a PGF/TikZ key? For example, I would like to set the inner sep of a matrix to 0em but set the inner sep of nodes within the matrix to be the value that ...