23
votes
Accepted
Why is pgf 3.1 not compatible with tex?
The answer why PGF 3.1 does not support Knuth TeX is two-fold.
It is the current year. By now e-TeX is over 20 years old and has simplified TeX development tremendously. I consider it a bug on your ...
18
votes
Accepted
Tikz: adjusting pin anchor
When TikZ places a label (or a pin) it calculates a point that is label distance (or pin distance) away from a point on the anchor-border of its parent node.
This point on the anchor-border is ...
14
votes
Accepted
How to create a table automatically for a homework in statistics?
I suspected that your question How do I use the ampersand (&) inside a foreach or conditional (or other group/environment) when building tables?
was of the XY type.
The usual problem in these ...
13
votes
Is there a compact way to set the same default for multiple pgfkeys?
Yes it is the /.list handler. The argument to it is passed to a \foreach array and at each spin next item is passed to the original handler.
\documentclass{article}
\usepackage{pgfkeys,pgffor}
\...
13
votes
Accepted
Which arguments of `\includegraphics` cannot be set beforehand?
Brilliant documentation isn't it:-)
In general setting keys is more or less just making macro definitions, so the ones you can't set in advance are the ones that are initialised by \includegraphics ...
12
votes
Accepted
create new TikZ key with code and style tags
Here is an example how you can do this :
\documentclass[varwidth,border=10]{standalone}
\usepackage{tikz}
\begin{document}
\tikzset{
mykey/.code args={#1,#2,#3}{
% perform complicated ...
11
votes
Accepted
pgfplots: How to define a key and set its value?
I'll rename your \alph macro to \alphstore because I am a coward and fear that redefining LaTeX's \alph command, even locally, might have undesirable side effects in some cases.
Background and ...
11
votes
tikz pic custom keys
A self-answer by the OP:
I did a bit more reading around, and found some useful information in particular in this answer. The following code works, but I wouldn't say I have any expertise about ...
10
votes
Pass a 3d coordinate via pgfkeys
As stated in my comment, the fundamental problem is that the statement
\coordinate (A) at (1,1,0);
only stores the 2d representation of the point in (A).
Using pgfkeys we can define a new command ...
10
votes
How to create and manage hierarchically dependent PGF keys?
You can use the handler .unknown to set up the fallback.
\documentclass[border=9,tikz]{standalone}
\usetikzlibrary{trees,shapes.geometric}
\begin{document}
\pgfkeys{
%/hierarkey/.unknown/.code={\...
9
votes
Is there a compact way to set the same default for multiple pgfkeys?
You do have a macro processor to hand so you could define a macro for it if tikz doesn't offer the functionality directly:
\documentclass{article}
\usepackage{pgfkeys}
\def\foo#1{\pgfkeys{#1/.code={#...
9
votes
PGF Keys differences between .initial and .default
Although this does not specifically add anything to the answer already provided, the following example helped me understand the difference more intuitively:
\documentclass{article}
\usepackage{...
9
votes
Accepted
How to get line width and inner sep values?
Your own style doesn't change any intrinsic properties of the line width and inner sep settings. So you can still use the regular key setting/reading ways.
\documentclass[tikz]{standalone}
\begin{...
9
votes
Setting a length with a key to a TikZ node
The explanation, that TikZ is using \nullfont is already given in percusse's answer. Therefore \settowidth will not work as expected.
\pgfmathsetlength{width("#1")}
Instead of \settowidth the ...
9
votes
Accepted
How do you define a default choice in pgfkeys
Default for an is choice is one of the choices, so simply do this:
\pgfkeys{/tmp/.is choice}
\pgfkeys{/tmp/list/.code={...}}
\pgfkeys{/tmp/.default=list}
This small example shows the expected ...
9
votes
Accepted
How to pass parameters to \tikzstyle?
Everything about keys is detailed in section "87 Key Management" in pgf documentation. But about your code:
once you define a style with parameters, use style=parameter_value to change it. You ...
9
votes
Accepted
Plot decorated arrows in pgf?
Your arrows are drawn with new computations of f(x) for every x value, and since f uses rand, you obtain different values from those that were used for the curve. In order to solve this problem, I ...
8
votes
Accepted
Passing (just) other options, when using pgfopts
You're mixing the two methods for setting options, which results in the warning.
\begin{filecontents}{exa.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{exa}[2014/03/19 exa]
% As "article" with "...
8
votes
Accepted
How to store tcolorbox's (multiple) settings in a macro?
With the combination of the code option plus \pgfkeysalsofrom from pgfkeys you can use options stored in a macro:
\documentclass{article}
\usepackage{tcolorbox}
%
\newcommand*\foo{colback=red,...
8
votes
Accepted
Using LaTeX commands inside pgfplotsset
Probably Till Tantau was having similar problems so he created the error messages in a smarter way. Example; if I go something like this
\tikz[xasfwr=yeah]{}
The error message is
Package ...
8
votes
Setting a length with a key to a TikZ node
TikZ/PGF design is done in such a way that its regular syntax doesn't have any spurious whitespace leaks or unintended characters are printed out inside the code etc. One way of doing it is to map the ...
8
votes
Accepted
tikz shapes, not quite getting things right (anchors and keys)
Here's a fully worked through example of (what I understand to be) the required shape from first principles (i.e., without inheritance). I exploit the (undocumented) \addtosavedmacro command which can ...
8
votes
Accepted
Change the optional arguments in the interval package
Sure!
\documentclass{article}
\usepackage{interval}
\intervalconfig{
ol/.style={open left},
}
\begin{document}
$\interval[ol]{a}{b}$
$\interval[open left]{a}{b}$
\end{document}
8
votes
Accepted
pgfkeys Error: I do not know the key '/tikz/green '
The error comes from the fact that you define
\newcommand{\chooseColor}{\ifnum\thetest=1 green \else red \fi}
Hence, you assign \chooseColor with green or red with a trailing space. This space is ...
7
votes
Accepted
Is there a compact way to set the same default for multiple pgfkeys?
Using pgffor (@percusse beat me to it but this is still a little different in allowing you to have different defs for a and b):
\documentclass{article}
\usepackage{pgfkeys}
\usepackage{pgffor}
\...
7
votes
Does expl3 key-setting syntax have an equivalent of TikZ/PGF's .cd?
Short answer: no.
The idea of using a keyval approach to setting up keys themselves was (that I know of) first implemented for TeX in pgfkeys. When writing l3keys I looked very hard at this for a ...
7
votes
Accepted
rounding to one decimal woes...
The macro \pgfmathprintnumber uses math mode for this.
I suggest changing the definition of \prlen:
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\prlen}{m}
{
\fp_eval:n { round(\...
7
votes
Accepted
Best Key-Value System For LaTeX
There is no concept of best in the TeX world.
As mentioned in the comments, most active key-value handling packages are pgfkeys and the l3keys. The latter is also inspired by pgfkeys however it ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pgfkeys × 522tikz-pgf × 240
pgfplots × 45
macros × 41
key-value × 37
tikz-styles × 24
tcolorbox × 23
expansion × 22
pgfmath × 19
errors × 15
beamer × 11
conditionals × 10
circuitikz × 10
pgfopts × 10
nodes × 9
foreach × 9
pgfplotstable × 8
package-writing × 8
documentclass-writing × 7
color × 6
expl3 × 6
package-options × 6
tikz-pic × 6
tables × 5
graphics × 5