2

I would like to store a coordinate tuple as used by tikz in a pgfkeys variable. In the following MWE, I would like to pass the tuple (0.5,0.5) to the command and store it in the variable \position:

\documentclass{article}

\usepackage{tikz,pgfkeys}
\usetikzlibrary{calc}

\pgfkeys{
    /absolutenode/.is family, /absolutenode,
    default/.style = {},
    position/.store in = \position,
}

\newcommand\absolutenode[2][]{%
    \pgfkeys{/absolutenode, default, #1}%
    \tikz[remember picture,overlay,x=\paperwidth,y=\paperheight]{%
        \node[anchor=center,inner sep=0pt] at ($(current page.south west)+\position$) {#2};
    }
}

\begin{document}
    \absolutenode[position=(0.5,0.5)]{Test}
\end{document}

However the comma in the tuple seems to be the problem. How can I fix this?

0

1 Answer 1

1

As @gernot mentions, you need to surround the coordinates by braces. But according to what I find, this does not yet work, but it does work if you also use shift instead of using calc.

\documentclass{article}

\usepackage{tikz,pgfkeys}

\pgfkeys{
    /absolutenode/.is family, /absolutenode,
    default/.style = {},
    position/.store in = \position,
}

\newcommand\absolutenode[2][]{%
    \pgfkeys{/absolutenode, default, #1}%
    \tikz[remember picture,overlay,x=\paperwidth,y=\paperheight]{%
        \node[anchor=center,inner sep=0pt] at ([shift={\position}]current page.south
        west) {#2};
    }
}

\begin{document}
    \absolutenode[position={(0.5,0.5)}]{Test}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .