[pgf-tikz] Style with two "parameters" : problem with arguments
Yukai Chou
muzimuzhi at gmail.com
Fri Aug 9 16:01:38 CEST 2024
Hi Claude,
Unfortunately, what you encountered, though perhaps puzzling, was
"worked as expected".
Similar to the key handler /.code 2 args={<code>}, handler /.style 2
args={<styles>} stores the `<styles>` in an internal macro, whose
parameter always ends with \pgfeov
\def\some at internal@macro#1#2\pgfeov{<styles>}
That \pgfeov makes the #2 delimited. Combining with the space trimming
behavior of key-value processing done by pgfkeys package,
- In "->- = {0.6} {latex}", #1 <- "0.6" and #2 <- " {latex}" (note the
leading space), which leads to "decoration={markings, mark=at
position{0.6} with {\arrow {latex}}" thus works.
- In "->- = {0.6}{{latex}}", #2 <- "{latex}", which leads to
"...\arrow{latex}..." thus also works.
- In "->- = {0.6}{latex}", #2 <- "latex", which leads to something
equivalent to "...\arrow latex" thus errors.
- In "->-= {0.6}{[ultra thick]{>}}", #2 <- "[ultra thick]{>}", which
leads to "...\arrow[ultra thick]{>}..." thus again works.
- In "->-= {0.6} {[ultra thick]{>}}", #2 <- " {[ultra thick]{>}"
(again the leading space), which leads to "... \arrow {[ultra
thick]{>}" thus errors.
Handler /.style n args={<n>}{<styles>} doesn't delimit the parameter
text, thus can give a more consistent behavior, of which the space(s)
between arguments are always skipped (just like the macros defined by
\newcommand[<n>]\cmd{<code>}.)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset{->-/.style n args = {2}{decoration={markings, mark=at
position{#1} with {\arrow#2}},
postaction=decorate}}
\begin{document}
\begin {tikzpicture}
\draw [->- = {0.6} {latex}] (0,0) -- (1,0) ; % errors
\draw [->- = {0.6}{{latex}}] (2,0) -- (3,0) ;
\draw [->- = {0.6}{latex}] (4,0) -- (5,0) ; % errors
\draw [->-= {0.6}{[ultra thick]{>}}] (6,0) -- (7,0) ;
\draw [->-= {0.6} {[ultra thick]{>}}] (8,0) -- (9,0) ;
\end {tikzpicture}
\end{document}
Similar discussions
- https://github.com/pgf-tikz/pgf/issues/1201
- https://github.com/pgf-tikz/pgf/issues/1350
best regards,
Yukai Chou
<pgf-tikz-request at tug.org> 于2024年8月9日周五 20:55写道:
>
> Send pgf-tikz mailing list submissions to
> pgf-tikz at tug.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://tug.org/mailman/listinfo/pgf-tikz
> or, via email, send a message with subject or body 'help' to
> pgf-tikz-request at tug.org
>
> You can reach the person managing the list at
> pgf-tikz-owner at tug.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of pgf-tikz digest..."
>
>
> Today's Topics:
>
> 1. Style with two "parameters" : problem with arguments
> (Claude Quitte)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 9 Aug 2024 07:55:45 +0200
> From: Claude Quitte <claude.quitte at orange.fr>
> To: pgf-tikz at tug.org
> Subject: [pgf-tikz] Style with two "parameters" : problem with
> arguments
> Message-ID: <1310d660-47d0-3cb4-53c1-64cb91e33f1c at orange.fr>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
>
> Hello
>
> I attach a small LaTeX source using tikz and the pdf produced.
>
> 1. Context :
>
> \usepackage{tikz}
> \usetikzlibrary{decorations.markings}
>
> \tikzset{->-/.style 2 args = {decoration={markings, mark=at position{#1}
> with {\arrow#2}},
> postaction=decorate}}
>
> 2. No problem with :
>
> \draw [->- = {0.6} {latex}] (0,0) -- (1,0) ;
> \draw [->- = {0.6}{{latex}}] (2,0) -- (3,0) ;
>
> 3. But, if no space between arguments, a problem with \draw [->- =
> {0.6}{latex}] (4,0) -- (5,0) ;
> %% \draw [->- = {0.6}{latex}] (4,0) -- (5,0) ;
> %% ! Package pgf Error: Unknown arrow tip kind 'l'.
> %% See the pgf package documentation for explanation.
> %% Type H <return> for immediate help.
> %% ...
> %% l.17 \draw [->- = {0.6}{latex}] (4,0) -- (5,0) ;
>
>
> 4. No problem with
>
> \draw [->-= {0.6}{[ultra thick]{>}}] (6,0) -- (7,0) ;
>
> 5. But, if a space between arguments, a problem with \draw [->-= {0.6}
> {[ultra thick]{>}}] (8,0) -- (9,0) ;
>
> %% \draw [->-= {0.6} {[ultra thick]{>}}] (8,0) -- (9,0) ;
> %% ! Package pgfkeys Error: I do not know the key 'ultra thick' and I am
> going to
> %% ignore it. Perhaps you misspelled it.
> %%
> %% See the pgfkeys package documentation for explanation.
> %% Type H <return> for immediate help.
> %% ...
> %% l.28 ...{0.6} {[ultra thick]{>}}] (8,0) -- (9,0) ;
>
>
> THANKS for an answer.
>
> Claude Quitte (France)
>
>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: ArgumentsProbem.tex
> Type: application/x-tex
> Size: 1337 bytes
> Desc: not available
> URL: <https://tug.org/pipermail/pgf-tikz/attachments/20240809/58e57d1f/attachment.tex>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: ArgumentsProbem.pdf
> Type: application/pdf
> Size: 38364 bytes
> Desc: not available
> URL: <https://tug.org/pipermail/pgf-tikz/attachments/20240809/58e57d1f/attachment.pdf>
>
> End of pgf-tikz Digest, Vol 29, Issue 1
> ***************************************
More information about the pgf-tikz
mailing list.