Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second argument for .code 2 args is not optional #1010

Closed
fritzw opened this issue Apr 29, 2021 · 2 comments
Closed

Second argument for .code 2 args is not optional #1010

fritzw opened this issue Apr 29, 2021 · 2 comments

Comments

@fritzw
Copy link

fritzw commented Apr 29, 2021

In section "87.4.3 Defining Key Codes" under .code 2 args, the manual states:

The second argument is optional: if it is not provided, it will be the empty string. Because of the special way the 'value' is parsed, if you set 'value' to, for instance, first (without any braces), then #1 will be set to f and #2 will be set to irst.

This appears to be false. If you pass a single braced argument, pgfkeys will always parse the first character as #1 and the rest as #2, even if you use double braces. Only when using triple braces, does it work as advertised in the manual.

Minimal working example (MWE)

\documentclass{article}
\usepackage{tikz}

\tikzset{
	my plain key/.code 2 args={1=#1, 2=#2},
}

\begin{document}
\pgfkeys{/tikz/my plain key={Expected result}{}}

\pgfkeys{/tikz/my plain key={First only}}

\pgfkeys{/tikz/my plain key={First}{Second}}

\pgfkeys{/tikz/my plain key={{Double Braces}}}

\pgfkeys{/tikz/my plain key={{{Triple Braces}}}}
\end{document}

Result:

image

@hmenke
Copy link
Member

hmenke commented Apr 29, 2021

Exact duplicate of #991. Please search existing issues before opening a new one.

@fritzw
Copy link
Author

fritzw commented Apr 29, 2021

Sorry, I did a search for "code 2 args" but that did not turn up anything. Obviously I forgot to search for closed issues as well. :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants